Esempio n. 1
0
        /// <summary>
        /// Overrides the metadata for the property on the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="metadata">The metadata.</param>
        protected void OverrideMetadata(Type type, PropertyMetadata metadata)
        {
            Contract.Requires <ArgumentNullException>(type != null);
            Contract.Requires <ArgumentNullException>(metadata != null);

            if (_metadata.ContainsKey(type))
            {
                throw new InvalidOperationException(
                          $"Metadata is already set for {Name} on {type}.");
            }

            var baseMetadata = GetMetadata(type);

            metadata.Merge(baseMetadata, this);
            _metadata.Add(type, metadata);
        }
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key)
        {
            if (forType == null)
            {
                throw new ArgumentNullException("forType");
            }

            if (typeMetadata == null)
            {
                throw new ArgumentNullException("typeMetadata");
            }

            // further checking?  should we check
            // key.DependencyProperty == this?
            typeMetadata.Merge(this.DefaultMetadata, this, forType);
            this.metadataByType.Add(forType, typeMetadata);
        }
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
        {
            if (forType == null)
            {
                throw new ArgumentNullException("forType");
            }

            if (typeMetadata == null)
            {
                throw new ArgumentNullException("typeMetadata");
            }

            if (this.ReadOnly)
            {
                throw new InvalidOperationException(string.Format("Cannot override metadata on readonly property '{0}' without using a DependencyPropertyKey", this.Name));
            }

            typeMetadata.Merge(this.DefaultMetadata, this, forType);
            this.metadataByType.Add(forType, typeMetadata);
        }
Esempio n. 4
0
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key)
        {
            if (forType == null)
            {
                throw new ArgumentNullException("forType");
            }

            if (typeMetadata == null)
            {
                throw new ArgumentNullException("typeMetadata");
            }

            // further checking?  should we check
            // key.DependencyProperty == this?
            typeMetadata.Merge(this.DefaultMetadata, this, forType);
            this.metadataByType.Add(forType, typeMetadata);
        }
Esempio n. 5
0
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
        {
            if (forType == null)
            {
                throw new ArgumentNullException("forType");
            }

            if (typeMetadata == null)
            {
                throw new ArgumentNullException("typeMetadata");
            }

            if (this.ReadOnly)
            {
                throw new InvalidOperationException(string.Format("Cannot override metadata on readonly property '{0}' without using a DependencyPropertyKey", this.Name));
            }

            typeMetadata.Merge(this.DefaultMetadata, this, forType);
            this.metadataByType.Add(forType, typeMetadata);
        }