SobekCM.Core.Configuration.QualityControl_Configuration.Add_Profile C# (CSharp) Method

Add_Profile() public method

Add a quality control profile with user settings, such as which division types to include for selection
public Add_Profile ( QualityControl_Profile New_Profile ) : void
New_Profile QualityControl_Profile New profile to add
return void
        public void Add_Profile(QualityControl_Profile New_Profile)
        {
            // Add to the dictionary of profiles
            Profiles.Add(New_Profile);
            profilesDictionary[New_Profile.Profile_Name] = New_Profile;

            // Was this the default profile?
            if (New_Profile.Default_Profile)
                DefaultProfile = New_Profile.Profile_Name;
        }

Usage Example

        private static void read_qc_profiles(XmlReader ReaderXml, QualityControl_Configuration Config )
        {
            int unnamed_profile_counter = 1;

            while (ReaderXml.Read())
            {
                if (ReaderXml.NodeType == XmlNodeType.Element)
                {
                    switch (ReaderXml.Name.ToLower())
                    {
                        case "profile":
                            QualityControl_Profile profile = new QualityControl_Profile();
                            XmlReader child_readerXml = ReaderXml.ReadSubtree();
                            if (ReaderXml.MoveToAttribute("name"))
                                profile.Profile_Name = ReaderXml.Value.Trim();
                            if (ReaderXml.MoveToAttribute("description"))
                                profile.Profile_Description = ReaderXml.Value;
                            if (ReaderXml.MoveToAttribute("isDefault"))
                            {
                                bool tempValue;
                                if (bool.TryParse(ReaderXml.Value, out tempValue))
                                {
                                    profile.Default_Profile = tempValue;
                                }
                            }
                            // Enforce a name for this profile (should have one according to XSD)
                            if (profile.Profile_Name.Length == 0)
                            {
                                profile.Profile_Name = "Unnamed" + unnamed_profile_counter;
                                unnamed_profile_counter++;
                            }

                            QualityControl_Division_Config thisConfig = new QualityControl_Division_Config();
                            while (child_readerXml.Read())
                            {
                                if (child_readerXml.NodeType == XmlNodeType.Element && child_readerXml.Name.ToLower() == "divisiontype")
                                {
                                    thisConfig = new QualityControl_Division_Config();

                                    if (child_readerXml.MoveToAttribute("type"))
                                    {
                                        thisConfig.TypeName = child_readerXml.Value;
                                    }
                                    if (child_readerXml.MoveToAttribute("isNameable"))
                                        thisConfig.isNameable = Convert.ToBoolean(child_readerXml.Value);
                                    if (child_readerXml.MoveToAttribute("base"))
                                    {
                                        string baseType = child_readerXml.Value;
                                        if (!String.Equals(baseType, thisConfig.TypeName, StringComparison.OrdinalIgnoreCase))
                                        {
                                            thisConfig.BaseTypeName = baseType;
                                        }
                                    }
                                    profile.Add_Division_Type(thisConfig);
                                }
                                else if (child_readerXml.NodeType == XmlNodeType.Element && child_readerXml.Name.ToLower() == "translation")
                                {
                                    if (thisConfig != null)
                                    {
                                        string language = (child_readerXml.MoveToAttribute("language")) ? child_readerXml.Value : String.Empty;
                                        string text = (child_readerXml.MoveToAttribute("text")) ? child_readerXml.Value : String.Empty;

                                        if ((!String.IsNullOrEmpty(language)) && (!String.IsNullOrEmpty(text)))
                                        {
                                            thisConfig.Add_Translation(Web_Language_Enum_Converter.Code_To_Enum(language), text );
                                        }
                                    }
                                }
                            }

                            Config.Add_Profile(profile);
                            break;

                    }
                }
            }
        }