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


C# ModelObject.MIsDefault方法代码示例

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


在下文中一共展示了ModelObject.MIsDefault方法的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];
//.........这里部分代码省略.........
开发者ID:Bubesz,项目名称:meta-cs,代码行数:101,代码来源:ModelExchange.cs


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