예제 #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);
 }