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); } } }
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(); }
bool IsListOfNodes(ModelClass ce) { var ce2 = GetListItemType(ce); return(ce2 != null && IsDerivedFromBaseNode(ce2)); }
bool IsList(ModelClass ce) { return(GetListItemType(ce) != null); }
IEnumerable <ModelClass> GetDerivedClasses(ModelClass ce) { return(Classes.Where(t => t.BaseClass == ce)); }
bool IsNodeLeaf(ModelClass ce) { return(GetDerivedClasses(ce).FirstOrDefault() == null); }
bool IsBaseNode(ModelClass type) { return(type == RootNodeType); }