/// <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); }
/// <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>(); }
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()); }
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()); }
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()); }
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); }