本文整理汇总了C#中ModelObject.MGetProperties方法的典型用法代码示例。如果您正苦于以下问题:C# ModelObject.MGetProperties方法的具体用法?C# ModelObject.MGetProperties怎么用?C# ModelObject.MGetProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelObject
的用法示例。
在下文中一共展示了ModelObject.MGetProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToXmi
private static void SaveToXmi(XNamespace xmi, Dictionary<MetaModel, XNamespace> metaModels, Dictionary<MetaModel, string> prefixes, XElement elem, ModelObject mo)
{
if (!string.IsNullOrEmpty(mo.MetaID))
{
elem.Add(new XAttribute(xmi + "id", mo.MetaID));
}
foreach (var prop in mo.MGetProperties())
{
if (!prop.IsCollection && !prop.IsReadonly)
{
if (prop.Type.IsPrimitive || prop.Type.IsEnum || prop.Type.Equals(typeof(string)))
{
if (!mo.MIsDefault(prop))
{
object value = mo.MGet(prop);
if (value != null)
{
elem.Add(new XAttribute(prop.Name.ToCamelCase(), value));
}
else
{
elem.Add(new XAttribute(prop.Name.ToCamelCase(), string.Empty));
}
}
}
else
{
if (!mo.MIsDefault(prop))
{
object value = mo.MGet(prop);
ModelObject valueObject = value as ModelObject;
if (valueObject != null)
{
if (!prop.OppositeProperties.Any(p => p.IsContainment))
{
elem.Add(new XAttribute(prop.Name.ToCamelCase(), valueObject.MetaID));
}
}
else if (value != null)
{
elem.Add(new XAttribute(prop.Name.ToCamelCase(), value.ToString()));
}
else
{
elem.Add(new XAttribute(prop.Name.ToCamelCase(), string.Empty));
}
}
}
}
else if (prop.IsContainment)
{
if (prop.IsCollection)
{
ModelCollection children = mo.MGet(prop) as ModelCollection;
if (children != null)
{
foreach (var childObj in children)
{
ModelObject child = childObj as ModelObject;
if (child != null && child.MMetaClass != null && child.MMetaClass.Model != null)
{
string ns = prefixes[mo.MMetaClass.Model];
XElement childElem =
new XElement(
prop.Name.ToCamelCase(),
new XAttribute(xmi + "type", ns + ":" + child.MMetaClass.Name));
elem.Add(childElem);
ModelExchange.SaveToXmi(xmi, metaModels, prefixes, childElem, child);
}
}
}
}
else
{
ModelObject child = mo.MGet(prop) as ModelObject;
if (child != null && child.MMetaClass != null && child.MMetaClass.Model != null)
{
string ns = prefixes[mo.MMetaClass.Model];
XElement childElem =
new XElement(
prop.Name.ToCamelCase(),
new XAttribute(xmi + "type", ns + ":" + child.MMetaClass.Name));
elem.Add(childElem);
ModelExchange.SaveToXmi(xmi, metaModels, prefixes, childElem, child);
}
}
}
else
{
if (prop.IsCollection)
{
ModelCollection children = mo.MGet(prop) as ModelCollection;
if (children != null)
{
foreach (var childObj in children)
{
ModelObject child = childObj as ModelObject;
if (child != null && child.MMetaClass != null && child.MMetaClass.Model != null)
{
//XNamespace ns = metaModels[mo.MMetaClass.Model];
//.........这里部分代码省略.........