示例#1
0
        protected internal override void Subordinate_ItemRemoved <TSKey, TSValue>(ISubordinateDictionary <TSKey, TMItemIdentifier, TSValue, TMItem> subordinate, TSKey key)
        {
            int state;

            lock (syncObject)
                state = this.state;
            if (state == USE_FETCH)
            {
                int index = this.Keys.IndexOf(key);
                if (index == -1)
                {
                    return;
                }
                MasterDictionaryEntry <TMItem> entry = this.Values[index];

                if (entry.Subordinate != subordinate)
                {
                    throw ThrowHelper.ObtainArgumentException(ArgumentWithException.subordinate, ExceptionMessageId.SubordinateMismatch);
                }
                var valueInst = (this.valuesInstance as _ValuesCollection);
                if (valueInst == null)
                {
                    return;
                }
                if (valueInst.Loaded(index))
                {
                    valueInst.dataCopy[index] = null;
                }
            }
            else
            {
                base.Subordinate_ItemRemoved <TSKey, TSValue>(subordinate, key);
            }
        }
示例#2
0
        /// <summary>
        /// Notifier for subordinate dictionaries
        /// indicating that an item has been removed.
        /// </summary>
        /// <typeparam name="TSKey">The kind of key within the subordinate
        /// dictionary.</typeparam>
        /// <typeparam name="TSValue">
        /// The specific type of value used in the
        /// subordinate dictionary, derives from the
        /// master dictionary's <typeparamref name="TValue"/>.
        /// </typeparam>
        /// <param name="subordinate">
        /// The <see cref="ISubordinateDictionary{TSKey, TMKey, TSValue, TMValue}"/>
        /// which is a subordinate of the current
        /// <see cref="MasterDictionaryBase{TKey, TValue}"/>.
        /// </param>
        /// <param name="key">
        /// The <typeparamref name="TSKey"/> of the item removed.
        /// </param>
        protected internal virtual void Subordinate_ItemRemoved <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate, TSKey key)
            where TSKey :
        TKey
            where TSValue :
        TValue
        {
            int index = this.Keys.IndexOf(key);

            /* *
             * The cause behind this is a caching issue.  Since the CLI types
             * are singletons, clearing the cache causes the signatures associated
             * to the members to become invalid since they referenced a type whose
             * underlying system type is now null.
             * */
            if (index == -1)
            {
                return;
            }
            MasterDictionaryEntry <TValue> entry = this.Values[index];

            if (entry.Subordinate != subordinate)
            {
                throw ThrowHelper.ObtainArgumentException(ArgumentWithException.subordinate, ExceptionMessageId.SubordinateMismatch);
            }
            base._Remove(index);
        }
示例#3
0
        private ISubordinateDictionary GetSubordinate(TypeKind kind)
        {
            ISubordinateDictionary subordinate = null;

            switch (kind)
            {
            case TypeKind.Class:
                subordinate = (ISubordinateDictionary)this.parent.Classes;
                break;

            case TypeKind.Delegate:
                subordinate = (ISubordinateDictionary)this.parent.Delegates;
                break;

            case TypeKind.Enumeration:
                subordinate = (ISubordinateDictionary)this.parent.Enums;
                break;

            case TypeKind.Interface:
                subordinate = (ISubordinateDictionary)this.parent.Interfaces;
                break;

            case TypeKind.Struct:
                subordinate = (ISubordinateDictionary)this.parent.Structs;
                break;
            }
            return(subordinate);
        }
示例#4
0
 /// <summary>
 /// Notifier for subordinate dictionaries
 /// indicating that an item has been changed.
 /// </summary>
 /// <typeparam name="TSKey">The kind of key within the subordinate
 /// dictionary.</typeparam>
 /// <typeparam name="TSValue">
 /// The specific type of value used in the
 /// subordinate dictionary, derives from the
 /// master dictionary's <typeparamref name="TValue"/>.
 /// </typeparam>
 /// <param name="subordinate">
 /// The <see cref="ISubordinateDictionary{TSKey, TMKey, TSValue, TMValue}"/>
 /// which is a subordinate of the current
 /// <see cref="MasterDictionaryBase{TKey, TValue}"/>.
 /// </param>
 /// <param name="key">
 /// The <typeparamref name="TKey"/> of the item changed.
 /// </param>
 /// <param name="value">
 /// The <typeparamref name="TSValue"/> of the item
 /// changed.
 /// </param>
 protected internal virtual void Subordinate_ItemChanged <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate, TSKey key, TSValue value)
     where TSKey :
 TKey
     where TSValue :
 TValue
 {
     base[key] = new MasterDictionaryEntry <TValue>((ISubordinateDictionary)subordinate, value);
 }
示例#5
0
 /// <summary>
 /// Adds a subordinate to to the <see cref="MasterDictionaryBase{TKey, TValue}"/>.
 /// </summary>
 /// <typeparam name="TSKey">The kind of key within the subordinate
 /// dictionary.</typeparam>
 /// <typeparam name="TSValue">The sub-type of <typeparamref name="TValue"/>
 /// that the elements of the <paramref name="subordinate"/>
 /// consist of.</typeparam>
 /// <param name="subordinate">
 /// The <see cref="ISubordinateDictionary{TSKey, TMKey, TSValue, TMValue}"/>
 /// which is to become a subordinate of the
 /// current <see cref="MasterDictionaryBase{TKey, TValue}"/>.
 /// </param>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="subordinate"/> is null.</exception>
 /// <exception cref="System.ArgumentException">
 /// thrown when <paramref name="subordinate"/> is not derived from
 /// <see cref="SubordinateDictionary{TSKey, TMKey, TSValue, TMValue}"/> or when
 /// a subordinate of the given <typeparamref name="TSValue"/>
 /// already exists.</exception>
 protected internal void AddSubordinate <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate)
     where TSKey :
 TKey
     where TSValue :
 TValue
 {
     AddSubordinateImpl <TSKey, TSValue>(subordinate);
 }
示例#6
0
 /// <summary>
 /// Creates a new <see cref="MasterDictionaryEntry{TEntry}"/> with the
 /// <paramref name="subordinate"/> and <paramref name="value"/>
 /// provided.
 /// </summary>
 /// <param name="subordinate">
 /// The <see cref="ISubordinateDictionary"/>
 /// from which the <paramref name="value"/> is derived.</param>
 /// <param name="value">The <typeparamref name="TEntry"/>
 /// entered into the master dictionary from the
 /// <paramref name="subordinate"/>.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when
 /// <paramref name="subordinate"/> is null.</exception>
 public MasterDictionaryEntry(ISubordinateDictionary subordinate, TEntry value)
 {
     if (subordinate == null)
     {
         throw new ArgumentNullException("subordinate");
     }
     this.subordinate = subordinate;
     this.value       = value;
 }
示例#7
0
 protected internal virtual void Subordinate_ItemsAdded <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate, IEnumerable <KeyValuePair <TSKey, TSValue> > items)
     where TSKey :
 TKey
     where TSValue :
 TValue
 {
     foreach (var element in items)
     {
         base._Add(element.Key, new MasterDictionaryEntry <TValue>((ISubordinateDictionary)subordinate, element.Value));
     }
 }
示例#8
0
        /// <summary>
        /// Notifier for subordinate dictionaries
        /// indicating that the <paramref name="subordinate"/>
        /// has been cleared.
        /// </summary>
        /// <typeparam name="TSValue">
        /// The specific type of value used in the
        /// subordinate dictionary, derives from the
        /// master dictionary's <typeparamref name="TValue"/>.
        /// </typeparam>
        /// <param name="subordinate">
        /// The <see cref="ISubordinateDictionary{TSKey, TMKey, TSValue, TMValue}"/>
        /// which is a subordinate of the current
        /// <see cref="MasterDictionaryBase{TKey, TValue}"/> that was
        /// cleared.
        /// </param>
        protected internal virtual void Subordinate_Cleared <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate)
            where TSKey :
        TKey
            where TSValue :
        TValue
        {
            var clearHelper = new _RemoveHelperCache <TSKey, TSValue>(this);
            var elements    = GetSubordinateClearedItems <TSKey, TSValue>(subordinate).ToArray();

            elements.OnAll((kvp) =>
                           clearHelper.__Subordinate_Cleared__removeHelper_cache((ISubordinateDictionary <TSKey, TKey, TSValue, TValue>)kvp.Value.Subordinate, (TSKey)kvp.Key));
        }
示例#9
0
        internal TMItemIdentifier FetchKey(MasterDictionaryEntry <object> sourceElement)
        {
            if (sourceElement.Subordinate == null)
            {
                throw ThrowHelper.ObtainArgumentException(ArgumentWithException.sourceElement, ExceptionMessageId.SubordinateNull);
            }
            ISubordinateDictionary isd = sourceElement.Subordinate;

            if (!(isd is _LockedGroupDeclarationsMasterPass <TMItemIdentifier, TMItem>))
            {
                throw ThrowHelper.ObtainArgumentException(ArgumentWithException.sourceElement, ExceptionMessageId.SubordinateInvalid);
            }
            _LockedGroupDeclarationsMasterPass <TMItemIdentifier, TMItem> lgdmp = (_LockedGroupDeclarationsMasterPass <TMItemIdentifier, TMItem>)isd;

            return(lgdmp.FetchKey(sourceElement.Entry));
        }
示例#10
0
 internal virtual void AddSubordinateImpl <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate)
     where TSKey :
 TKey
     where TSValue :
 TValue
 {
     if (subordinate == null)
     {
         throw new ArgumentNullException("subordinate");
     }
     if (!(subordinate is _ISubordinateDictionaryMasterPass))
     {
         throw ThrowHelper.ObtainArgumentException(ArgumentWithException.subordinate, ExceptionMessageId.SubordinateInvalid);
     }
     foreach (ISubordinateDictionary isd in this.subordinates)
     {
         if (isd is ISubordinateDictionary <TSKey, TKey, TSValue, TValue> )
         {
             throw ThrowHelper.ObtainArgumentException(ArgumentWithException.subordinate, ExceptionMessageId.SubordinateSubTypeDuplicate);
         }
     }
     this.subordinates.Add((ISubordinateDictionary)subordinate);
 }
示例#11
0
 internal void RelateSubordinateMembers <TSItemIdentifier, TSItem>(object[] sourceData, ISubordinateDictionary <TSItemIdentifier, TMItemIdentifier, TSItem, TMItem> subordinate)
     where TSItemIdentifier :
 TMItemIdentifier
     where TSItem :
 TMItem
 {
     if (sourceData == null)
     {
         throw new ArgumentNullException("sourceData");
     }
     if (subordinate == null)
     {
         throw new ArgumentNullException(ThrowHelper.GetArgumentName(ArgumentWithException.subordinate));
     }
     if (!this.Subordinates.Contains((ISubordinateDictionary)subordinate))
     {
         throw ThrowHelper.ObtainArgumentException(ArgumentWithException.subordinate, ExceptionMessageId.SubordinateDoesNotExist);
     }
     lock (syncObject)
         if (this.state != USE_FETCH)
         {
             this.state = USE_FETCH;
         }
     if (this.sourceData == null)
     {
         this.sourceData = new List <MasterDictionaryEntry <object> >();
     }
     this.sourceData.AddRange(sourceData.OnAll(u => new MasterDictionaryEntry <object>((ISubordinateDictionary)subordinate, u)));
     if (this._fetchKeys != null)
     {
         this._fetchKeys.SetRange(this._fetchKeys.Count + sourceData.Length);
     }
     if (this._fetchValues != null)
     {
         this._fetchValues.SetRange(this._fetchValues.Count + sourceData.Length);
     }
 }
示例#12
0
 void _LockedRelativeHelper <TMItemIdentifier, TMItem> .RelateSubordinateMembers <TSItemIdentifier, TSItem, TRItem>(TRItem[] sourceData, ISubordinateDictionary <TSItemIdentifier, TMItemIdentifier, TSItem, TMItem> subordinate)
 {
     this.RelateSubordinateMembers <TSItemIdentifier, TSItem>(sourceData.Cast <object>().ToArray(), subordinate);
 }
示例#13
0
        internal override IEnumerable <KeyValuePair <TMItemIdentifier, MasterDictionaryEntry <TMItem> > > GetSubordinateClearedItems <TSKey, TSValue>(ISubordinateDictionary <TSKey, TMItemIdentifier, TSValue, TMItem> subordinate)
        {
            var values = this.valuesInstance as _ValuesCollection;

            if (values == null)
            {
                yield break;
            }
            for (int i = 0; i < this.Count; i++)
            {
                if (values.Loaded(i))
                {
                    var value = values[i];
                    if (value.Subordinate != subordinate)
                    {
                        continue;
                    }
                    if (!(value is TSValue))
                    {
                        continue;
                    }
                    yield return(new KeyValuePair <TMItemIdentifier, MasterDictionaryEntry <TMItem> >(this.Keys[i], value));
                }
            }
        }
示例#14
0
 /// <remarks>Due to compiler warning CS1911</remarks>
 public void __Subordinate_Cleared__removeHelper(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate, TSKey k)
 {
     this.master.Subordinate_ItemRemoved <TSKey, TSValue>(subordinate, k);
 }
示例#15
0
 internal virtual IEnumerable <KeyValuePair <TKey, MasterDictionaryEntry <TValue> > > GetSubordinateClearedItems <TSKey, TSValue>(ISubordinateDictionary <TSKey, TKey, TSValue, TValue> subordinate)
     where TSKey :
 TKey
     where TSValue :
 TValue
 {
     return(from kvp in this
            where kvp.Value.Subordinate == subordinate &&
            kvp.Value.Entry is TValue &&
            kvp.Key is TSKey
            select kvp);
 }
示例#16
0
            public IEnumerator <MasterDictionaryEntry <IMember> > GetEnumerator()
            {
                ISubordinateDictionary bops    = null,
                                       ctors   = null,
                                       evts    = null,
                                       fields  = null,
                                       methods = null,
                                       props   = null,
                                       typeCs  = null,
                                       unops   = null,
                                       indxrs  = null;

                for (int memberIndex = 0; memberIndex < this.Count; memberIndex++)
                {
                    if (this.owner.members[memberIndex] == null)
                    {
                        this.owner.CheckItemAt(memberIndex);
                    }
                    switch (this.owner.memberTypes[memberIndex])
                    {
                    case CliMemberType.BinaryOperator:
                        yield return(new MasterDictionaryEntry <IMember>(bops ?? (bops = this.owner.parent.BinaryOperators), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Constructor:
                        yield return(new MasterDictionaryEntry <IMember>(ctors ?? (ctors = this.owner.parent.Constructors), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Event:
                        yield return(new MasterDictionaryEntry <IMember>(evts ?? (evts = this.owner.parent.Events), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Field:
                        yield return(new MasterDictionaryEntry <IMember>(fields ?? (fields = this.owner.parent.Fields), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Method:
                        yield return(new MasterDictionaryEntry <IMember>(methods ?? (methods = this.owner.parent.Methods), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Property:
                        yield return(new MasterDictionaryEntry <IMember>(props ?? (props = this.owner.parent.Properties), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.Indexer:
                        yield return(new MasterDictionaryEntry <IMember>(indxrs ?? (indxrs = this.owner.parent.Indexers), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.TypeCoercionOperator:
                        yield return(new MasterDictionaryEntry <IMember>(typeCs ?? (typeCs = this.owner.parent.TypeCoercions), this.owner.members[memberIndex]));

                        break;

                    case CliMemberType.UnaryOperator:
                        yield return(new MasterDictionaryEntry <IMember>(unops ?? (unops = this.owner.parent.UnaryOperators), this.owner.members[memberIndex]));

                        break;
                    }
                }
            }