Пример #1
0
        public bool Add(T item)
        {
            string stringItem = getStringItem(item);

            if (items.ContainsKey(stringItem))
            {
                return(false);
            }

            items.Add(stringItem, item);
            return(true);
        }
Пример #2
0
        public void OverrideMetadata(Type forType, PropertyMetadata metadata)
        {
            if (typeMetadata.ContainsKey(forType))
            {
                throw new Granular.Exception("DependencyProperty \"{0}\" already contains metadata for type \"{1}\"", this, forType.Name);
            }

            if (metadata.DefaultValue == null)
            {
                metadata.DefaultValue = ownerMetadata.DefaultValue;
            }

            if (metadata.CoerceValueCallback == null)
            {
                metadata.CoerceValueCallback = ownerMetadata.CoerceValueCallback;
            }

            if (Inherits != metadata.Inherits)
            {
                throw new Granular.Exception("Overriding inheritance behavior is not supported, Overrides of \"{0}\" must declare \"inherits: {1}\"", this, Inherits);
            }

            if (Inherits)
            {
                if (metadata.DefaultValue != null && metadata.DefaultValue != ownerMetadata.DefaultValue)
                {
                    throw new Granular.Exception("Overriding inherited properties metadata with different default value is not supported, Overrides of \"{0}\" cannot set a different default value other than \"{1}\"", this, ownerMetadata.DefaultValue);
                }

                metadata.DefaultValue = ownerMetadata.DefaultValue;
            }

            typeMetadata.Add(forType, metadata);

            typeMetadataCache.Clear();
            orderedTypeMetadataCache = null;

            isMetadataOverridden = true;
        }
Пример #3
0
 public bool ContainsKey(TKey key)
 {
     return(keys.ContainsKey(getStringKey(key)));
 }
Пример #4
0
 public bool Contains(TKey key)
 {
     return(values.ContainsKey(key) || unsetValues.Contains(key));
 }