Add() 공개 메소드

Adds a FieldInfo to the end of the FieldInfoCollection.
Please refer to ArrayList.Add for details.
/// The /// is read-only or has a fixed size. /// -or- /// The FieldInfoCollection /// already contains , /// and the FieldInfoCollection /// ensures that all elements are unique.
public Add ( FieldInfo value ) : int
value System.Reflection.FieldInfo /// The object to be added /// to the end of the . /// This argument may be a null reference. ///
리턴 int
예제 #1
0
		/// <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;
		}
예제 #2
0
		/// <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;
		}