/// <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); } } }
/// <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); } }