本文整理汇总了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);
}
示例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;
}
示例3: DrawSceneGUI
public void DrawSceneGUI(Data.IData data, GameObject context)
{
// edit the data
IDataInspector inspector = DataInspector.Get(data.GetType());
inspector.OnSceneGUI(data, context);
}
示例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);
}
示例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());
}
示例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();
}