本文整理汇总了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 });
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例5: Validate
public bool Validate(IGenerator generator)
{
string name = GetName(generator.GetType());
return !string.IsNullOrEmpty(name);
}