示例#1
0
 private void DoGenerateProperties(ModelClass ce)
 {
     foreach (var pe in ce.Properties)
     {
         if (SupportParent && pe.Name != "Parent" && (IsListOfNodes(pe.Type) || IsDerivedFromBaseNode(pe.Type)))
         {
             WriteLine("{0} _{1};", pe.Type.Name, pe.Name);
             if (IsListOfNodes(pe.Type))
             {
                 WriteLine("public {0} {1} {{ get {{ return _{1}; }} set {{ _{1}.SetItems(value);}} }}", pe.Type.Name, pe.Name);
             }
             else
             {
                 WriteLine("public {0} {1} {{ get {{ return _{1}; }} set {{ if(_{1}!=null) _{1}.Parent=null; _{1}= value;if(_{1}!=null) _{1}.Parent=this;}} }}", pe.Type.Name, pe.Name);
             }
         }
         else
         {
             WriteLine("public {0} {1} {{get;set;}}", pe.Type.Name, pe.Name);
         }
     }
 }
示例#2
0
 private void GenerateClass(ModelClass ce)
 {
     WriteLine("[DebuggerStepThrough]");
     Write("partial class {0}", ce.Name);
     if (ce.BaseClass != null)
     {
         Write(" : {0}", ce.BaseClass.Name);
     }
     WriteLine("");
     BeginBlock();
     if (GenerateProperties)
     {
         DoGenerateProperties(ce);
     }
     GenerateCtor(ce);
     if (GenerateLinq)
     {
         DoGenerateLinq(ce);
     }
     GenerateVisitorImpl(ce);
     EndBlock();
 }
示例#3
0
        bool IsListOfNodes(ModelClass ce)
        {
            var ce2 = GetListItemType(ce);

            return(ce2 != null && IsDerivedFromBaseNode(ce2));
        }
示例#4
0
 bool IsList(ModelClass ce)
 {
     return(GetListItemType(ce) != null);
 }
示例#5
0
 IEnumerable <ModelClass> GetDerivedClasses(ModelClass ce)
 {
     return(Classes.Where(t => t.BaseClass == ce));
 }
示例#6
0
 bool IsNodeLeaf(ModelClass ce)
 {
     return(GetDerivedClasses(ce).FirstOrDefault() == null);
 }
示例#7
0
 bool IsBaseNode(ModelClass type)
 {
     return(type == RootNodeType);
 }