Пример #1
0
 /// <summary>
 /// protected method allow the inheritor to add many types at once
 /// </summary>
 /// <param name="types"></param>
 protected void AddTypes(IEnumerable <Type> types)
 {
     using (var l = new WriteLock(_lock))
     {
         foreach (var t in types)
         {
             EnsureCorrectType(t);
             if (InstanceTypes.Contains(t))
             {
                 throw new InvalidOperationException("The Type " + t + " already exists in the collection");
             }
             ;
             InstanceTypes.Add(t);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Adds a Type to the end of the list.
        /// </summary>
        /// <param name="value">The object to be added.</param>
        public virtual void AddType(Type value)
        {
            EnsureAddSupport();

            EnsureResolutionNotFrozen();

            using (GetWriteLock())
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;
                _instanceTypes.Add(value);
            }
        }
Пример #3
0
        /// <summary>
        /// Adds a Type to the end of the list.
        /// </summary>
        /// <param name="value">The object to be added.</param>
        public void AddType(Type value)
        {
            if (!SupportsAdd)
            {
                throw new InvalidOperationException("This resolver does not support Adding new types");
            }

            using (var l = new WriteLock(_lock))
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;
                InstanceTypes.Add(value);
            }
        }
Пример #4
0
        /// <summary>
        /// Inserts a Type at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which the object should be inserted.</param>
        /// <param name="value">The object to insert.</param>
        public void InsertType(int index, Type value)
        {
            if (!SupportsInsert)
            {
                throw new InvalidOperationException("This resolver does not support Inserting new types");
            }

            using (var l = new UpgradeableReadLock(_lock))
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;

                l.UpgradeToWriteLock();
                InstanceTypes.Insert(index, value);
            }
        }
Пример #5
0
        /// <summary>
        /// protected method allow the inheritor to add many types at once
        /// </summary>
        /// <param name="types"></param>
        protected void AddTypes(IEnumerable <Type> types)
        {
            EnsureAddSupport();

            EnsureResolutionNotFrozen();

            using (GetWriteLock())
            {
                foreach (var t in types)
                {
                    EnsureCorrectType(t);
                    if (InstanceTypes.Contains(t))
                    {
                        throw new InvalidOperationException("The Type " + t + " already exists in the collection");
                    }
                    ;
                    _instanceTypes.Add(t);
                }
            }
        }