public static ListenerElement Create(ElementInformation eI)
 {
     string name = eI.Properties["name"].Value as string;
     string type = eI.Properties["type"].Value as string;
     string initializeData = eI.Properties["initializeData"].Value as string;
     return new ListenerElement (name, type, initializeData);
 }
Exemple #2
0
 internal void Reset(ElementInformation parentInfo)
 {
     foreach (PropertyInformation prop in Properties)
     {
         PropertyInformation parentProp = parentInfo.Properties [prop.Name];
         prop.Reset(parentProp);
     }
 }
Exemple #3
0
 protected internal virtual void Reset(ConfigurationElement parentElement)
 {
     if (parentElement != null)
     {
         ElementInformation.Reset(parentElement.ElementInformation);
     }
     else
     {
         InitializeDefault();
     }
 }
        internal void HandleLockedAttributes(ConfigurationElement source) {
            // if there are locked attributes on this collection element
            if (source != null) {
                if (source._lockedAttributesList != null || source._lockedAllExceptAttributesList != null) {
                    // enumerate the possible locked properties
                    foreach (PropertyInformation propInfo in source.ElementInformation.Properties) {
                        if ((source._lockedAttributesList != null && (source._lockedAttributesList.Contains(propInfo.Name) ||
                            source._lockedAttributesList.Contains(LockAll))) ||
                            (source._lockedAllExceptAttributesList != null && !source._lockedAllExceptAttributesList.Contains(propInfo.Name))
                           ) {
                            // if the attribute has been locked in the source then check to see
                            // if the local config is trying to override it
                            if (propInfo.Name != LockAttributesKey && propInfo.Name != LockAllAttributesExceptKey) {

                                if (ElementInformation.Properties[propInfo.Name] == null) { // locked items are not defined
                                    
                                    ConfigurationPropertyCollection props = Properties; // so create the property based in the source item
                                    ConfigurationProperty prop = (ConfigurationProperty)source.Properties[propInfo.Name];
                                    props.Add(prop); // Add the property information to the property bag
                                    _evaluationElement = null; // flush the cached element data

                                    // Add the data from the source element but mark it as in herited
                                    // This must use setvalue in order to set the lock and inherited flags
                                    ConfigurationValueFlags flags = ConfigurationValueFlags.Inherited | ConfigurationValueFlags.Locked;
                                    _values.SetValue(propInfo.Name, propInfo.Value, flags, source.PropertyInfoInternal(propInfo.Name));

                                }
                                else { // don't error when optional attibute are not defined yet
                                    if (ElementInformation.Properties[propInfo.Name].ValueOrigin == PropertyValueOrigin.SetHere) {
                                        // Don't allow the override
                                        throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_attribute_locked, propInfo.Name));
                                    }
                                    // They did not override so we need to make sure the value comes from the locked one
                                    ElementInformation.Properties[propInfo.Name].Value = propInfo.Value;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
		static void ValidateProperty (SettingsProperty settingsProperty, ElementInformation elementInfo)
		{
			string exceptionMessage = string.Empty;
			if (!AnonymousIdentificationModule.Enabled && 
				(bool) settingsProperty.Attributes ["AllowAnonymous"])
				exceptionMessage = "Profile property '{0}' allows anonymous users to store data. " +
					"This requires that the AnonymousIdentification feature be enabled.";

			if (settingsProperty.PropertyType == null)
				exceptionMessage = "The type specified for a profile property '{0}' could not be found.";

			if (settingsProperty.SerializeAs == SettingsSerializeAs.Binary &&
				!settingsProperty.PropertyType.IsSerializable)
				exceptionMessage = "The type for the property '{0}' cannot be serialized " +
					"using the binary serializer, since the type is not marked as serializable.";

			if (exceptionMessage.Length > 0)
				throw new ConfigurationErrorsException (string.Format (exceptionMessage, settingsProperty.Name),
					elementInfo.Source, elementInfo.LineNumber);
		}
Exemple #6
0
 internal virtual void InitFromProperty(PropertyInformation propertyInfo)
 {
     elementInfo = new ElementInformation(this, propertyInfo);
     Init();
 }
		internal void Reset (ElementInformation parentInfo)
		{
			foreach (PropertyInformation prop in Properties) {
				PropertyInformation parentProp = parentInfo.Properties [prop.Name];
				prop.Reset (parentProp);
			}
		}
 private static bool ConfigurationElementHasKeyProperties(ElementInformation elementInformation)
 {
     return elementInformation.Properties.Cast<PropertyInformation>().Any(x => x.IsKey);
 }
		internal virtual void InitFromProperty (PropertyInformation propertyInfo)
		{
			elementInfo = new ElementInformation (this, propertyInfo);
			Init ();
		}
Exemple #10
0
 internal void HandleLockedAttributes(ConfigurationElement source)
 {
     if (source == null || source._lockedAttributesList == null && source._lockedAllExceptAttributesList == null)
     return;
       foreach (PropertyInformation propertyInformation in (NameObjectCollectionBase) source.ElementInformation.Properties)
       {
     if ((source._lockedAttributesList != null && (source._lockedAttributesList.Contains(propertyInformation.Name) || source._lockedAttributesList.Contains("*")) || source._lockedAllExceptAttributesList != null && !source._lockedAllExceptAttributesList.Contains(propertyInformation.Name)) && (propertyInformation.Name != "lockAttributes" && propertyInformation.Name != "lockAllAttributesExcept"))
     {
       if (this.ElementInformation.Properties[propertyInformation.Name] == null)
       {
     this.Properties.Add(source.Properties[propertyInformation.Name]);
     this._evaluationElement = (ElementInformation) null;
     ConfigurationValueFlags valueFlags = ConfigurationValueFlags.Inherited | ConfigurationValueFlags.Locked;
     this._values.SetValue(propertyInformation.Name, propertyInformation.Value, valueFlags, source.PropertyInfoInternal(propertyInformation.Name));
       }
       else if (this.ElementInformation.Properties[propertyInformation.Name].ValueOrigin == PropertyValueOrigin.SetHere)
     throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_base_attribute_locked", new object[1]
     {
       (object) propertyInformation.Name
     }));
       else
     this.ElementInformation.Properties[propertyInformation.Name].Value = propertyInformation.Value;
     }
       }
 }
Exemple #11
0
 internal static void FailIfNoAPTCABit(Type t, ElementInformation elemInfo, string propertyName)
 {
   if (HttpRuntime.IsTypeAllowedInConfig(t))
     return;
   if (elemInfo != null)
   {
     PropertyInformation propertyInformation = elemInfo.Properties[propertyName];
     throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_from_untrusted_assembly", new object[1]
     {
       (object) t.FullName
     }), propertyInformation.Source, propertyInformation.LineNumber);
   }
   else
     throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_from_untrusted_assembly", new object[1]
     {
       (object) t.FullName
     }));
 }