当前位置: 首页>>代码示例>>C#>>正文


C# IReflect.GetProperty方法代码示例

本文整理汇总了C#中IReflect.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IReflect.GetProperty方法的具体用法?C# IReflect.GetProperty怎么用?C# IReflect.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReflect的用法示例。


在下文中一共展示了IReflect.GetProperty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPropertyCaseInsensitive

        private static PropertyInfo GetPropertyCaseInsensitive(IReflect type, string propertyName)
        {
            // make the property reflection lookup case insensitive
            const BindingFlags bindingFlags = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

            return type.GetProperty(propertyName, bindingFlags);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:7,代码来源:DefaultRepositoryConventions.cs

示例2: LookupResource

 public static string LookupResource(IReflect resourceManagerProvider, string resourceKey)
 {
     PropertyInfo property = resourceManagerProvider.GetProperty(resourceKey, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
     // Fallback with the key name
     if (property == null)
         return resourceKey;
     return (string) property.GetValue(null, null); // returns string directly from res file
 }
开发者ID:denkhaus,项目名称:WPG,代码行数:8,代码来源:LocalizationResourceHelper.cs

示例3: GetArray

 private string GetArray(IReflect reflect)
 {
     PropertyInfo piLength = reflect.GetProperty("length", BindingFlags.Default);
     int len = (int)piLength.GetValue(reflect, null);
     string[] ret = new string[len];
     for (int i = 0; i < len; i++) {
         PropertyInfo pi = reflect.GetProperty(i.ToString(), BindingFlags.Default);
         object item;
         if (pi == null) {
             item = null;
         }
         else {
             item = pi.GetValue(reflect, null);
         }
         ret[i] = GetString(item);
     }
     return string.Format("[ {0} ]", string.Join(", ", ret));
 }
开发者ID:JimmyJune,项目名称:DotWeb,代码行数:18,代码来源:JsConsole.cs

示例4: GetMember

        private static MemberInfo GetMember(IReflect entityType, string[] memberNames)
        {
            var publicProperties =
                from name in memberNames
                select entityType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public) into propertyInfo
                where propertyInfo != null && IsPropertyOk(propertyInfo)
                select propertyInfo;

            var privateProperties =
                from name in memberNames
                select entityType.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic) into propertyInfo
                where propertyInfo != null && IsPropertyOk(propertyInfo)
                select propertyInfo;

            var publicFields =
                from name in memberNames
                select entityType.GetField(name, BindingFlags.Instance | BindingFlags.Public) into fieldInfo
                where fieldInfo != null && IsFildOk(fieldInfo)
                select fieldInfo;

            return publicProperties.OfType<MemberInfo>().Concat(privateProperties).Concat(publicFields).FirstOrDefault();
        }
开发者ID:artikh,项目名称:CouchDude,代码行数:22,代码来源:ParticularyNamedPropertyOrPubilcFieldSpecialMember.cs

示例5: GetAndWrapMember

 private static MemberInfo[] GetAndWrapMember(IReflect reflect, Object namedItem, String name, BindingFlags bindingAttr){
   PropertyInfo property = reflect.GetProperty(name, bindingAttr);
   if (property != null){
     MethodInfo getMethod = JSProperty.GetGetMethod(property, false);
     MethodInfo setMethod = JSProperty.GetSetMethod(property, false);
     if ((getMethod != null && !getMethod.IsStatic) || (setMethod != null && !setMethod.IsStatic)){
       MethodInfo method = reflect.GetMethod(name, bindingAttr);
       if (method != null && !method.IsStatic){
         MemberInfo[] propMethods = new MemberInfo[1];
         propMethods[0] = new JSWrappedPropertyAndMethod(property, method, namedItem);
         return propMethods;
       }
     }
   }
   MemberInfo[] members = reflect.GetMember(name, bindingAttr);
   if (members != null && members.Length > 0)
     return ScriptObject.WrapMembers(members, namedItem);
   return null;
 }
开发者ID:ArildF,项目名称:masters,代码行数:19,代码来源:vsanameditemscope.cs

示例6: GetAndWrapMember

 private static MemberInfo[] GetAndWrapMember(IReflect reflect, object namedItem, string name, BindingFlags bindingAttr)
 {
     PropertyInfo property = reflect.GetProperty(name, bindingAttr);
     if (property != null)
     {
         MethodInfo getMethod = JSProperty.GetGetMethod(property, false);
         MethodInfo setMethod = JSProperty.GetSetMethod(property, false);
         if (((getMethod != null) && !getMethod.IsStatic) || ((setMethod != null) && !setMethod.IsStatic))
         {
             MethodInfo method = reflect.GetMethod(name, bindingAttr);
             if ((method != null) && !method.IsStatic)
             {
                 return new MemberInfo[] { new JSWrappedPropertyAndMethod(property, method, namedItem) };
             }
         }
     }
     MemberInfo[] member = reflect.GetMember(name, bindingAttr);
     if ((member != null) && (member.Length > 0))
     {
         return ScriptObject.WrapMembers(member, namedItem);
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:VsaNamedItemScope.cs

示例7: SetProperty

        /// <summary>
        /// Sets the property.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="strMethod">The STR method.</param>
        /// <param name="objInstance">The obj instance.</param>
        /// <param name="eFlags">The e flags.</param>
        /// <param name="setValue">The set value.</param>
        /// <param name="index">The index.</param>
        /// <returns></returns>
        private static object SetProperty(IReflect type, string strMethod, object objInstance, BindingFlags eFlags, object setValue, object[] index)
        {
            PropertyInfo property;
            try
            {
                if ((eFlags == InstanceBindingFlags) && (objInstance == null))
                {
                    throw new ArgumentException("The reflection non-static object argument was invalid");
                }
                if ((eFlags == StaticBindingFlags) && (objInstance != null))
                {
                    throw new ArgumentException("The reflection static object argument was invalid");
                }
                if ((objInstance != null) && (objInstance.GetType() != (Type)type) && (objInstance.GetType().BaseType != (Type)type))
                {
                    throw new ArgumentException("The object instance was of type '" + objInstance.GetType() + "' for type '" + type + "'.");
                }
                if (string.IsNullOrEmpty(strMethod))
                {
                    throw new ArgumentException("The reflection method argument was invalid");
                }
                property = type.GetProperty(strMethod, eFlags);
                if (property == null)
                {
                    throw new ArgumentException("There is no property '" + strMethod + "' for type '" + type + "'.");
                }
                if (setValue.GetType() != property.PropertyType)
                {
                    throw new ArgumentException("The value instance was of type '" + setValue.GetType() + "' for field type '" + property.PropertyType + "'.");
                }

                property.SetValue(objInstance, setValue, index);
                var objRet = property.GetValue(objInstance, index);
                return objRet;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
开发者ID:Guzikowski,项目名称:TestMania,代码行数:51,代码来源:ReflectionTestHelper.cs

示例8: SetAuthId

        private bool SetAuthId(IReflect t, dynamic o)
        {
            var mustAuth = t.GetProperty("MustAuth", BindingFlags.Public | BindingFlags.Instance);
            if (mustAuth != null)
            {
                if (Sorted.ContainsKey("session"))
                {
                    _authorizedId = GetUserId(YunWebUtils.FromBase64StringForUrl(Sorted["session"]));
                    if (_authorizedId > 0)
                    {
                        var authId = t.GetProperty("AuthId", BindingFlags.Public | BindingFlags.Instance);
                        if (authId != null)
                        {
                            o.AuthId = _authorizedId;
                            //authId.SetValue(o, Convert.ChangeType(_authorizedId, TypeCode.Int32), null);
                            return true;
                        }
                    }
                }

                //return !(bool)mustAuth.GetValue(o, null);
                return !o.MustAuth;
            }

            return true;
        }
开发者ID:summer-breeze,项目名称:SummerBreezeShop,代码行数:26,代码来源:YunRequest.cs

示例9: GetSetPropertyInfo

        private static PropertyInfo GetSetPropertyInfo(IReflect actionType, string propertyName, string actionId)
        {
            var propertyInfo = actionType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.IgnoreCase);

            if (propertyInfo == null || (propertyInfo.SetMethod.Attributes & MethodAttributes.Public) != MethodAttributes.Public)
            {
                throw new InvalidDataException(
                    string.Format(
                        "Add-on '{0}' doesn't implement public setter for property '{1}' but input property is required for action '{2}'.", 
                        actionType, 
                        propertyName, 
                        actionId));
            }

            return propertyInfo;
        }
开发者ID:HansKindberg-Net,项目名称:TFS-Branch-Tool,代码行数:16,代码来源:ActionExecutionEngine.cs

示例10: GetAs

 private static object GetAs(IReflect type, object obj, string prop)
 {
     var propInfo = type.GetProperty(prop, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     return propInfo.GetValue(obj, null);
 }
开发者ID:roman5566,项目名称:WAYGui,代码行数:5,代码来源:FolderSelectDialog.cs


注:本文中的IReflect.GetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。