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


C# Data.GetType方法代码示例

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


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

示例1: GetShow

        public XDocument GetShow(int showID)
        {
            var showData = _data.GetShowData();
            var episodeData = _data.GetEpisodeData();
            var show = new Data {TestShow = new TestShow()};

            // Dynamically create the show object
            foreach (var key in showData.Keys)
            {
                var prop = show.TestShow.GetType().GetProperty(key.XmlValue);
                prop.SetValue(show.TestShow, showData[key].XmlValue, null);
            }

            // Add episodes to the show object
            show.TestShow.Episodes = new List<TestEpisode>();
            foreach (var ep in episodeData)
            {
                var newEpisode = new TestEpisode();

                foreach (var key in ep.Keys)
                {
                    var prop = newEpisode.GetType().GetProperty(key.XmlValue);
                    prop.SetValue(newEpisode, ep[key].XmlValue, null);
                }

                show.TestShow.Episodes.Add(newEpisode);
            }

            // Pull the created object trough an XML serializer
            var serializer = new XmlSerializer(show.GetType());
            string xml;

            using (var writer = new StringWriter())
            {
                serializer.Serialize(writer, show);
                xml = writer.ToString();
            }

            return XDocument.Parse(xml);
        }
开发者ID:Rigby93,项目名称:TVDBSharp,代码行数:40,代码来源:TestDataProvider.cs

示例2: ParseToDataTable

        public static DataTable ParseToDataTable(Data.Pemeriksaan theObject)
        {
            DataTable dat = new DataTable();

            Data.Pemeriksaan datos = new Data.Pemeriksaan();

            foreach (PropertyInfo info in typeof(Data.Pemeriksaan).GetProperties())
            {
                if (info.PropertyType != typeof(string)
                     && info.PropertyType.GetInterface(typeof(IEnumerable).Name) != null
                     && info.PropertyType.GetInterface(typeof(IEnumerable<>).Name) != null)
                {
                    continue;
                }

                dat.Columns.Add(info.Name, info.PropertyType);
            }

            dat.AcceptChanges();

            DataRow row = dat.NewRow();
              datos = theObject;

              foreach (var info in datos.GetType().GetProperties())
            {

                if (info.PropertyType != typeof(string)
            && info.PropertyType.GetInterface(typeof(IEnumerable).Name) != null
            && info.PropertyType.GetInterface(typeof(IEnumerable<>).Name) != null)
                {
                    continue;
                }
                row[info.Name] = info.GetValue(datos, null);

            }

            dat.Rows.Add(row);
            dat.AcceptChanges();
            return dat;
        }
开发者ID:safaintegrated,项目名称:asm,代码行数:40,代码来源:Converter.cs

示例3: DrawSceneGUI

 public void DrawSceneGUI(Data.IData data, GameObject context)
 {
     // edit the data
     IDataInspector inspector = DataInspector.Get(data.GetType());
     inspector.OnSceneGUI(data, context);
 }
开发者ID:jacobdufault,项目名称:forge-unity,代码行数:6,代码来源:DataWindow.cs

示例4: OnSerializing

        /// <summary>
        /// Called when the object is about to be serialized.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="model">The model.</param>
        public override void OnSerializing(ISerializationContext context, Data.IModel model)
        {
            _serializationManager.Clear(model.GetType());

            base.OnSerializing(context, model);
        }
开发者ID:jensweller,项目名称:Catel,代码行数:11,代码来源:DynamicConfigurationSerializerModifier.cs

示例5: GetId

 /// <summary>
 /// Returns the id for the given data type. Forwards the call to GetId(Type).
 /// </summary>
 public static int GetId(Data.IData data) {
     return GetId(data.GetType());
 }
开发者ID:jyunfan2015,项目名称:forge,代码行数:6,代码来源:DataAccessor.cs

示例6: InitStats

        public CreatureBaseStats InitStats(Data.Structures.Creature.Creature creature)
        {
            Player player = creature as Player;
            if (player != null)
                return GetBaseStats(player).Clone();

            Npc npc = creature as Npc;
            if (npc != null)
                return GetNpcStats(npc);

            Log.Error("StatsService: Unknown type: {0}.", creature.GetType().Name);
            return new CreatureBaseStats();
        }
开发者ID:mMellowz,项目名称:revcore,代码行数:13,代码来源:StatsService.cs


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