Answer the question
In order to leave comments, you need to log in
How to use the same code with different libraries?
Hello.
I'm using a model library which uses two other libraries to deal with the context of a model depending on its type.
Let it be Type1 and Type2 .
The principle of operation for both libraries is completely the same, the classes are identical, only the paths to these classes differ.
For example, for the first Type1.Resource and for the second Type2.Resource .
To work with the model, I created two classes LinksMasterType1 and LinksMasterType2 , with completely identical code, but with a different set of plug-in libraries.
For the first:
using Type1.Resource;
For the second, respectively, Type2.Resource.
The classes have one common interface, ILinksMaster .
Further, depending on the model type, I initialize the required class and work in the program through it.
ILinksMaster linksMaster = null;
switch(type)
case(type1)
linksMaster = new LinksMasterType1();
break;
case(type2)
linksMaster = new LinksMasterType2();
break;
Answer the question
In order to leave comments, you need to log in
Maxim Lensky , it’s quite possible to make it with the addition of blocks, and divkas, and so that it stretches.
Three columns and a background below them. The size of the background depends on the width of the side, just like the columns. Since their size changes in the same way, it will be enough to move the background. And then the browser itself will do everything.
PS Don't forget to tear off the designer's legs. The task is doable, both in css and js, but I doubt that the designer is competent in this matter. And in general, it’s better not to generate such crap in fantasies, it looks so-so, it makes no sense.
The interface is a good idea. But for this you need to think it over well. There is another way to use reflection and dynamic connection of assemblies, but this is resource-intensive.
Generic classes
class Link<T>
{
public string WhatClass()
{
if (typeof(T) == typeof(int))
return "Number";
else
if (typeof(T) == typeof(string))
return "Text";
return "X3";
}
}
static void Main(string[] args)
{
var link = new Link<string>();
var cl = link.WhatClass();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question