Код: Выделить всё
container.RegisterTypes(
AllClasses.FromAssembliesInBasePath(),
WithMappings.FromAllInterfaces,
WithName.TypeName,
WithLifetime.PerResolve
);
Код: Выделить всё
namespace Taschenrechner
{
public interface IBerechne
{
int Berechnen(Formel formel);
}
}
Код: Выделить всё
class Addition : IRechenoperation
{
public char Operator
{
get
{
return '+';
}
}
public int Berechnen(int operand1, int operand2)
{
return operand1 + operand2;
}
}
class Subtraktion : IRechenoperation
{
public char Operator
{
get
{
return '-';
}
}
public int Berechnen(int operand1, int operand2)
{
return operand1 - operand2;
}
}
Код: Выделить всё
public Parser(Formel formel,IRechenoperation[] rechenoperationen)
{
this.ergebnisformel = formel;
this.rechenoperationen = rechenoperationen;
}
Подробнее здесь: https://stackoverflow.com/questions/331 ... -instanced
Мобильная версия