Beispiel #1
0
        public mytemplate(mytable table)
        {
            XmlDocument cols = new XmlDocument();

            cols.LoadXml(table.xml_column);
            XmlDocument keys = new XmlDocument();

            keys.LoadXml(table.xml_index);

            XmlNodeList colNodes = cols.SelectNodes("/Root/Data");
            XmlNodeList keyNodes = keys.SelectNodes("/Root/Data");

            vclass      = new myvariable("<class>", table.xml_class);
            vclassname  = new myvariable("<classname>", table.xml_class.ToLower());
            vshortclass = new myvariable("<shortclass>", table.xml_class.Substring(3));
            foreach (XmlNode node in colNodes)
            {
                vbase.Add(new myvariable(node));
            }

            foreach (XmlNode node in keyNodes)
            {
                vconstprimary.Add(new myvariable(node, colNodes));
            }
        }
Beispiel #2
0
        public string vreplace(string target, string tmp, myvariable myvar)
        {
            string rtn = target;

            switch (tmp)
            {
            case "<variabletype>":
                rtn = target.Replace(tmp, myvar.VType);
                break;

            case "<privatevariable>":
                rtn = target.Replace(tmp, myvar.VPrivate);
                break;

            case "<publicvariable>":
                rtn = target.Replace(tmp, myvar.VPublic);
                break;

            case "<getxml>":
                rtn = target.Replace(tmp, myvar.VGetXml);
                break;

            default:
                rtn = "ERROR";
                break;
            }
            return(rtn);
        }
Beispiel #3
0
        private void BuildKeyCompare(StringBuilder sb, string line, mytemplate t)
        {
            string newline = "";

            newline = line.Replace(t.vstaticfieldequals, "public bool KeyEquals(" + t.vclass.VBase + " a)");
            sb.AppendLine(newline);
            newline = line.Replace(t.vstaticfieldequals, "{");
            sb.AppendLine(newline);
            newline = line.Replace(t.vstaticfieldequals, "\tif ((object)a == null)");
            sb.AppendLine(newline);
            newline = line.Replace(t.vstaticfieldequals, "\t\treturn false;");
            sb.AppendLine(newline);
            newline = line.Replace(t.vstaticfieldequals, "\treturn (");
            sb.AppendLine(newline);
            for (int i = 0; i < t.vconstprimary.Count; i++)
            {
                string amp = " &&";
                if (i == t.vconstprimary.Count - 1)
                {
                    amp = "";
                }
                myvariable variable = t.vconstprimary[i];
                if (variable.VType == "string")
                {
                    newline = line.Replace(t.vstaticfieldequals, "\t(a." + variable.VPublic + ".Trim().ToLower() == " + variable.VPublic + ".Trim().ToLower())" + amp);
                    sb.AppendLine(newline);
                }
                else
                {
                    newline = line.Replace(t.vstaticfieldequals, "\t(a." + variable.VPublic + " == " + variable.VPublic + ")" + amp);
                    sb.AppendLine(newline);
                }
            }
            newline = line.Replace(t.vstaticfieldequals, "\t);");
            sb.AppendLine(newline);
            newline = line.Replace(t.vstaticfieldequals, "}");
            sb.AppendLine(newline);
        }