当前位置: 首页>>代码示例>>C#>>正文


C# IGenerator.GetType方法代码示例

本文整理汇总了C#中IGenerator.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IGenerator.GetType方法的具体用法?C# IGenerator.GetType怎么用?C# IGenerator.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGenerator的用法示例。


在下文中一共展示了IGenerator.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

		private static void Configure(IGenerator generator, string[] args)
		{
			Type type = generator.GetType();

			object[] attrs = type.GetCustomAttributes(typeof(GeneratorOptionsAttribute), false);

			if (attrs.Length == 1)
			{
				GeneratorOptionsAttribute attr = (GeneratorOptionsAttribute) attrs[0];

				Type configurerType = typeof(GeneratorConfigurer<>).MakeGenericType(type);

				object configurer = Activator.CreateInstance(attr.OptionClass);

				MethodInfo method = configurerType.GetMethod("Configure", BindingFlags.Instance | BindingFlags.Public);

				method.Invoke(configurer, new object[] { generator, args });
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:19,代码来源:Program.cs

示例2: LoadGeneratorGUI

 private void LoadGeneratorGUI(IGenerator Generator)
 {
     if (Generator.GetType() == typeof(CharacterGenerator))
     {
         ucCharacterGenerator ucGenerator = new ucCharacterGenerator();
         ucGenerator.LoadGenerator((CharacterGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(CharacterRepeater))
     {
         ucCharacterRepeater ucGenerator = new ucCharacterRepeater();
         ucGenerator.LoadGenerator((CharacterRepeater)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(FileGenerator))
     {
         ucFileGenerator ucGenerator = new ucFileGenerator();
         ucGenerator.LoadGenerator((FileGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(NumberGenerator))
     {
         ucNumberGenerator ucGenerator = new ucNumberGenerator();
         ucGenerator.LoadGenerator((NumberGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(RandomStringGenerator))
     {
         ucRandomStringGenerator ucGenerator = new ucRandomStringGenerator();
         ucGenerator.LoadGenerator((RandomStringGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(StringGenerator))
     {
         ucStringGenerator ucGenerator = new ucStringGenerator();
         ucGenerator.LoadGenerator((StringGenerator)Generator);
         AddGenerator(ucGenerator);
     }
 }
开发者ID:mcorrientes,项目名称:Web-Security-Toolset,代码行数:39,代码来源:frmMain.cs

示例3: SaveModelFile

        //private static void CreateNewModelFile(string loadingFile)
        //{
        //  var nmf = new NewModelForm(loadingFile);
        //  if (string.IsNullOrEmpty(nmf.FileContent))
        //    nmf.ShowDialog();
        //  var fi = new FileInfo(loadingFile);
        //  using (var writer = fi.AppendText())
        //  {
        //    writer.Write(nmf.FileContent);
        //    writer.Close();
        //  }
        //}
        public static void SaveModelFile(IGenerator generatorProject, string fullFileName)
        {
            var att = (GeneratorAttribute)ReflectionHelper.GetSingleAttribute(typeof(GeneratorAttribute), generatorProject);

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(string.Format("<{0}></{0}>", ROOT_NODE));

            var xmlAttr = xmlDoc.CreateAttribute("guid");
            xmlAttr.Value = att.ProjectGuid.ToString();
            xmlDoc.DocumentElement.Attributes.Append(xmlAttr);

            var typeAttribute = xmlDoc.CreateAttribute("type");
            typeAttribute.Value = generatorProject.GetType().FullName;
            xmlDoc.DocumentElement.Attributes.Append(typeAttribute);

            var assemblyAttribute = xmlDoc.CreateAttribute("assembly");
            assemblyAttribute.Value = new FileInfo(generatorProject.GetType().Assembly.Location).Name;
            xmlDoc.DocumentElement.Attributes.Append(assemblyAttribute);

            generatorProject.XmlAppend(xmlDoc.DocumentElement);
            xmlDoc.Save(fullFileName);
        }
开发者ID:jradxl,项目名称:nHydrate-Designer-Only,代码行数:34,代码来源:GeneratorHelper.cs

示例4: BuildList

        private List<string> BuildList(IGenerator Generator, List<string> List)
        {
            List<string> OldList = List;
            List<string> NewList = new List<string>();

            for (int i = 0; i < OldList.Count; )
            {
                string OldValue = List[i];
                List.RemoveAt(i);

                if (Generator.GetType() == typeof(CharacterGenerator))
                {
                    CharacterGenerator characterGenerator = (CharacterGenerator)Generator;
                    NewList.AddRange(BuildCharacters(characterGenerator, OldValue));
                }
                else if (Generator.GetType() == typeof(CharacterRepeater))
                {
                    CharacterRepeater characterRepeater = (CharacterRepeater)Generator;
                    NewList.AddRange(BuildCharacterRepeats(characterRepeater, OldValue));
                }
                else if (Generator.GetType() == typeof(FileGenerator))
                {
                    FileGenerator fileGenerator = (FileGenerator)Generator;
                    NewList.AddRange(BuildFileString(fileGenerator, OldValue));
                }
                else if (Generator.GetType() == typeof(NumberGenerator))
                {
                    NumberGenerator numberGenerator = (NumberGenerator)Generator;
                    NewList.AddRange(BuildNumbers(numberGenerator, OldValue));
                }
                else if (Generator.GetType() == typeof(RandomStringGenerator))
                {
                    RandomStringGenerator randomStringGenerator = (RandomStringGenerator)Generator;
                    NewList.AddRange(BuildRandomStrings(randomStringGenerator, OldValue));
                }
                else if (Generator.GetType() == typeof(StringGenerator))
                {
                    StringGenerator stringGenerator = (StringGenerator)Generator;
                    NewList.AddRange(BuildStrings(stringGenerator, OldValue, ""));
                }
            }
            return NewList;
        }
开发者ID:mcorrientes,项目名称:Web-Security-Toolset,代码行数:43,代码来源:RequestGenerator.cs

示例5: Validate

 public bool Validate(IGenerator generator)
 {
     string name = GetName(generator.GetType());
     return !string.IsNullOrEmpty(name);
 }
开发者ID:BenHall,项目名称:ExtendViaMEF,代码行数:5,代码来源:GeneratorValidator.cs


注:本文中的IGenerator.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。