System.Type.GetProperty C# (CSharp) Method

GetProperty() public method

Searches for the specified public property whose parameters match the specified argument types and modifiers.
More than one property is found with the specified name and matching the specified argument types and modifiers. is null.-or- is null. is multidimensional.-or- is multidimensional.-or- and do not have the same length. An element of is null.
public GetProperty ( string name, Type returnType, Type types, ParameterModifier modifiers ) : PropertyInfo
name string The string containing the name of the public property to get.
returnType Type The return type of the property.
types Type An array of objects representing the number, order, and type of the parameters for the indexed property to get.-or- An empty array of the type (that is, Type[] types = new Type[0]) to get a property that is not indexed.
modifiers ParameterModifier An array of objects representing the attributes associated with the corresponding element in the array. The default binder does not process this parameter.
return PropertyInfo
        public PropertyInfo GetProperty(string name, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (types == null)
                throw new ArgumentNullException("types");
            else
                return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder)null, returnType, types, modifiers);
        }

Same methods

Type::GetProperty ( string name ) : PropertyInfo
Type::GetProperty ( string name, BindingFlags bindingAttr ) : PropertyInfo
Type::GetProperty ( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type types, ParameterModifier modifiers ) : PropertyInfo
Type::GetProperty ( string name, BindingFlags bindingAttr, Type returnType ) : PropertyInfo
Type::GetProperty ( string name, Type types ) : PropertyInfo
Type::GetProperty ( string name, Type returnType, Type types ) : PropertyInfo

Usage Example

Ejemplo n.º 1
5
 /// <summary>
 /// Создает на основе типа фильтр
 /// </summary>
 /// <param name="lib"></param>
 /// <param name="type"></param>
 public Filter(string lib, Type type)
 {
     libname = lib;
     if (type.BaseType == typeof(AbstractFilter))
     {
         Exception fullex = new Exception("");
         ConstructorInfo ci = type.GetConstructor(System.Type.EmptyTypes);
         filter = ci.Invoke(null);
         PropertyInfo everyprop;
         everyprop = type.GetProperty("Name");
         name = (string)everyprop.GetValue(filter, null);
         everyprop = type.GetProperty("Author");
         author = (string)everyprop.GetValue(filter, null);
         everyprop = type.GetProperty("Ver");
         version = (Version)everyprop.GetValue(filter, null);
         help = type.GetMethod("Help");
         MethodInfo[] methods = type.GetMethods();
         filtrations = new List<Filtration>();
         foreach (MethodInfo mi in methods)
             if (mi.Name == "Filter")
             {
                 try
                 {
                     filtrations.Add(new Filtration(mi));
                 }
                 catch (TypeLoadException)
                 {
                     //Не добавляем фильтрацию.
                 }
             }
         if (filtrations == null) throw new TypeIncorrectException("Класс " + name + " не содержит ни одной фильтрации");
     }
     else
         throw new TypeLoadException("Класс " + type.Name + " не наследует AbstractFilter");
 }
All Usage Examples Of System.Type::GetProperty