private type_generationGenerateentityCustomfindmethod CreateFindByMethod(string pDef)
        {
            //create new entry
            type_generationGenerateentityCustomfindmethod m = new type_generationGenerateentityCustomfindmethod();

            //get the single tokens
            string[] astrTokens = pDef.Split(',');
            for (int intIndex = 0; intIndex < astrTokens.Length; intIndex++)
            {
                astrTokens[intIndex] = astrTokens[intIndex].Replace("%%;%%", ",");
            }

            //first token is the method name
            m.name = astrTokens[0];

            //get the attributes to filter the query
            ArrayList alAttr   = new ArrayList();
            int       intCount = 1;

            while (intCount < astrTokens.Length)
            {
                if (astrTokens[intCount].Equals("1") || astrTokens[intCount].Equals("0"))
                {
                    //Digits found, stop loop
                    break;
                }
                type_generationGenerateentityCustomfindmethodMethodattribute attr = new type_generationGenerateentityCustomfindmethodMethodattribute();
                attr.name = astrTokens[intCount];

                alAttr.Add(attr);
                intCount++;
            }

            //Set the found attributes
            m.methodattribute = (type_generationGenerateentityCustomfindmethodMethodattribute[])
                                alAttr.ToArray(typeof(type_generationGenerateentityCustomfindmethodMethodattribute));

            m.returnsmultiple   = astrTokens[intCount++].Equals("1");
            m.generatetest      = astrTokens[intCount++].Equals("1");
            m.whereexpression   = astrTokens[intCount++];
            m.orderbyexpression = astrTokens[intCount++];
            m.description       = astrTokens[intCount + 2];

            return(m);
        }
        private void cmdAttrAddCustom_Click(object sender, System.EventArgs e)
        {
            fdlgCustomFindMethod_CustomAttribute dlg = new fdlgCustomFindMethod_CustomAttribute();

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                type_generationGenerateentityCustomfindmethodMethodattribute attr = new type_generationGenerateentityCustomfindmethodMethodattribute();
                attr.name          = dlg.AttributeName;
                attr.type          = dlg.AttributeType;
                attr.typeSpecified = true;
                attr.entityalias   = dlg.EntityAlias;
                malSelected.Add(attr);
                LoadAttributes();

                if (this.AttributeAdded != null)
                {
                    this.AttributeAdded(this, new AttributeEventArgs(((attr.entityalias != null) ? attr.entityalias + "." : "") + attr.name));
                }
            }
        }
        public void Initialize()
        {
            malAll = new ArrayList();
            foreach (XmlNode node in mDbDefinitionDocument.SelectNodes("/db-definition/entities/entity[@name='" + mEntity + "']/attributes/attribute"))
            {
                if (mCustomCreateMethod != null)
                {
                    type_generationGenerateentityCustomcreatemethodMethodattribute attr = new type_generationGenerateentityCustomcreatemethodMethodattribute();
                    attr.name = node.Attributes["name"].Value;
                    malAll.Add(attr);
                }
                else if (mCustomFindMethod != null)
                {
                    type_generationGenerateentityCustomfindmethodMethodattribute attr = new type_generationGenerateentityCustomfindmethodMethodattribute();
                    attr.name = node.Attributes["name"].Value;
                    malAll.Add(attr);
                }
            }

            malSelected = new ArrayList();
            if (mCustomCreateMethod != null && mCustomCreateMethod.methodattribute != null)
            {
                foreach (type_generationGenerateentityCustomcreatemethodMethodattribute attr in mCustomCreateMethod.methodattribute)
                {
                    foreach (type_generationGenerateentityCustomcreatemethodMethodattribute attr2 in malAll)
                    {
                        if (attr.name.Equals(attr2.name))
                        {
                            malSelected.Add(attr2);
                            break;
                        }
                    }
                }
            }
            else if (mCustomFindMethod != null && mCustomFindMethod.methodattribute != null)
            {
                foreach (type_generationGenerateentityCustomfindmethodMethodattribute attr in mCustomFindMethod.methodattribute)
                {
                    bool fFound = false;
                    foreach (type_generationGenerateentityCustomfindmethodMethodattribute attr2 in malAll)
                    {
                        if (attr.name.Equals(attr2.name))
                        {
                            malSelected.Add(attr2);
                            fFound = true;
                            break;
                        }
                    }
                    if (!fFound && attr.typeSpecified)
                    {
                        type_generationGenerateentityCustomfindmethodMethodattribute attr2 = new type_generationGenerateentityCustomfindmethodMethodattribute();
                        attr2.name          = attr.name;
                        attr2.type          = attr.type;
                        attr2.typeSpecified = true;
                        attr2.entityalias   = attr.entityalias;
                        malSelected.Add(attr2);
                    }
                }
            }

            LoadAttributes();
        }