示例#1
0
        public override bool Equals(object prefix)
        {
            TagPrefixInfo ns = prefix as TagPrefixInfo;

            return(StringUtil.Equals(TagPrefix, ns.TagPrefix) &&
                   StringUtil.Equals(TagName, ns.TagName) &&
                   StringUtil.Equals(Namespace, ns.Namespace) &&
                   StringUtil.Equals(Assembly, ns.Assembly) &&
                   StringUtil.Equals(Source, ns.Source));
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            TagPrefixInfo info = (TagPrefixInfo)element;

            if (string.IsNullOrEmpty(info.TagName))
            {
                return(info.TagPrefix + ":" + info.Namespace + ":" + (string.IsNullOrEmpty(info.Assembly) ? string.Empty : info.Assembly));
            }
            return(info.TagPrefix + ":" + info.TagName);
        }
示例#3
0
        public override bool Equals(object prefix)
        {
            TagPrefixInfo info = prefix as TagPrefixInfo;

            if (info == null)
            {
                return(false);
            }

            return(Namespace == info.Namespace &&
                   Source == info.Source &&
                   TagName == info.TagName &&
                   TagPrefix == info.TagPrefix);
        }
示例#4
0
        public static void SetValue(string key, string value)
        {
            Configuration config = WebConfigurationManager.OpenWebConfiguration("~/xml/");

            //ConnectionStringSettings test = new ConnectionStringSettings("test1", "test1", "test1.dll");

            //config.ConnectionStrings.ConnectionStrings.Add(test);

            //<add src="~/WebPart/ProductCate.ascx" tagName="cate" tagPrefix="uc" />
            TagPrefixInfo dd=new TagPrefixInfo("uc","","","cate","~/WebPart/ProductCate.ascx");
            //config.SectionGroups["system.web"]
            SystemWebSectionGroup t = new SystemWebSectionGroup();
            t.Pages.Controls.Add(dd);
            config.Save(ConfigurationSaveMode.Modified);
        }
示例#5
0
        private static void Validate(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("control");
            }

            TagPrefixInfo elem = (TagPrefixInfo)value;

            if (System.Web.UI.Util.ContainsWhiteSpace(elem.TagPrefix))
            {
                throw new ConfigurationErrorsException(
                          SR.GetString(SR.Space_attribute, "tagPrefix"));
            }

            bool invalid = false;

            if (!String.IsNullOrEmpty(elem.Namespace))
            {
                // It is a custom control
                if (!(String.IsNullOrEmpty(elem.TagName) && String.IsNullOrEmpty(elem.Source)))
                {
                    invalid = true;
                }
            }
            else if (!String.IsNullOrEmpty(elem.TagName))
            {
                // It is a user control
                if (!(String.IsNullOrEmpty(elem.Namespace) &&
                      String.IsNullOrEmpty(elem.Assembly) &&
                      !String.IsNullOrEmpty(elem.Source)))
                {
                    invalid = true;
                }
            }
            else
            {
                invalid = true;
            }

            if (invalid)
            {
                throw new ConfigurationErrorsException(
                          SR.GetString(SR.Invalid_tagprefix_entry));
            }
        }
        void AddControl(PagesSection section, SettingsMappingWhatContents how)
        {
            Dictionary <string, string> attrs = how.Attributes;
            if (attrs == null || attrs.Count == 0)
                return;

            string tagPrefix, nameSpace, asm, tagName, source;
            if (!attrs.TryGetValue ("tagPrefix", out tagPrefix))
                tagPrefix = String.Empty;
            if (!attrs.TryGetValue ("namespace", out nameSpace))
                nameSpace = String.Empty;
            if (!attrs.TryGetValue ("assembly", out asm))
                asm = String.Empty;
            if (!attrs.TryGetValue ("tagName", out tagName))
                tagName = String.Empty;
            if (!attrs.TryGetValue ("src", out source))
                source = String.Empty;

            TagPrefixInfo info = new TagPrefixInfo (tagPrefix, nameSpace, asm, tagName, source);
            section.Controls.Add (info);
        }
        private static void Validate(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("control");
            }
            TagPrefixInfo info = (TagPrefixInfo)value;

            if (Util.ContainsWhiteSpace(info.TagPrefix))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Space_attribute", new object[] { "tagPrefix" }));
            }
            bool flag = false;

            if (!string.IsNullOrEmpty(info.Namespace))
            {
                if (!string.IsNullOrEmpty(info.TagName) || !string.IsNullOrEmpty(info.Source))
                {
                    flag = true;
                }
            }
            else if (!string.IsNullOrEmpty(info.TagName))
            {
                if ((!string.IsNullOrEmpty(info.Namespace) || !string.IsNullOrEmpty(info.Assembly)) || string.IsNullOrEmpty(info.Source))
                {
                    flag = true;
                }
            }
            else
            {
                flag = true;
            }
            if (flag)
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_tagprefix_entry"));
            }
        }
 public void Remove(TagPrefixInfo tagPrefixInformation)
 {
 }
 public void Add(TagPrefixInfo tagPrefixInformation)
 {
 }
示例#10
0
 public void Remove(TagPrefixInfo tagPrefixInformation)
 {
     BaseRemove(GetElementKey(tagPrefixInformation));
 }
示例#11
0
 public void Remove(TagPrefixInfo tagPrefixInformation)
 {
 }
        public override bool Equals(object prefix)
        {
            TagPrefixInfo info = prefix as TagPrefixInfo;

            return(((System.Web.Util.StringUtil.Equals(this.TagPrefix, info.TagPrefix) && System.Web.Util.StringUtil.Equals(this.TagName, info.TagName)) && (System.Web.Util.StringUtil.Equals(this.Namespace, info.Namespace) && System.Web.Util.StringUtil.Equals(this.Assembly, info.Assembly))) && System.Web.Util.StringUtil.Equals(this.Source, info.Source));
        }
 public void Remove(TagPrefixInfo tagPrefixInformation)
 {
     base.BaseRemove(this.GetElementKey(tagPrefixInformation));
 }
示例#14
0
        public static void Main()
        {
            try
            {
                // Get the Web application configuration.
                Configuration configuration =
                    WebConfigurationManager.OpenWebConfiguration("");

                // Get the section.
                PagesSection pagesSection =
                    (PagesSection)configuration.GetSection("system.web/pages");

                // <Snippet2>
                // <Snippet20>
                // Get the AutoImportVBNamespace property.
                Console.WriteLine("AutoImportVBNamespace: '{0}'",
                                  pagesSection.Namespaces.AutoImportVBNamespace.ToString());

                // Set the AutoImportVBNamespace property.
                pagesSection.Namespaces.AutoImportVBNamespace = true;
                // </Snippet20>

                // <Snippet21>
                // Get all current Namespaces in the collection.
                for (int i = 0; i < pagesSection.Namespaces.Count; i++)
                {
                    Console.WriteLine(
                        "Namespaces {0}: '{1}'", i,
                        pagesSection.Namespaces[i].Namespace);
                }
                // </Snippet21>

                // <Snippet22>
                // <Snippet28>
                // Create a new NamespaceInfo object.
                System.Web.Configuration.NamespaceInfo namespaceInfo =
                    new System.Web.Configuration.NamespaceInfo("System");
                // </Snippet28>

                // <Snippet29>
                // Set the Namespace property.
                namespaceInfo.Namespace = "System.Collections";
                // </Snippet29>

                // Execute the Add Method.
                pagesSection.Namespaces.Add(namespaceInfo);
                // </Snippet22>

                // <Snippet23>
                // Add a NamespaceInfo object using a constructor.
                pagesSection.Namespaces.Add(
                    new System.Web.Configuration.NamespaceInfo(
                        "System.Collections.Specialized"));
                // </Snippet23>

                // <Snippet25>
                // Execute the RemoveAt method.
                pagesSection.Namespaces.RemoveAt(0);
                // </Snippet25>

                // <Snippet24>
                // Execute the Clear method.
                pagesSection.Namespaces.Clear();
                // </Snippet24>

                // <Snippet26>
                // Execute the Remove method.
                pagesSection.Namespaces.Remove("System.Collections");
                // </Snippet26>

                // <Snippet27>
                // Get the current AutoImportVBNamespace property value.
                Console.WriteLine(
                    "Current AutoImportVBNamespace value: '{0}'",
                    pagesSection.Namespaces.AutoImportVBNamespace);

                // Set the AutoImportVBNamespace property to false.
                pagesSection.Namespaces.AutoImportVBNamespace = false;
                // </Snippet27>
                // </Snippet2>

                // <Snippet3>
                // Get the current PageParserFilterType property value.
                Console.WriteLine(
                    "Current PageParserFilterType value: '{0}'",
                    pagesSection.PageParserFilterType);

                // Set the PageParserFilterType property to
                // "MyNameSpace.AllowOnlySafeControls".
                pagesSection.PageParserFilterType =
                    "MyNameSpace.AllowOnlySafeControls";
                // </Snippet3>

                // <Snippet4>
                // Get the current Theme property value.
                Console.WriteLine(
                    "Current Theme value: '{0}'",
                    pagesSection.Theme);

                // Set the Theme property to "MyCustomTheme".
                pagesSection.Theme = "MyCustomTheme";
                // </Snippet4>

                // <Snippet5>
                // Get the current EnableViewState property value.
                Console.WriteLine(
                    "Current EnableViewState value: '{0}'",
                    pagesSection.EnableViewState);

                // Set the EnableViewState property to false.
                pagesSection.EnableViewState = false;
                // </Snippet5>

                // <Snippet6>
                // Get the current CompilationMode property value.
                Console.WriteLine(
                    "Current CompilationMode value: '{0}'",
                    pagesSection.CompilationMode);

                // Set the CompilationMode property to CompilationMode.Always.
                pagesSection.CompilationMode = CompilationMode.Always;
                // </Snippet6>

                // <Snippet7>
                // Get the current ValidateRequest property value.
                Console.WriteLine(
                    "Current ValidateRequest value: '{0}'",
                    pagesSection.ValidateRequest);

                // Set the ValidateRequest property to true.
                pagesSection.ValidateRequest = true;
                // </Snippet7>

                // <Snippet8>
                // Get the current EnableViewStateMac property value.
                Console.WriteLine(
                    "Current EnableViewStateMac value: '{0}'",
                    pagesSection.EnableViewStateMac);

                // Set the EnableViewStateMac property to true.
                pagesSection.EnableViewStateMac = true;
                // </Snippet8>

                // <Snippet9>
                // Get the current AutoEventWireup property value.
                Console.WriteLine(
                    "Current AutoEventWireup value: '{0}'",
                    pagesSection.AutoEventWireup);

                // Set the AutoEventWireup property to false.
                pagesSection.AutoEventWireup = false;
                // </Snippet9>

                // <Snippet10>
                // Get the current MaxPageStateFieldLength property value.
                Console.WriteLine(
                    "Current MaxPageStateFieldLength value: '{0}'",
                    pagesSection.MaxPageStateFieldLength);

                // Set the MaxPageStateFieldLength property to 4098.
                pagesSection.MaxPageStateFieldLength = 4098;
                // </Snippet10>

                // <Snippet11>
                // Get the current UserControlBaseType property value.
                Console.WriteLine(
                    "Current UserControlBaseType value: '{0}'",
                    pagesSection.UserControlBaseType);

                // Set the UserControlBaseType property to
                // "MyNameSpace.MyCustomControlBaseType".
                pagesSection.UserControlBaseType =
                    "MyNameSpace.MyCustomControlBaseType";
                // </Snippet11>

                // <Snippet12>
                // <Snippet30>
                // Get all current Controls in the collection.
                for (int i = 0; i < pagesSection.Controls.Count; i++)
                {
                    Console.WriteLine("Control {0}:", i);
                    Console.WriteLine("  TagPrefix = '{0}' ",
                                      pagesSection.Controls[i].TagPrefix);
                    Console.WriteLine("  TagName = '{0}' ",
                                      pagesSection.Controls[i].TagName);
                    Console.WriteLine("  Source = '{0}' ",
                                      pagesSection.Controls[i].Source);
                    Console.WriteLine("  Namespace = '{0}' ",
                                      pagesSection.Controls[i].Namespace);
                    Console.WriteLine("  Assembly = '{0}' ",
                                      pagesSection.Controls[i].Assembly);
                }
                // </Snippet30>

                // <Snippet31>
                // <Snippet33>
                // Create a new TagPrefixInfo object.
                System.Web.Configuration.TagPrefixInfo tagPrefixInfo =
                    new System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx");
                // </Snippet33>

                // <Snippet39>
                // Execute the Add Method.
                pagesSection.Controls.Add(tagPrefixInfo);
                // </Snippet39>
                // </Snippet31>

                // <Snippet32>
                // Add a TagPrefixInfo object using a constructor.
                pagesSection.Controls.Add(
                    new System.Web.Configuration.TagPrefixInfo(
                        "MyCtrl", "MyNameSpace", "MyAssembly", "MyControl",
                        "MyControl.ascx"));
                // </Snippet32>
                // </Snippet12>

                // <Snippet13>
                // Get the current StyleSheetTheme property value.
                Console.WriteLine(
                    "Current StyleSheetTheme value: '{0}'",
                    pagesSection.StyleSheetTheme);

                // Set the StyleSheetTheme property.
                pagesSection.StyleSheetTheme =
                    "MyCustomStyleSheetTheme";
                // </Snippet13>

                // <Snippet14>
                // Get the current EnableSessionState property value.
                Console.WriteLine(
                    "Current EnableSessionState value: '{0}'",
                    pagesSection.EnableSessionState);

                // Set the EnableSessionState property to
                // PagesEnableSessionState.ReadOnly.
                pagesSection.EnableSessionState =
                    PagesEnableSessionState.ReadOnly;
                // </Snippet14>

                // <Snippet15>
                // Get the current MasterPageFile property value.
                Console.WriteLine(
                    "Current MasterPageFile value: '{0}'",
                    pagesSection.MasterPageFile);

                // Set the MasterPageFile property to "MyMasterPage.ascx".
                pagesSection.MasterPageFile = "MyMasterPage.ascx";
                // </Snippet15>

                // <Snippet16>
                // Get the current Buffer property value.
                Console.WriteLine(
                    "Current Buffer value: '{0}'", pagesSection.Buffer);

                // Set the Buffer property to true.
                pagesSection.Buffer = true;
                // </Snippet16>

                // <Snippet17>
                // <Snippet40>
                // Get all current TagMappings in the collection.
                for (int i = 0; i < pagesSection.TagMapping.Count; i++)
                {
                    Console.WriteLine("TagMapping {0}:", i);
                    Console.WriteLine("  TagTypeName = '{0}'",
                                      pagesSection.TagMapping[i].TagType);
                    Console.WriteLine("  MappedTagTypeName = '{0}'",
                                      pagesSection.TagMapping[i].MappedTagType);
                }
                // </Snippet40>

                // <Snippet42>
                // Add a TagMapInfo object using a constructor.
                pagesSection.TagMapping.Add(
                    new System.Web.Configuration.TagMapInfo(
                        "MyNameSpace.MyControl", "MyNameSpace.MyOtherControl"));
                // </Snippet42>
                // </Snippet17>

                // <Snippet18>
                // Get the current PageBaseType property value.
                Console.WriteLine(
                    "Current PageBaseType value: '{0}'",
                    pagesSection.PageBaseType);

                // Set the PageBaseType property to
                // "MyNameSpace.MyCustomPagelBaseType".
                pagesSection.PageBaseType =
                    "MyNameSpace.MyCustomPagelBaseType";
                // </Snippet18>

                // <Snippet19>
                // Get the current SmartNavigation property value.
                Console.WriteLine(
                    "Current SmartNavigation value: '{0}'",
                    pagesSection.SmartNavigation);

                // Set the SmartNavigation property to true.
                pagesSection.SmartNavigation = true;
                // </Snippet19>

                // Update if not locked.
                if (!pagesSection.SectionInformation.IsLocked)
                {
                    configuration.Save();
                    Console.WriteLine("** Configuration updated.");
                }
                else
                {
                    Console.WriteLine("** Could not update, section is locked.");
                }
            }
            catch (System.Exception e)
            {
                // Unknown error.
                Console.WriteLine("A unknown exception detected in" +
                                  "UsingPagesSection Main.");
                Console.WriteLine(e);
            }
            Console.ReadLine();
        }
 public void Remove(TagPrefixInfo tagPrefixInformation)
 {
     base.BaseRemove(this.GetElementKey(tagPrefixInformation));
 }
		public void Add (TagPrefixInfo tagPrefixInformation)
		{
			BaseAdd (tagPrefixInformation);
		}
		public void Remove (TagPrefixInfo tagPrefixInformation)
		{
			BaseRemove (GetElementKey (tagPrefixInformation));
		}
示例#18
0
 public void Add(TagPrefixInfo tagPrefixInformation)
 {
     BaseAdd(tagPrefixInformation);
 }
示例#19
0
        protected override object GetElementKey(ConfigurationElement element)
        {
            TagPrefixInfo info = (TagPrefixInfo)element;

            return(String.Concat(info.TagPrefix, "-", info.TagName, "-", info.Source, "-", info.Namespace, "-", info.Assembly));
        }
示例#20
0
 public void Add(TagPrefixInfo tagPrefixInformation)
 {
 }