Exemplo n.º 1
0
        /// <summary>
        /// Gets commands from the discovered command bundles.
        /// </summary>
        /// <param name="et"></param>
        /// <returns></returns>
        public static CommandCollection GetCommandsFromCommandBundles(EntityType et)
        {
            if (et == null)
            {
                throw new ArgumentNullException("et");
            }

            // finder...
            TypeFinder finder = new TypeFinder(typeof(CommandBundle));

            finder.AddAttributeSpecification(typeof(CommandBundleAttribute), false, "Type", et.Type);

            // create...
            CommandBundle[] bundles = (CommandBundle[])finder.CreateInstances();
            if (bundles == null)
            {
                throw new InvalidOperationException("bundles is null.");
            }

            // walk...
            CommandCollection all = new CommandCollection();

            foreach (CommandBundle bundle in bundles)
            {
                all.AddRange(bundle.GetAllCommands());
            }

            // return...
            return(all);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Создание экземпляров классов
 /// слоя Model шаблона MVP.
 /// </summary>
 void InitCanvasModelLayer()
 {
     painter                      = new Painter(viewMainForm.GetPictureBoxWidth, viewMainForm.GetPictureBoxHeight);
     colorsInstanceList           = new ColorsInstanceList();
     figureInstanceList           = new FigureInstanceList();
     figureInstanceList.Instances = TypeFinder.CreateInstances <IFigure>();
     colorsInstanceList.Instances = TypeFinder.CreateInstances <IColor>();
 }
Exemplo n.º 3
0
        public void CreateInstance_PassIFigureType_ListReturnSuccess()
        {
            //Arrange
            FigureInstanceList figureInstanceList = new FigureInstanceList();
            List <IFigure>     expected;

            //Act
            figureInstanceList.Instances = TypeFinder.CreateInstances <IFigure>();
            expected = figureInstanceList.Instances;
            //Assert
            Assert.AreEqual(typeof(List <IFigure>), expected.GetType());
        }
Exemplo n.º 4
0
        public void CreateInstance_PassIColorType_ListReturnSuccess()
        {
            //Arrange
            ColorsInstanceList colorsInstanceList = new ColorsInstanceList();
            List <IColor>      expected;

            //Act
            colorsInstanceList.Instances = TypeFinder.CreateInstances <IColor>();
            expected = colorsInstanceList.Instances;
            //Assert
            Assert.AreEqual(typeof(List <IColor>), expected.GetType());
        }
Exemplo n.º 5
0
        public void GetNames_PassIColor_ReturnCorrectType()
        {
            //Arrange
            ColorsInstanceList colorsInstanceList = new ColorsInstanceList();
            List <string>      expected;

            //Act
            colorsInstanceList.Instances = TypeFinder.CreateInstances <IColor>();

            expected = TypeFinder.GetNames <IColor>(colorsInstanceList.Instances);
            //Assert
            Assert.AreEqual(typeof(List <string>), expected.GetType());
        }
Exemplo n.º 6
0
        public void GetNames_PassIColor_ReturnCorrectListElement()
        {
            //Arrange
            ColorsInstanceList colorsInstanceList = new ColorsInstanceList();
            List <string>      expected;

            //Act
            colorsInstanceList.Instances = TypeFinder.CreateInstances <IColor>();
            expected = TypeFinder.GetNames <IColor>(colorsInstanceList.Instances);

            //Assert
            Assert.IsTrue(expected.Contains("Red") == true);
            Assert.IsTrue(expected.Contains("Square") == false);
        }