1 // 2 // System.Web.Configuration.TagPrefixInfo 3 // 4 // Authors: 5 // Chris Toshok (toshok@ximian.com) 6 // 7 // (C) 2005 Novell, Inc (http://www.novell.com) 8 // 9 10 // 11 // Permission is hereby granted, free of charge, to any person obtaining 12 // a copy of this software and associated documentation files (the 13 // "Software"), to deal in the Software without restriction, including 14 // without limitation the rights to use, copy, modify, merge, publish, 15 // distribute, sublicense, and/or sell copies of the Software, and to 16 // permit persons to whom the Software is furnished to do so, subject to 17 // the following conditions: 18 // 19 // The above copyright notice and this permission notice shall be 20 // included in all copies or substantial portions of the Software. 21 // 22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 // 30 31 32 using System; 33 using System.ComponentModel; 34 using System.Configuration; 35 using System.Web.UI; 36 using System.Xml; 37 38 namespace System.Web.Configuration 39 { 40 public sealed class TagPrefixInfo : ConfigurationElement 41 { 42 static ConfigurationPropertyCollection properties; 43 static ConfigurationProperty tagPrefixProp; 44 static ConfigurationProperty namespaceProp; 45 static ConfigurationProperty assemblyProp; 46 static ConfigurationProperty tagNameProp; 47 static ConfigurationProperty sourceProp; 48 49 static ConfigurationElementProperty elementProperty; 50 TagPrefixInfo()51 static TagPrefixInfo () 52 { 53 tagPrefixProp = new ConfigurationProperty ("tagPrefix", typeof (string), "/", 54 TypeDescriptor.GetConverter (typeof (string)), 55 PropertyHelper.NonEmptyStringValidator, 56 ConfigurationPropertyOptions.IsRequired); 57 namespaceProp = new ConfigurationProperty ("namespace", typeof (string)); 58 assemblyProp = new ConfigurationProperty ("assembly", typeof (string)); 59 tagNameProp = new ConfigurationProperty ("tagName", typeof (string)); 60 sourceProp = new ConfigurationProperty ("src", typeof (string)); 61 62 properties = new ConfigurationPropertyCollection (); 63 properties.Add (tagPrefixProp); 64 properties.Add (namespaceProp); 65 properties.Add (assemblyProp); 66 properties.Add (tagNameProp); 67 properties.Add (sourceProp); 68 69 elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (TagPrefixInfo), ValidateElement)); 70 } 71 TagPrefixInfo()72 internal TagPrefixInfo () 73 { 74 } 75 TagPrefixInfo(string tagPrefix, string nameSpace, string assembly, string tagName, string source)76 public TagPrefixInfo (string tagPrefix, string nameSpace, string assembly, string tagName, string source) 77 { 78 this.TagPrefix = tagPrefix; 79 this.Namespace = nameSpace; 80 this.Assembly = assembly; 81 this.TagName = tagName; 82 this.Source = source; 83 } 84 ValidateElement(object o)85 static void ValidateElement (object o) 86 { 87 /* XXX do some sort of element validation here? */ 88 } 89 90 protected internal override ConfigurationElementProperty ElementProperty { 91 get { return elementProperty; } 92 } 93 Equals(object prefix)94 public override bool Equals (object prefix) 95 { 96 TagPrefixInfo info = prefix as TagPrefixInfo; 97 if (info == null) 98 return false; 99 100 return (Namespace == info.Namespace 101 && Source == info.Source 102 && TagName == info.TagName 103 && TagPrefix == info.TagPrefix); 104 } 105 GetHashCode()106 public override int GetHashCode () 107 { 108 return Namespace.GetHashCode() + Source.GetHashCode() + TagName.GetHashCode() + TagPrefix.GetHashCode(); 109 } 110 111 [ConfigurationProperty ("assembly")] 112 public string Assembly { 113 get { return (string) base[assemblyProp]; } 114 set { base[assemblyProp] = value; } 115 } 116 117 [ConfigurationProperty ("namespace")] 118 public string Namespace { 119 get { return (string) base[namespaceProp]; } 120 set { base[namespaceProp] = value; } 121 } 122 123 [ConfigurationProperty ("src")] 124 public string Source { 125 get { return (string) base[sourceProp]; } 126 set { base[sourceProp] = value; } 127 } 128 129 [ConfigurationProperty ("tagName")] 130 public string TagName { 131 get { return (string) base[tagNameProp]; } 132 set { base[tagNameProp] = value; } 133 } 134 135 [StringValidator (MinLength = 1)] 136 [ConfigurationProperty ("tagPrefix", DefaultValue = "/", Options = ConfigurationPropertyOptions.IsRequired)] 137 public string TagPrefix { 138 get { return (string) base[tagPrefixProp]; } 139 set { base[tagPrefixProp] = value; } 140 } 141 142 protected internal override ConfigurationPropertyCollection Properties { 143 get { return properties; } 144 } 145 } 146 } 147 148