public void generate_code(StreamWriter sw, node_info ni, HelpStorage hst) { string txt = "public "+method_text; var ss = txt.Split(new string[]{Environment.NewLine}, StringSplitOptions.None); txt = string.Join(Environment.NewLine + text_consts.tab + text_consts.tab, ss); sw.WriteLine(text_consts.tab + text_consts.tab + txt); // sw.WriteLine(); }
public void generate_code_property(StreamWriter sw,node_info ni,HelpStorage hst) { string prop=text_consts.create_property(field_type_name,property_name,field_code_name, hst.get_help_context(ni.node_name+"."+field_name).help_context); //sw.WriteLine(); sw.WriteLine(prop); //sw.WriteLine(); }
public static HelpStorage deserialize(string file_name) { HelpStorage hc; BinaryFormatter formatter=new BinaryFormatter(); FileStream fs; if (!File.Exists(file_name)) { fs=File.Create(file_name); hc=new HelpStorage(); formatter.Serialize(fs,hc); fs.Flush(); fs.Close(); return hc; } fs=File.Open(file_name,FileMode.Open); hc=(HelpStorage)formatter.Deserialize(fs); fs.Close(); return hc; }
public void generate_to_text(StreamWriter sw,HelpStorage hst) { if (this.base_class!=null) sw.WriteLine(this.node_name+"->"+this.base_class.node_name); else sw.WriteLine(this.node_name); foreach(node_field_info nfi in _subnodes) { sw.WriteLine(text_consts.tab+nfi.field_type_name+" "+nfi.field_name); } /* string resize_part= text_consts.tab2+"if ("+this.node_name+"_size<="+this.node_name+"_count)"+text_consts.nr+ text_consts.tab2+"{"+text_consts.nr+ text_consts.tab2+this.node_name+"_size*=2;"+text_consts.nr+ text_consts.tab2+this.node_name+"[] "+this.node_name+"_arrayold="+this.node_name+"_array;"+text_consts.nr+ text_consts.tab2+this.node_name+"_array=new "+this.node_name+"["+this.node_name+"_size];"+text_consts.nr+ text_consts.tab2+this.node_name+"_arrayold.CopyTo("+this.node_name+"_array,0);"+text_consts.nr+ text_consts.tab2+"for (int i="+this.node_name+"_count;i<"+this.node_name+"_size;i++) "+this.node_name+"_array[i]=new "+this.node_name+"();"+text_consts.nr+ text_consts.tab2+"}"; sw.WriteLine(text_consts.tab2+this.node_name+"_count++"+text_consts.semicolon); sw.WriteLine(resize_part); string elem=this.node_name+"_array["+this.node_name+"_count-1]"; string reset_elem=""; for(int i=0;i<_subnodes.Count;i++) { if (!(_subnodes[i] is simple_element)) reset_elem+=text_consts.tab2+elem+"."+((node_field_info)_subnodes[i]).field_name+"=null;"+text_consts.nr; if (_subnodes[i] is extended_simple_element) if (((extended_simple_element)_subnodes[i]).field_type_name.IndexOf("ArrayList")>=0) reset_elem+=text_consts.tab2+elem+"."+((node_field_info)_subnodes[i]).field_name+".Clear();"+text_consts.nr; } if(reset_elem!="") { sw.WriteLine(reset_elem); } sw.WriteLine(text_consts.tab2+"return "+elem+";"); sw.WriteLine(text_consts.tab+text_consts.close_figure); sw.WriteLine(); if (_subnodes.Count>0) { //tn(...) sw.Write(text_consts.tab+text_consts.public_keyword+text_consts.space+ text_consts.space+ node_name+text_consts.space+text_consts.new_keyword+text_consts.underline+this.node_name+text_consts.open_par); for(int i=0;i<_subnodes.Count-1;i++) sw.Write(subnode_variable(i)+text_consts.comma); if (_subnodes.Count>0) sw.Write(subnode_variable(_subnodes.Count-1)); sw.WriteLine(text_consts.close_par); sw.WriteLine(text_consts.tab+text_consts.open_figure); sw.WriteLine(text_consts.tab2+this.node_name+"_count++"+text_consts.semicolon); sw.WriteLine(resize_part); reset_elem=""; for(int i=0;i<_subnodes.Count;i++) { if (_subnodes[i] is extended_simple_element) if (((extended_simple_element)_subnodes[i]).field_type_name.IndexOf("ArrayList")>=0) reset_elem+=text_consts.tab2+elem+"."+((node_field_info)_subnodes[i]).field_name+".Clear();"+text_consts.nr; } if(reset_elem!="") { sw.WriteLine(reset_elem); } for(int i=0;i<_subnodes.Count;i++) sw.WriteLine(text_consts.tab2+elem+"."+((node_field_info)_subnodes[i]).field_name+"="+((node_field_info)_subnodes[i]).field_code_name+text_consts.semicolon); sw.WriteLine(text_consts.tab2+"return "+elem+";"); sw.WriteLine(text_consts.tab+text_consts.close_figure); } */ sw.WriteLine(); }
//\ssyy public void generate_code(StreamWriter sw,HelpStorage hst) { //sw.WriteLine(); string temp=""; if (hst.get_help_context(this.node_name)!=null) { sw.WriteLine(@" ///<summary>"); sw.WriteLine(@" ///"+hst.get_help_context(this.node_name).help_context); sw.WriteLine(@" ///</summary>"); } sw.WriteLine(" [Serializable]"); if (base_class!=null) { temp=text_consts.space+text_consts.colon+text_consts.space+base_class.node_name; } sw.WriteLine(text_consts.tab+text_consts.public_keyword+text_consts.space+text_consts.class_keyword+text_consts.space+ node_name+temp); sw.WriteLine(text_consts.tab+text_consts.open_figure); //sw.WriteLine(); generate_simple_constructor_code(sw); //sw.WriteLine(); if (_subnodes.Count>0) { generate_big_constructor_code(sw, false); sw.WriteLine(); generate_big_constructor_code(sw, true); } if (CountNodesInBaseClasses() > 0) { sw.WriteLine(); generate_big_constructor_code(sw, false, true); sw.WriteLine(); generate_big_constructor_code(sw, true, true); } sw.WriteLine(); foreach (node_field_info nfi in _subnodes) { nfi.generate_field_code(sw); } if (_subnodes.Count > 0) sw.WriteLine(); foreach(node_field_info nfi in _subnodes) { nfi.generate_code_property(sw,this,hst); } if (_subnodes.Count>0) sw.WriteLine(); foreach (method_info mi in _methods) { mi.generate_code(sw, this, hst); } if (_methods.Count > 0) sw.WriteLine(); generate_visitor_node(sw); sw.WriteLine(); sw.WriteLine(text_consts.tab+text_consts.close_figure); sw.WriteLine(); sw.WriteLine(); }
//\ssyy //ssyy public void generate_cpp_code(StreamWriter sw_h, StreamWriter sw_cpp, HelpStorage hst) { sw_h.WriteLine(); string temp = ""; if (hst.get_help_context(this.node_name) != null) { sw_h.WriteLine(@" ///<summary>"); sw_h.WriteLine(@" ///" + hst.get_help_context(this.node_name).help_context); sw_h.WriteLine(@" ///</summary>"); if (base_class != null) { temp = text_consts.space + text_consts.colon + text_consts.space + text_consts.public_keyword + text_consts.space + base_class.node_name; } sw_h.WriteLine(text_consts.tab + text_consts.class_keyword + text_consts.space + node_name + temp); sw_h.WriteLine(text_consts.tab + text_consts.open_figure); sw_h.WriteLine(text_consts.tab + text_consts.public_keyword + text_consts.colon); List<string> destructor_code = new List<string>(); foreach (node_field_info nfi in _subnodes) { nfi.generate_cpp_field_code(sw_h, destructor_code); } if (destructor_code.Count > 0) { sw_h.WriteLine(); sw_h.WriteLine(text_consts.tab2 + text_consts.tilde + node_name + text_consts.open_par + text_consts.close_par + text_consts.semicolon); sw_cpp.WriteLine(); sw_cpp.WriteLine(text_consts.tab + node_name + text_consts.colon2 + text_consts.tilde + node_name + text_consts.open_par + text_consts.close_par); sw_cpp.WriteLine(text_consts.tab + text_consts.open_figure); foreach (string s in destructor_code) { sw_cpp.WriteLine(s); } sw_cpp.WriteLine(text_consts.tab + text_consts.close_figure); } generate_visitor_node_cpp(sw_h); sw_h.WriteLine(text_consts.tab + text_consts.close_figure + text_consts.semicolon); sw_h.WriteLine(); } }