Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the player.</param>
 /// <param name="factory">The factory for this player (represent the nation).</param>
 public Player(string name, IUnitFactory factory)
 {
     this.name = name;
     this.factory = factory;
     count++;
     this.number = count;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Build the game.
        /// Creates the game manager with the right players, units and map.
        /// </summary>
        /// <remarks>
        /// The map is created in the C++ library as for the unit positions.
        /// </remarks>
        /// <param name="name1">The first player's name.</param>
        /// <param name="factory1">The factory for the first player.</param>
        /// <param name="name2">The second player's name.</param>
        /// <param name="factory2">The factory for the second player.</param>
        /// <returns>The game manager.</returns>
        public IGame BuildGame(string name1, IUnitFactory factory1, string name2, IUnitFactory factory2)
        {
            // Builds the map using the MapBuilder:
            IMap map = MapBuilder.Instance.BuildMap(this.mapSize);
            ITile[,] tiles = map.Tiles;
            int[][] mapAsIntegers = TileFactory.GetNumbers(tiles);

            IPlayer player1 = new Player(name1, factory1);
            IPlayer player2 = new Player(name2, factory2);

            // Retrieves the starting points from the wrapper:
            int[][] starts = Wrapper.getStartsPlayers(mapAsIntegers, this.mapSize);
            IPoint startPlayer1 = new Point(starts[0][0], starts[0][1]);
            IPoint startPlayer2 = new Point(starts[1][0], starts[1][1]);

            // Creates and places the units for each player:
            List<IUnit> units1 = player1.CreateUnits(this.nbUnits);
            for(int i = 0; i < this.nbUnits; i++) {
                map.PlaceUnit(units1[i], startPlayer1);
            }
            List<IUnit> units2 = player2.CreateUnits(this.nbUnits);
            for(int i = 0; i < this.nbUnits; i++) {
                map.PlaceUnit(units2[i], startPlayer2);
            }

            return new Game(player1, player2, map, this.maxRounds);
        }
        public Engine(IUserInterface userInterface,IDatabase db)
        {
            this.buildingFactory = new BuildingFactory();
            this.resourceFactory = new ResourceFactory();
            this.unitFactory = new UnitFactory();

            this.io = userInterface;
            this.db = db;
        }
Exemplo n.º 4
0
 public Engine(IUnitFactory unitFactory, IResourceFactory resourceFactory,IBuildingFactory buildingFactory, IInputReader reader, IOutputWriter writer, IEmpiresData data)
 {
     this.unitFactory = unitFactory;
     this.resourceFactory = resourceFactory;
     this.buildingFactory = buildingFactory;
     this.reader = reader;
     this.writer = writer;
     this.data = data;
 }
Exemplo n.º 5
0
 public Engine(IBuildingFactory buildingFactory, IResourceFactory resourceFactory, IUnitFactory unitFactory, IData data, IInputReader reader, IOuptupWriter writer)
 {
     this.buildingFactory = buildingFactory;
     this.resourceFactory = resourceFactory;
     this.unitFactory = unitFactory;
     this.data = data;
     this.reader = reader;
     this.writer = writer;
 }
Exemplo n.º 6
0
 public Engine(IBuildingFactory buildingFactory, IResourseFactory resourseFactory, IUnitFactory unitFactory, IData empireData, IInputReader reader, IOutputWriter writer)
 {
     this.buildingFactory = buildingFactory;
        this.resourseFactory = resourseFactory;
        this.unitFactory = unitFactory;
        this.empireData = empireData;
        this.reader = reader;
        this.writer = writer;
 }
Exemplo n.º 7
0
 public Barracks(IUnitFactory unitFactory, IResourceFactory resourceFactory)
     : base(BarracksUnitType,
           BarracksUnitCycleLength,
           BarracksResourceType,
           BarracksResourceCycleLength,
           BarracksResourceQuantity,
           unitFactory, 
           resourceFactory)
 {
 }
Exemplo n.º 8
0
 public Barracks(IUnitFactory unitFactory, IResourceFactory resourceFactory)
     : base(UnitType,
          UnitCicleLenth,
          BarracsResourceType,
          ResourceCicleLength,
          ResourceQuantity,
          unitFactory,
          resourceFactory)
 {
 }
Exemplo n.º 9
0
 public Archery( IUnitFactory unitFactory, IResourceFactory resourseFactory)
     : base(ArcheryUnitType,
            ArcheryUnitCycleLength,
            ArcheryResourseType,
            ArcheryResourceCycleLength,
            unitFactory,
            ArcheryResourceQuantity,
            resourseFactory)
 {
 }
 protected Building(string unitType, int unitCycleLength, ResourceType resourceType, int resourceCycleLength, int resourceQuantity, IUnitFactory unitFactory, IResourceFactory resourceFactory)
 {
     this.unitType = unitType;
     this.unitCycleLength = unitCycleLength;
     this.resourceType = resourceType;
     this.resourceCycleLength = resourceCycleLength;
     this.resourceQuantity = resourceQuantity;
     this.unitFactory = unitFactory;
     this.resourceFactory = resourceFactory;
 }
Exemplo n.º 11
0
 public Archery(IUnitFactory unitFactory, IResourceFactory resourceFactory)
     : base(UnitType,
          UnitCicleLenth,
          ArcheryResourceType,
          ResourceCicleLength,
          ResourceQuantity,
          unitFactory,
          resourceFactory)
 {
 }
        public IBuilding CreateBuilding(string buildingType, IResourceFactory resourceFactory, IUnitFactory unitFactory)
        {
            var type = Assembly.GetExecutingAssembly()
                .GetTypes()
                .FirstOrDefault(t => t.Name.ToLowerInvariant() == buildingType);

            var building = (IBuilding)Activator.CreateInstance(type, unitFactory, resourceFactory);

            return building;
        }
Exemplo n.º 13
0
        public SimpleFixedUnitLayer(ISet<IUnit> units,
                                    IUnitFactory<Archer> archerFactory,
                                    IUnitFactory<Legion> legionFactory,
                                    IUnitFactory<Settler> settlerFactory)
        {
            Units = units;

            Units.Add(archerFactory.Create(RedArcherTile, Red));
            Units.Add(legionFactory.Create(BlueLegionTile, Blue));
            Units.Add(settlerFactory.Create(RedSettlerTile, Red));
        }
Exemplo n.º 14
0
 public IBuilding CreateBuilding(string buildingType, IUnitFactory unitFactory, IResourceFactory resourceFactory)
 {
     switch (buildingType)
     {
         case "archery":
             return new Archery(unitFactory, resourceFactory);
         case "barracks":
             return new Barracks(unitFactory, resourceFactory);
         default:
             throw new ArgumentException("Unknow building type.");
     }
 }
        public IBuilding CreateBuilding(string buildingType, IUnitFactory unitFactory, IResourceFactory resourceFactory)
        {
            // Reflection
            var type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.Name.ToLowerInvariant() == buildingType);
            if (type == null)
            {
                throw new AggregateException("Unknow building type");
            }
            var building = (IBuilding)Activator.CreateInstance(type, unitFactory, resourceFactory);

            return building;
        }
        public IBuilding CreateBuilding(string buildingType,IResourceFactory rf, IUnitFactory bf)
        {
            var type = Assembly.GetExecutingAssembly().GetTypes()
               .FirstOrDefault(t => t.Name.ToLowerInvariant() == buildingType);

            if (type == null)
            {
                throw new ArgumentException("Unknown building type.");
            }

            var building = (IBuilding)Activator.CreateInstance(type, rf, bf);

            return building;
        }
        public IBuilding CreateBuilding(string buildingType, IUnitFactory unitFactory, IResourceFactory resourceFacotory)
        {
            var type = Assembly.GetExecutingAssembly().GetTypes()
                .FirstOrDefault(t => t.Name.ToLowerInvariant() == buildingType);

            if (type == null)
            {
                throw new InvalidOperationException("Invalid building type.");
            }

            var building = Activator.CreateInstance(type, unitFactory, resourceFacotory) as IBuilding;

            return building;
        }
Exemplo n.º 18
0
 public Engine(
     IBuildingFactory buildingFactory,
     IResourceFactory resourceFactory,
     IUnitFactory unitFactory,
     IDatabase db,
     IInputReader reader,
     IOutputWriter writer)
 {
     this.buildingFactory = buildingFactory;
     this.resourceFactory = resourceFactory;
     this.unitFactory = unitFactory;
     this.db = db;
     this.reader = reader;
     this.writer = writer;
 }
Exemplo n.º 19
0
 protected Building(string unitType, int unitCycleLenght,
     ResourseType resourseType,
         int resoursesCycleLenght,
         int resourceQuantity,
         IUnitFactory unitFactory,
         IResourseFactory resourseFactory)
 {
     this.unitType = unitType;
     this.unitCycleLenght = unitCycleLenght;
     this.resourseType = resourseType;
     this.resourcseCycleLenght = resoursesCycleLenght;
     this.resourceQuantity = resourceQuantity;
     this.unitFactory = unitFactory;
     this.resourseFactory = resourseFactory;
 }
Exemplo n.º 20
0
 public UpgradedWarEngine(
     IRenderer renderer,
     IInputController inputController,
     IUnitFactory unitFactory,
     IArmyStructureFactory armyStructureFactory,
     ICommandFactory commandFactory,
     IContinent continent)
     : base(renderer,
     inputController,
     unitFactory,
     armyStructureFactory,
     commandFactory,
     continent)
 {
 }
Exemplo n.º 21
0
        internal UnitSystem(string name, IUnitFactory unitFactory, IUnitDialect dialect)
        {
            Check.Argument(name, nameof(name)).IsNotNull();
            Check.Argument(unitFactory, nameof(unitFactory)).IsNotNull();
            Check.Argument(dialect, nameof(dialect)).IsNotNull();

            this.unitFactory = unitFactory;
            this.dialect = dialect;
            this.Name = name;
            this.baseUnits = new Dictionary<Dimension, KnownUnit>();
            this.coherentUnits = new Dictionary<Dimension, Unit>();
            this.units = new Dictionary<Tuple<double, Dimension>, KnownUnit>();
            this.unitsBySymbol = new Dictionary<string, KnownUnit>();
            this.NoUnit = new DerivedUnit(this, 1, Dimension.DimensionLess);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitSystemDependencies"/> class.
 /// </summary>
 /// <param name="unitRegistry">The unit registry.</param>
 /// <param name="lexicalAnalyzer">The lexical analyzer.</param>
 /// <param name="expressionParser">The expression parser.</param>
 /// <param name="quantityParser">The quantity parser.</param>
 /// <param name="unitFactory">The unit factory.</param>
 /// <param name="quantityOperations">The quantity operations.</param>
 public UnitSystemDependencies(
     UnitRegistry unitRegistry,
     ILexicalAnalyzer lexicalAnalyzer,
     IExpressionParser expressionParser,
     IQuantityParser quantityParser,
     IUnitFactory unitFactory,
     IQuantityOperations quantityOperations)
 {
     this.UnitRegistry = unitRegistry;
     this.LexicalAnalyzer = lexicalAnalyzer;
     this.ExpressionParser = expressionParser;
     this.QuantityParser = quantityParser;
     this.UnitFactory = unitFactory;
     this.QuantityOperations = quantityOperations;
 }
Exemplo n.º 23
0
 public WarEngine(
     IRenderer renderer, 
     IInputController inputController, 
     IUnitFactory unitFactory,
     IArmyStructureFactory armyStructureFactory,
     ICommandFactory commandFactory,
     IContinent continent)
 {
     this.renderer = renderer;
     this.inputController = inputController;
     this.UnitFactory = unitFactory;
     this.ArmyStructureFactory = armyStructureFactory;
     this.CommandFactory = commandFactory;
     this.Continent = continent;
 }
Exemplo n.º 24
0
 protected Building(ResourceType resourceType,
     int resourceProduceTime,
     int resourceQuantity,
     string unitType,
     int unitProduceTime,
     IUnitFactory unitFactory,
     IResourceFactory resourceFactory)
 {
     this.resourceType = resourceType;
     this.resourceProduceTime = resourceProduceTime;
     this.Quantity = resourceQuantity;
     this.unitType = unitType;
     this.unitProduceTime = unitProduceTime;
     this.unitFactory = unitFactory;
     this.resourceFactory = resourceFactory;
 }
Exemplo n.º 25
0
 public Building(
     string unitType,
     int unitCicleLength,
     ResourceType resourceType,
     int resourceCicleLength,
     int quantity,
     IUnitFactory unitFactory,
     IResourceFactory resourceFactory)
 {
     this.unitType = unitType;
     this.unitCicleLength = unitCicleLength;
     this.resourceType = resourceType;
     this.resourceCicleLength = resourceCicleLength;
     this.quantity = quantity;
     this.unitFactory = unitFactory;
     this.resourceFactory = resourceFactory;
 }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QuantityOperations"/> class.
 /// </summary>
 /// <param name="unitFactory">The unit factory.</param>
 /// <param name="expressionReducer">The expression reducer.</param>
 /// <param name="valueFromBaseVisitor">From base visitor.</param>
 /// <param name="valueToBaseVisitor">To base visitor.</param>
 public QuantityOperations(
     IUnitFactory unitFactory,
     IExpressionReducer expressionReducer,
     ValueFromBaseVisitor valueFromBaseVisitor,
     ValueToBaseVisitor valueToBaseVisitor)
 {
     this.Addition = new AdditionOperation(valueFromBaseVisitor, valueToBaseVisitor);
     this.Subtraction = new SubtractionOperation(valueFromBaseVisitor, valueToBaseVisitor);
     this.Multiplication = new ReducingOperation(
         unitFactory,
         new UnitMultiplicationOperation(expressionReducer),
         new MultiplicationOperation());
     this.Division = new ReducingOperation(
         unitFactory,
         new UnitDivisionOperation(expressionReducer),
         new DivisionOperation());
     this.Exponentiation = new ExponentiationOperation(unitFactory, expressionReducer);
     this.NthRoot = new NthRootOperation(unitFactory, expressionReducer);
     this.ConvertToUnit = new ConvertToUnitOperation();
 }
Exemplo n.º 27
0
 /// <summary>
 /// Constructor for the deserialization.
 /// </summary>
 /// <param name="info">Information for the serialization.</param>
 /// <param name="context">The context for the serialization.</param>
 public Player(SerializationInfo info, StreamingContext context)
 {
     this.name = (string)info.GetValue("Name", typeof(string));
     this.points = (int)info.GetValue("Points", typeof(int));
     IUnitFactory vikingFactory = new VikingFactory();
     IUnitFactory gauloisFactory = new GauloisFactory();
     IUnitFactory dwarfFactory = new DwarfFactory();
     // Deserialises the factory by its unique number:
     int factoryNumber = (int)info.GetValue("Factory", typeof(int));
     if(factoryNumber == vikingFactory.Number) {
         this.factory = vikingFactory;
     } else if(factoryNumber == gauloisFactory.Number) {
         this.factory = gauloisFactory;
     } else if(factoryNumber == dwarfFactory.Number) {
         this.factory = dwarfFactory;
     } else {
         throw new IncorrectFactoryNumberException(factoryNumber);
     }
     this.number = (int)info.GetValue("Number", typeof(int));
     count++;
 }
Exemplo n.º 28
0
 public Engine(IRepository repository, IUnitFactory unitFactory)
 {
     this.repository         = repository;
     this.unitFactory        = unitFactory;
     this.commandInterpreter = new CommandInterpreter(unitFactory, repository);
 }
Exemplo n.º 29
0
 public Command(string[] data, IRepository repository, IUnitFactory unitFactory)
 {
     Data        = data;
     Repository  = repository;
     UnitFactory = unitFactory;
 }
Exemplo n.º 30
0
 public Engine(IOutputWriter writer, IInputReader reader, IResourceFactory resourceFactory, IUnitFactory unitFactory, IBuildingFactory buildingFactory, IDatabase database)
 {
 }
Exemplo n.º 31
0
 public void SetFactory(IUnitFactory factory)
 {
     _unitFactory = factory;
 }
Exemplo n.º 32
0
 public ReportCommand(string[] data, IRepository repository, IUnitFactory unitFactory) : base(data)
 {
     this.Repository = repository;
 }
Exemplo n.º 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExponentiationOperation" /> class.
 /// </summary>
 /// <param name="unitFactory">The unit factory.</param>
 /// <param name="expressionReducer">The expression reducer.</param>
 public ExponentiationOperation(IUnitFactory unitFactory, IExpressionReducer expressionReducer)
 {
     this.unitFactory       = unitFactory;
     this.expressionReducer = expressionReducer;
 }
Exemplo n.º 34
0
 protected Command(string[] data, IRepository repository, IUnitFactory unitFactory)
 {
     this.Data        = data;
     this.Repository  = repository;
     this.UnitFactory = unitFactory;
 }
Exemplo n.º 35
0
 public RetireCommand(string[] data, IUnitFactory unitFactory, IRepository unitRepository)
     : base(data, unitFactory, unitRepository)
 {
 }
Exemplo n.º 36
0
 public Engine(IBuildingFactory buildingFactory, IResourceFactory resourceFactory, IUnitFactory unitFactory, IEmpiresData data, IInputReader reader, IOutputWriter writer)
 {
     this.buildingFactory = buildingFactory;
     this.resourceFactory = resourceFactory;
     this.unitFactory     = unitFactory;
     this.data            = data;
     this.reader          = reader;
     this.writer          = writer;
 }
 public Add(string[] data, IUnitFactory factory, IRepository repository)
     : base(data)
 {
     this.UnitFactory = factory;
     this.Repository  = repository;
 }
Exemplo n.º 38
0
 public AddCommand(string[] data, IRepository repo, IUnitFactory fatory) : base(data, repo, fatory)
 {
 }
Exemplo n.º 39
0
 public Retire(string[] data, IRepository repository, IUnitFactory unitFactory)
     : base(data, repository, unitFactory)
 {
 }
Exemplo n.º 40
0
 public Building(string unitType, ResourceTypes resourceType, int unitCycle, int resourceCycle, int resourceQuantity, IResourceFactory resourceFactory, IUnitFactory unitFactory)
 {
     this.UnitType         = unitType;
     this.ResourceType     = resourceType;
     this.UnitCycle        = unitCycle;
     this.ResourceCycle    = resourceCycle;
     this.ResourceQuantity = resourceQuantity;
     this.ResourceFactory  = resourceFactory;
     this.UnitFactory      = unitFactory;
 }
Exemplo n.º 41
0
 public LocalEnemyUnitCommander(IUnitFactory factory) : base(factory)
 {
 }
Exemplo n.º 42
0
 public Engine(IRepository repository, IUnitFactory unitFactory, ContainerBuilder container)
 {
     this.repository  = repository;
     this.unitFactory = unitFactory;
     this.ioc         = container;
 }
Exemplo n.º 43
0
 public FightCommand(IRepository repository, IUnitFactory unitFactory, string[] data)
     : base(repository, unitFactory, data)
 {
 }
 /// <summary>
 /// Creates the parser.
 /// </summary>
 /// <param name="expressionParser">The expression parser.</param>
 /// <param name="unitFactory">The unit factory.</param>
 /// <returns>
 /// A <see cref="QuantityParser" />.
 /// </returns>
 public IQuantityParser CreateParser(IExpressionParser expressionParser, IUnitFactory unitFactory)
 {
     return(new QuantityParser(expressionParser, unitFactory));
 }
 public CommandInterpreter(IRepository repository, IUnitFactory unitFactory, string[] data)
     : base(repository, unitFactory, data)
 {
 }
Exemplo n.º 46
0
 public CommandInterpreter(IRepository repository, IUnitFactory unitFactory)
 {
     this.repository  = repository;
     this.unitFactory = unitFactory;
 }
Exemplo n.º 47
0
 public CommandInterpreter(IRepository repository, IUnitFactory unitFactory)
 {
     iocc = new DependencyContainer();
     iocc.AddDependency <IRepository, UnitRepository>(repository as UnitRepository);
     iocc.AddDependency <IUnitFactory, UnitFactory>(unitFactory as UnitFactory);
 }
Exemplo n.º 48
0
 public Engine(IRepository repository, IUnitFactory unitFactory)
 {
     this.commandInterpreter = new CommandInterpreter(repository, unitFactory);
 }
Exemplo n.º 49
0
 public Retire(string[] data, IRepository repository, IUnitFactory unitFactory)
     : base(data)
 {
     this.Repository  = repository;
     this.UnitFactory = unitFactory;
 }
Exemplo n.º 50
0
        /// <summary>
        /// Initializes the unit system.
        /// </summary>
        /// <param name="unitSystemDependencyFactory">The unit system dependency factory.</param>
        /// <param name="registerUnitAction">The register unit action.</param>
        public UnitSystemDependencies InitializeUnitSystem(
            IUnitSystemDependencyFactory unitSystemDependencyFactory,
            Action<IUnitRegistrar> registerUnitAction)
        {
            this.LockedAction(
                () =>
                    {
                        if (!this.isInitialized)
                        {
                            unitSystemDependencyFactory = unitSystemDependencyFactory
                                                          ?? new UnitSystemDependencyFactory(
                                                                 new ExpressionToFlatRepresentationConverter());
                            this.unitRegistry = unitSystemDependencyFactory.CreateUnitRegistry();
                            registerUnitAction?.Invoke(this.unitRegistry);
                            this.expressionParser = unitSystemDependencyFactory.CreateParser(this.unitRegistry);
                            this.lexicalAnalyzer =
                                unitSystemDependencyFactory.CreateLexicalAnalyzer(TokenMatching.CompositeUnit);
                            this.unitFactory = unitSystemDependencyFactory.CreateUnitFactory(this.unitRegistry);
                            this.quantityParser = unitSystemDependencyFactory.CreateParser(
                                this.expressionParser,
                                this.unitFactory);
                            this.quantityOperations =
                                unitSystemDependencyFactory.CreateQuantityOperations(this.unitFactory);
                            this.Dependencies = new UnitSystemDependencies(
                                this.unitRegistry,
                                this.lexicalAnalyzer,
                                this.expressionParser,
                                this.quantityParser,
                                this.unitFactory,
                                this.quantityOperations);
                            this.isInitialized = true;
                        }
                    });

            return this.Dependencies;
        }
Exemplo n.º 51
0
 public Report(string[] data, IRepository repository, IUnitFactory factory)
     : base(data, repository, factory)
 {
 }
Exemplo n.º 52
0
 public Barracks(IUnitFactory unitFactory, IResourceFactory resourceFactory)
     : base(ResourceType, ResourceProduceTime, resourceQuantity, UnitType, UnitProduceTime, unitFactory, resourceFactory)
 {
 }
Exemplo n.º 53
0
 public Fight(string[] data, IRepository repository, IUnitFactory unitFactory)
     : base(data, repository, unitFactory)
 {
 }
Exemplo n.º 54
0
 public Engine(IRepository repository, IUnitFactory unitFactory, ICommandInterpreter commandInterpreter)
 {
     this.repository         = repository;
     this.unitFactory        = unitFactory;
     this.commandInterpreter = commandInterpreter;
 }
 public Barrack(IResourceFactory resourceFactory, IUnitFactory unitFactory) 
     : base(resourceFactory, unitFactory)
 {
     
 }
Exemplo n.º 56
0
 public Engine(IRepository repository, IUnitFactory unitFactory)
 {
     this.repository  = repository;
     this.unitFactory = unitFactory;
 }
Exemplo n.º 57
0
 public ReportCommand(string[] data, IRepository repository, IUnitFactory unitFactory)
     : base(data, repository, unitFactory)
 {
 }
Exemplo n.º 58
0
 public AddCommand(string[] data, IRepository repository, IUnitFactory unitFactory)
     : base(data)
 {
     this.repository  = repository;
     this.unitFactory = unitFactory;
 }
Exemplo n.º 59
0
        public IExecutable CreateCommand(string commandType, string[] data, IRepository repository, IUnitFactory unitFactory)
        {
            //var types = Assembly.GetExecutingAssembly().GetTypes();
            var type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(x => x.Name.ToLower() == commandType.ToLower());

            if (type == null)
            {
                throw new NotSupportedException($"Not supported Command type: {commandType}");
            }

            var instance = Activator.CreateInstance(type, new object[] { data });

            if (!(instance is IExecutable currentInstance))
            {
                throw new NotSupportedException($"Incorrect Command type: {commandType}");
            }

            var injectFields = instance
                               .GetType()
                               .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                               .Where(x => x.IsDefined(typeof(InjectAttribute), false))
                               .ToArray();

            foreach (var field in injectFields)
            {
                var fieldType = field.FieldType;

                if (fieldType == typeof(IRepository))
                {
                    field.SetValue(instance, repository);
                    continue;
                }

                if (fieldType == typeof(IUnitFactory))
                {
                    field.SetValue(instance, unitFactory);
                    continue;
                }
            }

            return(currentInstance);
        }
Exemplo n.º 60
0
 public FightCommand(string[] data, IRepository r, IUnitFactory uF) : base(data)
 {
 }