////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////

        // BuildProvider implementation

        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            Hashtable       properties  = ProfileBase.GetPropertiesForCompilation();
            CodeCompileUnit compileUnit = new CodeCompileUnit();
            Hashtable       groups      = new Hashtable();
            Type            baseType    = Type.GetType(ProfileBase.InheritsFromTypeString, false);

            // namespace ASP {
            //
            CodeNamespace ns = new CodeNamespace();

            // ns.Name = BaseCodeDomTreeGenerator.defaultNamespace;

            //GEN: using System;
            ns.Imports.Add(new CodeNamespaceImport("System"));
            //GEN: using System.Web;
            ns.Imports.Add(new CodeNamespaceImport("System.Web"));
            //GEN: using System.Web.Profile;
            ns.Imports.Add(new CodeNamespaceImport("System.Web.Profile"));

            // class Profile :  System.Web.Security.ProfileBase {
            //
            CodeTypeDeclaration type = new CodeTypeDeclaration();

            type.Name = ProfileTypeName;
            if (baseType != null)
            {
                type.BaseTypes.Add(new CodeTypeReference(baseType));
                assemblyBuilder.AddAssemblyReference(baseType.Assembly, compileUnit);
            }
            else
            {
                type.BaseTypes.Add(new CodeTypeReference(ProfileBase.InheritsFromTypeString));
                ProfileSection config = MTConfigUtil.GetProfileAppConfig();
                if (config != null)
                {
                    PropertyInformation prop = config.ElementInformation.Properties["inherits"];
                    if (prop != null && prop.Source != null && prop.LineNumber > 0)
                    {
                        type.LinePragma = new CodeLinePragma(HttpRuntime.GetSafePath(prop.Source), prop.LineNumber);
                    }
                }
            }
            // tell the assemblyBuilder to generate a fast factory for this type
            assemblyBuilder.GenerateTypeFactory(/*ns.Name + "." + */ ProfileTypeName);

            foreach (DictionaryEntry de in properties)
            {
                ProfileNameTypeStruct property = (ProfileNameTypeStruct)de.Value;
                if (property.PropertyType != null)
                {
                    assemblyBuilder.AddAssemblyReference(property.PropertyType.Assembly, compileUnit);
                }
                int pos = property.Name.IndexOf('.');
                if (pos < 0)
                {
                    // public string Color { get { return (string) GetProperty("Color"); } set { SetProperty("Color", value); } }
                    CreateCodeForProperty(assemblyBuilder, type, property);
                }
                else
                {
                    string grpName = property.Name.Substring(0, pos);
                    if (!assemblyBuilder.CodeDomProvider.IsValidIdentifier(grpName))
                    {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Profile_bad_group, grpName), property.FileName, property.LineNumber);
                    }
                    if (groups[grpName] == null)
                    {
                        groups.Add(grpName, property.Name);
                    }
                    else
                    {
                        groups[grpName] = ((string)groups[grpName]) + ";" + property.Name;
                    }
                }
            }

            foreach (DictionaryEntry de in groups)
            {
                // public ProfileGroupFooClass Foo { get { return ProfileGroupSomething; }}
                //
                // public class ProfileGroupFoo : ProfileGroup {
                //      Properties
                // }
                AddPropertyGroup(assemblyBuilder, (string)de.Key, (string)de.Value, properties, type, ns);
            }


            // public ASP.Profile GetProfileForUser(string username) {
            //      return (ASP.Profile) this.GetUserProfile(username);
            // }
            AddCodeForGetProfileForUser(type);

            // }
            //
            ns.Types.Add(type);
            compileUnit.Namespaces.Add(ns);

            assemblyBuilder.AddCodeCompileUnit(this, compileUnit);
        }
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            Hashtable       propertiesForCompilation = ProfileBase.GetPropertiesForCompilation();
            CodeCompileUnit ccu        = new CodeCompileUnit();
            Hashtable       hashtable2 = new Hashtable();
            Type            type       = Type.GetType(ProfileBase.InheritsFromTypeString, false);
            CodeNamespace   ns         = new CodeNamespace();

            ns.Imports.Add(new CodeNamespaceImport("System"));
            ns.Imports.Add(new CodeNamespaceImport("System.Web"));
            ns.Imports.Add(new CodeNamespaceImport("System.Web.Profile"));
            CodeTypeDeclaration declaration = new CodeTypeDeclaration {
                Name = "ProfileCommon"
            };

            if (type != null)
            {
                declaration.BaseTypes.Add(new CodeTypeReference(type));
                assemblyBuilder.AddAssemblyReference(type.Assembly, ccu);
            }
            else
            {
                declaration.BaseTypes.Add(new CodeTypeReference(ProfileBase.InheritsFromTypeString));
                ProfileSection profileAppConfig = MTConfigUtil.GetProfileAppConfig();
                if (profileAppConfig != null)
                {
                    PropertyInformation information = profileAppConfig.ElementInformation.Properties["inherits"];
                    if (((information != null) && (information.Source != null)) && (information.LineNumber > 0))
                    {
                        declaration.LinePragma = new CodeLinePragma(HttpRuntime.GetSafePath(information.Source), information.LineNumber);
                    }
                }
            }
            assemblyBuilder.GenerateTypeFactory("ProfileCommon");
            foreach (DictionaryEntry entry in propertiesForCompilation)
            {
                ProfileNameTypeStruct property = (ProfileNameTypeStruct)entry.Value;
                if (property.PropertyType != null)
                {
                    assemblyBuilder.AddAssemblyReference(property.PropertyType.Assembly, ccu);
                }
                int index = property.Name.IndexOf('.');
                if (index < 0)
                {
                    this.CreateCodeForProperty(assemblyBuilder, declaration, property);
                }
                else
                {
                    string str = property.Name.Substring(0, index);
                    if (!assemblyBuilder.CodeDomProvider.IsValidIdentifier(str))
                    {
                        throw new ConfigurationErrorsException(System.Web.SR.GetString("Profile_bad_group", new object[] { str }), property.FileName, property.LineNumber);
                    }
                    if (hashtable2[str] == null)
                    {
                        hashtable2.Add(str, property.Name);
                    }
                    else
                    {
                        hashtable2[str] = ((string)hashtable2[str]) + ";" + property.Name;
                    }
                }
            }
            foreach (DictionaryEntry entry2 in hashtable2)
            {
                this.AddPropertyGroup(assemblyBuilder, (string)entry2.Key, (string)entry2.Value, propertiesForCompilation, declaration, ns);
            }
            this.AddCodeForGetProfileForUser(declaration);
            ns.Types.Add(declaration);
            ccu.Namespaces.Add(ns);
            assemblyBuilder.AddCodeCompileUnit(this, ccu);
        }