本文整理汇总了C#中Record.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Record.GetType方法的具体用法?C# Record.GetType怎么用?C# Record.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRecordItemName
/// <summary>
/// Dohvaca ime itema unutar Record-a
/// </summary>
/// <param name="record"></param>
/// <param name="position"></param>
/// <returns></returns>
private static string GetRecordItemName(Record record, int position)
{
log.Debug("Mapper:GetRecordItemName");
try
{
PropertyInfo[] props = record.GetType().GetProperties();
foreach (PropertyInfo prop in props)
{
object[] attrs = prop.GetCustomAttributes(true);
foreach (object attr in attrs)
{
FieldAttribute fieldAttr = attr as FieldAttribute;
if (fieldAttr != null)
{
if (fieldAttr as FieldSubtypeAttribute == null)
if (fieldAttr.Position == position)
return fieldAttr.Name;
}
}
}
return null;
}
catch (Exception ex)
{
log.Error(ex.ToString());
throw;
}
}
示例2: SetRecordItem
/// <summary>
/// Setira item unutar Record-a
/// </summary>
/// <param name="record"></param>
/// <param name="value"></param>
/// <param name="position"></param>
private static void SetRecordItem(Record record, string value, int position)
{
log.Debug("Mapper:SetRecordItem");
try
{
PropertyInfo[] props = record.GetType().GetProperties();
foreach (PropertyInfo prop in props)
{
object[] attrs = prop.GetCustomAttributes(true);
foreach (object attr in attrs)
{
FieldAttribute fieldAttr = attr as FieldAttribute;
if (fieldAttr != null)
{
if (fieldAttr as FieldSubtypeAttribute == null)
if (fieldAttr.Position == position)
{
object instance = Activator.CreateInstance(Type.GetType("astm.protocol.record." + fieldAttr.Type));
((Field)instance).SetValue(value);
record.GetType().GetProperty(fieldAttr.Name).SetValue(record, (Field)instance, null);
return;
}
}
}
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
throw;
}
}
示例3: CreateSubItems
/// <summary>
/// Kreira subitem
/// </summary>
/// <param name="record"></param>
/// <param name="cm"></param>
/// <param name="position"></param>
/// <param name="count"></param>
private static void CreateSubItems(Record record, Cm cm, int position, int count)
{
log.Debug("Mapper:CreateSubItems");
try
{
PropertyInfo[] props = record.GetType().GetProperties();
for (int i = 0; i < count; i++)
{
cm.Value.Add(new Cm());
cm.Empty = false;
cm.Delimiter = "/";
foreach (PropertyInfo prop in props)
{
object[] attrs = prop.GetCustomAttributes(true);
object[] sorted = attrs.OrderBy(a => ((FieldAttribute)a).Position).ToArray();
foreach (object attr in sorted)
{
FieldSubtypeAttribute subtypeAttr = attr as FieldSubtypeAttribute;
if (subtypeAttr != null)
{
if (subtypeAttr.Parent.Equals(GetRecordItemName(record, position)))
{
//TODO: namespace hardkodiran!!!
object instance = Activator.CreateInstance(Type.GetType("astm.protocol.record." + subtypeAttr.Type));
((Cm)cm.Value[i]).Value.Add((Field)instance);
}
}
}
}
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
throw;
}
}