// FIXME: there should be some validation of syntactic correctness of the member/class name // for the groups/properties. For now it's left to the compiler to report errors. // // CodeGenerator.IsValidLanguageIndependentIdentifier (id) - use that // bool ProcessCustomProfile(ProfileSection ps, AppCodeAssembly defasm) { CodeCompileUnit unit = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(null); unit.Namespaces.Add(ns); defasm.AddUnit(unit); ns.Imports.Add(new CodeNamespaceImport("System")); ns.Imports.Add(new CodeNamespaceImport("System.Configuration")); ns.Imports.Add(new CodeNamespaceImport("System.Web")); ns.Imports.Add(new CodeNamespaceImport("System.Web.Profile")); RootProfilePropertySettingsCollection props = ps.PropertySettings; if (props == null) { return(true); } SortedList <string, string> groupProperties = new SortedList <string, string> (); string groupName; foreach (ProfileGroupSettings pgs in props.GroupSettings) { groupName = MakeGroupName(pgs.Name); groupProperties.Add(groupName, pgs.Name); BuildProfileClass(ps, groupName, pgs.PropertySettings, ns, "System.Web.Profile.ProfileGroupBase", true, null); } string baseType = ps.Inherits; if (String.IsNullOrEmpty(baseType)) { baseType = "System.Web.Profile.ProfileBase"; } else { string[] parts = baseType.Split(new char[] { ',' }); if (parts.Length > 1) { baseType = parts [0].Trim(); } } bool baseIsGlobal; if (baseType.IndexOf('.') != -1) { baseIsGlobal = true; } else { baseIsGlobal = false; } BuildProfileClass(ps, "ProfileCommon", props, ns, baseType, baseIsGlobal, groupProperties); return(true); }
// FIXME: there should be some validation of syntactic correctness of the member/class name // for the groups/properties. For now it's left to the compiler to report errors. // // CodeGenerator.IsValidLanguageIndependentIdentifier (id) - use that // bool ProcessCustomProfile (ProfileSection ps, AppCodeAssembly defasm) { CodeCompileUnit unit = new CodeCompileUnit (); CodeNamespace ns = new CodeNamespace (null); unit.Namespaces.Add (ns); defasm.AddUnit (unit); ns.Imports.Add (new CodeNamespaceImport ("System")); ns.Imports.Add (new CodeNamespaceImport ("System.Configuration")); ns.Imports.Add (new CodeNamespaceImport ("System.Web")); ns.Imports.Add (new CodeNamespaceImport ("System.Web.Profile")); RootProfilePropertySettingsCollection props = ps.PropertySettings; if (props == null) return true; SortedList<string, string> groupProperties = new SortedList<string, string> (); string groupName; foreach (ProfileGroupSettings pgs in props.GroupSettings) { groupName = MakeGroupName (pgs.Name); groupProperties.Add (groupName, pgs.Name); BuildProfileClass (ps, groupName, pgs.PropertySettings, ns, "System.Web.Profile.ProfileGroupBase", true, null); } string baseType = ps.Inherits; if (String.IsNullOrEmpty (baseType)) baseType = "System.Web.Profile.ProfileBase"; else { string[] parts = baseType.Split (new char[] {','}); if (parts.Length > 1) baseType = parts [0].Trim (); } bool baseIsGlobal; if (baseType.IndexOf ('.') != -1) baseIsGlobal = true; else baseIsGlobal = false; BuildProfileClass (ps, "ProfileCommon", props, ns, baseType, baseIsGlobal, groupProperties); return true; }