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


C# Record.GetType方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:buskovic,项目名称:cobas,代码行数:36,代码来源:Mapper.cs

示例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;
            }
        }
开发者ID:buskovic,项目名称:cobas,代码行数:39,代码来源:Mapper.cs

示例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;
            }
        }
开发者ID:buskovic,项目名称:cobas,代码行数:46,代码来源:Mapper.cs


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