Inheritance: IFieldInfoList, IList, ICloneable
コード例 #1
0
			public override void AddRange(FieldInfoCollection collection)
			{
				throw new NotSupportedException("Read-only collections cannot be modified.");
			}
コード例 #2
0
		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="FieldInfoCollection"/> class that
		/// contains elements copied from the specified collection and that
		/// has the same initial capacity as the number of elements copied.
		/// </summary>
		/// <param name="collection">
		/// The <see cref="FieldInfoCollection"/>
		/// whose elements are copied to the new collection.</param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="collection"/> is a null reference.</exception>
		/// <remarks>
		/// Please refer to <see cref="ArrayList(ICollection)"/> for details.
		/// </remarks>
		public FieldInfoCollection(FieldInfoCollection collection)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");

			_data = new Data();
			_data.Items = new FieldInfo[collection.Count];
			AddRange(collection._data.Items, collection.Count);
		}
コード例 #3
0
		/// <summary>
		/// Returns a read-only wrapper for the specified
		/// <see cref="FieldInfoCollection"/>.
		/// </summary>
		/// <param name="collection">
		/// The <see cref="FieldInfoCollection"/> to wrap.</param>
		/// <returns>
		/// A read-only wrapper around <paramref name="collection"/>.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="collection"/> is a null reference.</exception>
		/// <remarks>
		/// Please refer to <see cref="ArrayList.ReadOnly(IList)"/> for details.
		/// </remarks>
		public static FieldInfoCollection ReadOnly(FieldInfoCollection collection)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");

			return new ReadOnlyWrapper(collection._data);
		}
コード例 #4
0
		/// <summary>
		/// Creates a shallow copy of the <see cref="FieldInfoCollection"/>.
		/// </summary>
		/// <returns>
		/// A shallow copy of the <see cref="FieldInfoCollection"/>.
		/// </returns>
		/// <remarks>
		/// Please refer to <see cref="ArrayList.Clone"/> for details.
		/// </remarks>
		public virtual object Clone()
		{
			FieldInfoCollection clone = new FieldInfoCollection(_data.Count);

			Array.Copy(_data.Items, 0, clone._data.Items, 0, _data.Count);
			clone._data.Count = _data.Count;
			clone._data.IsUnique = _data.IsUnique;

			return clone;
		}
コード例 #5
0
		/// <overloads>
		/// Adds a range of elements to the end of the
		/// <see cref="FieldInfoCollection"/>.
		/// </overloads>
		/// <summary>
		/// Adds the elements of another collection to the end of the
		/// <see cref="FieldInfoCollection"/>.
		/// </summary>
		/// <param name="collection">
		/// The <see cref="FieldInfoCollection"/> whose elements
		/// should be added to the end of the current collection.</param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="collection"/> is a null reference.</exception>
		/// <exception cref="NotSupportedException"><para>
		/// The <see cref="FieldInfoCollection"/> 
		/// is read-only or has a fixed size.
		/// </para><para>-or-</para><para>
		/// The <b>FieldInfoCollection</b> already contains one
		/// or more elements in <paramref name="collection"/>,
		/// and the <b>FieldInfoCollection</b>
		/// ensures that all elements are unique.
		/// </para></exception>
		/// <remarks>
		/// Please refer to <see cref="ArrayList.AddRange"/> for details.
		/// </remarks>
		public virtual void AddRange(FieldInfoCollection collection)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");

			AddRange(collection._data.Items, collection.Count);
		}
コード例 #6
0
ファイル: ReflectionUtil.cs プロジェクト: RookieX/Windsor
		/// <summary>
		/// Gets all the fields WITHOUT ANY of the specified attributes.
		/// </summary>
		public static FieldInfoCollection GetFieldsWithOutAttributes(Type type, params Type[] types)
		{
			FieldInfoCollection fields = new FieldInfoCollection();

			bool match;
			foreach (FieldInfo field in type.GetFields())
			{
				match = true;
				foreach (Type attType in types)
				{
					if (field.GetCustomAttributes(attType, true).Length != 0)
						match = false;
				}
				if (match)
					fields.Add(field);
			}

			return fields;
		}
コード例 #7
0
ファイル: ReflectionUtil.cs プロジェクト: RookieX/Windsor
		/// <summary>
		/// Gets all the fields from the object's type with specified attribute
		/// </summary>
		public static FieldInfoCollection GetFieldsWithAttribute(Type type, Type attribute)
		{
			FieldInfoCollection fields = new FieldInfoCollection();
			foreach (FieldInfo field in type.GetFields())
			{
				if (field.GetCustomAttributes(attribute, true).Length > 0)
					fields.Add(field);
			}
			return fields;
		}