예제 #1
0
        /// <summary>
        /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="value">An <see cref="Object"/> that specifies the type of array for which to get properties.</param>
        /// <param name="attributes">An array of type <see cref="Attribute"/> that is used as a filter.</param>
        /// <returns>A <see cref="PropertyDescriptorCollection"/> with the properties that are exposed for this data type, or <see langword="null"/> if there are no properties.</returns>
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            MergedConfigurationNode mergedConfigurationNode = value as MergedConfigurationNode;

            if (mergedConfigurationNode != null)
            {
                return(TypeDescriptor.GetProperties(mergedConfigurationNode, attributes));
            }

            return(base.GetProperties(context, value, attributes));
        }
예제 #2
0
        /// <summary>
        /// Converts an arbitrary instance of <see cref="System.Object"/> to an instance of <see cref="MergedConfigurationNode"/>.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">A <see cref="System.Globalization.CultureInfo"/>. If <see langword="null"/> is passed, the current culture is assumed.</param>
        /// <param name="value">The instance of <see cref="System.Object"/> that should be used for conversion.</param>
        /// <returns>If conversion succeeds, an instance of <see cref="MergedConfigurationNode"/>, otherwise <see langword="null"/>.</returns>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value != null)
            {
                string overrideString = value.ToString();
                MergedConfigurationNode    oldMergedConfigurationNode = context.PropertyDescriptor.GetValue(context.Instance) as MergedConfigurationNode;
                ConfigurationNodeMergeData oldMergeData = oldMergedConfigurationNode.MergeData;

                bool overrideProperties = (overrideString == Resources.OverrideProperties);

                ConfigurationNodeMergeData newMergeData = new ConfigurationNodeMergeData(overrideProperties, oldMergeData);
                return(new MergedConfigurationNode(newMergeData, oldMergedConfigurationNode));
            }
            return(base.ConvertFrom(context, culture, value));
        }
예제 #3
0
        /// <summary>
        /// Converts an instance of <see cref="MergedConfigurationNode"/> to the type specified in <paramref name="destinationType"/>.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">A <see cref="System.Globalization.CultureInfo"/>. If <see langword="null"/> is passed, the current culture is assumed.</param>
        /// <param name="value">The instance of <see cref="MergedConfigurationNode"/> that should be converted.</param>
        /// <param name="destinationType">The type to which the <paramref name="value"/> should be converted.</param>
        /// <returns>An instance of <paramref name="destinationType"/> if converstion succeeds, otherwise <see langword="null"/>.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                if (value is string)
                {
                    return(value);
                }
                MergedConfigurationNode mergedConfigurationNode = value as MergedConfigurationNode;
                if (mergedConfigurationNode != null)
                {
                    if (mergedConfigurationNode.MergeData.OverrideProperties)
                    {
                        return(Resources.OverrideProperties);
                    }
                    else
                    {
                        return(Resources.DontOverrideProperties);
                    }
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
예제 #4
0
 /// <summary>
 /// Updates the <see cref="MergedConfigurationNode"/> for a specific <see cref="ConfigurationNode"/> instance.
 /// </summary>
 /// <param name="node">The <see cref="ConfigurationNode"/> whose properties in this environment should be updated.</param>
 /// <param name="value">The <see cref="MergedConfigurationNode"/> instance that contains all the differences for the <paramref name="node"/>.</param>
 public void SetOverrides(ConfigurationNode node, MergedConfigurationNode value)
 {
     environmentData.UpdateMergeData(node, value.MergeData);
 }
예제 #5
0
 internal MergedConfigurationNode(ConfigurationNodeMergeData mergedConfigurationNodeData, MergedConfigurationNode mergedConfigurationNode)
     : this(mergedConfigurationNode.masterConfigurationNode, mergedConfigurationNodeData)
 {
 }
		/// <summary>
		/// Updates the <see cref="MergedConfigurationNode"/> for a specific <see cref="ConfigurationNode"/> instance.
		/// </summary>
		/// <param name="node">The <see cref="ConfigurationNode"/> whose properties in this environment should be updated.</param>
		/// <param name="value">The <see cref="MergedConfigurationNode"/> instance that contains all the differences for the <paramref name="node"/>.</param>
		public void SetOverrides(ConfigurationNode node, MergedConfigurationNode value)
		{
			environmentData.UpdateMergeData(node, value.MergeData);
		}
 internal MergedConfigurationNode(ConfigurationNodeMergeData mergedConfigurationNodeData, MergedConfigurationNode mergedConfigurationNode)
     : this(mergedConfigurationNode.masterConfigurationNode, mergedConfigurationNodeData)
 {
 }