本文整理汇总了C#中Field.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Field.GetType方法的具体用法?C# Field.GetType怎么用?C# Field.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FieldTypeTest
public void FieldTypeTest()
{
var idField = new Field
{
Name = "Id"
};
var fieldType = idField.GetType<Person>();
Assert.AreEqual(fieldType, typeof (int));
}
示例2: CreateEntity
private Entity CreateEntity(XmlNode node, bool hasDeletedField = false, bool checkTabularSectionKey = false)
{
Entity entity = new Entity(null, hasDeletedField);
foreach (System.Xml.XmlAttribute a in node.Attributes)
{
System.Reflection.PropertyInfo pi = entity.GetType().GetProperty(a.Name);
pi.SetValue(entity, System.Convert.ChangeType(a.Value, pi.PropertyType), null);
}
XmlNodeList fieldNodes = node.SelectNodes("Fields/Field");
foreach (XmlNode fieldNode in fieldNodes)
{
Field field = new Field();
foreach (System.Xml.XmlAttribute a in fieldNode.Attributes)
{
System.Reflection.PropertyInfo pi = field.GetType().GetProperty(a.Name);
pi.SetValue(field, System.Convert.ChangeType(a.Value, pi.PropertyType), null);
}
entity.Fields.Add(field);
}
entity.SortFields();
XmlNodeList tabularSectionNodes = node.SelectNodes("TabularSections/TabularSection");
foreach (XmlNode tabularSectionNode in tabularSectionNodes)
{
TabularSection tabularSection = new TabularSection(entity);
foreach (System.Xml.XmlAttribute a in tabularSectionNode.Attributes)
{
System.Reflection.PropertyInfo pi = tabularSection.GetType().GetProperty(a.Name);
pi.SetValue(tabularSection, System.Convert.ChangeType(a.Value, pi.PropertyType), null);
}
XmlNodeList tabularSectionFieldNodes = tabularSectionNode.SelectNodes("Field");
foreach (XmlNode tabularSectionFieldNode in tabularSectionFieldNodes)
{
Field field = new Field();
foreach (System.Xml.XmlAttribute a in tabularSectionFieldNode.Attributes)
{
System.Reflection.PropertyInfo pi = field.GetType().GetProperty(a.Name);
pi.SetValue(field, System.Convert.ChangeType(a.Value, pi.PropertyType), null);
}
tabularSection.Fields.Add(field);
}
tabularSection.SortFields();
entity.TabularSections.Add(tabularSection);
}
entity.Validate(checkTabularSectionKey);
return entity;
}
示例3: CreateEmptyFieldObject
protected IStorageField CreateEmptyFieldObject(Field field)
{
var storageService = service.StorageService;
return storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType());
}