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


C# PropertyInfo.GetIndexParameters方法代码示例

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


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

示例1: GetMemberID

		/// <summary>
		/// 
		/// </summary>
		/// <param name="property"></param>
		/// <returns></returns>
		public static string GetMemberID(PropertyInfo property)
		{
			string memberName;

			memberName = "P:" + GetFullNamespaceName(property) +
				"." + property.Name.Replace('.', '#').Replace('+', '#');

			try
			{
				if (property.GetIndexParameters().Length > 0)
				{
					memberName += "(";

					int i = 0;

					foreach (ParameterInfo parameter in property.GetIndexParameters())
					{
						if (i > 0)
						{
							memberName += ",";
						}

						Type type = parameter.ParameterType;

#if NET_2_0
                        if (type.ContainsGenericParameters && type.IsGenericParameter)
                        {
                            memberName += "`" + type.GenericParameterPosition.ToString();
                        }
                        else if (type.FullName != null)
                        {
                            memberName += type.FullName;
                        }
                        else
                        {
                            memberName += type.Name;
                        }
#else
						memberName += type.FullName;
#endif

						++i;
					}

					memberName += ")";
				}
			}
			catch (System.Security.SecurityException) { }

			return memberName;
		}
开发者ID:tgassner,项目名称:NDoc,代码行数:56,代码来源:MemberID.cs

示例2: PropertyHasValue

		/// <summary>
		/// Check if the property is not null and can be read and is no indexed.
		/// This is done to know if it can be read safely.
		/// </summary>
		/// <param name="obj">Obj.</param>
		/// <param name="prop">Prop.</param>
		/// <returns></returns>
		private static bool PropertyHasValue(object obj, PropertyInfo prop)
		{
			if (obj == null || prop == null || !prop.CanRead || prop.GetIndexParameters().Length > 0)
				return false;
			else
				return true;
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:14,代码来源:ReflectionUtil.cs

示例3: IsAValidProperty

 private static bool IsAValidProperty(PropertyInfo propertyInfo)
 {
     if (!propertyInfo.CanRead) return false;
     if (!propertyInfo.CanWrite) return false;
     if (propertyInfo.GetIndexParameters().Length > 0) return false;
     return true;
 }
开发者ID:ahmedowsky,项目名称:Ahmedowsky,代码行数:7,代码来源:TypeEnumerator.cs

示例4: GetPropertySetter

        internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type type)
        {
            if (propertyInfo.DeclaringType == type) return propertyInfo.GetSetMethod(true);
#if NETSTANDARD1_3
            return propertyInfo.DeclaringType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                    .Single(x => x.Name == propertyInfo.Name
                        && x.PropertyType == propertyInfo.PropertyType
                        && IsParameterMatch(x.GetIndexParameters(), propertyInfo.GetIndexParameters())
                        ).GetSetMethod(true);
#else
            return propertyInfo.DeclaringType.GetProperty(
                   propertyInfo.Name,
                   BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                   Type.DefaultBinder,
                   propertyInfo.PropertyType,
                   propertyInfo.GetIndexParameters().Select(p => p.ParameterType).ToArray(),
                   null).GetSetMethod(true);
#endif
        }
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:19,代码来源:DefaultTypeMap.cs

示例5: CanRead

 public bool CanRead(ReflectedInstance value, Type type, PropertyInfo property)
 {
     // verify if property is "this[int i]", in real use is: "myList[0]', exclude array objects
     // because if array is multidimensional will happen a error when call
     // "property.GetValue(obj, new object[] { 0, 0 });" the class "PropertyReaderIndexerInArray" fix it.
     var parameters = property.GetIndexParameters();
     //
     return (parameters.Length == 1)
         && (parameters[0].ParameterType == typeof(int));
 }
开发者ID:juniorgasparotto,项目名称:ExpressionGraph,代码行数:10,代码来源:PropertyReaderIndexerInt32InAnyClass.cs

示例6: HasGetter

        private static bool HasGetter(PropertyInfo prop)
        {
            if (!prop.CanRead)
                return false;

            if (!ArrayUtil.IsNullOrEmpty(prop.GetIndexParameters()))
                return false;

            return true;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:10,代码来源:ReflectionUtil.cs

示例7: GetValues

        public IEnumerable<MethodValue> GetValues(ReflectedInstance value, Type type, PropertyInfo property)
        {
            var dictionary = value.Object as IDictionary;
            var parameters = property.GetIndexParameters();

            foreach (var key in dictionary.Keys)
            {
                var parameter = new MethodValueParam(parameters[0].Name, parameters[0], key);
                yield return new MethodValue(dictionary[key], parameter);
            }
        }
开发者ID:juniorgasparotto,项目名称:ExpressionGraph,代码行数:11,代码来源:PropertyReaderIndexerInDictionary.cs

示例8: GetAssetId

        public static string GetAssetId(PropertyInfo propertyInfo)
        {
            ParameterInfo[] p = propertyInfo.GetIndexParameters();
            if (p.Length == 0)
                return string.Format("P:{0}.{1}", GetTypeName(propertyInfo.ReflectedType), propertyInfo.Name);

            return string.Format("P:{0}.{1}{2}",
                                 GetTypeName(propertyInfo.ReflectedType),
                                 propertyInfo.Name,
                                 CreateParameterSignature(propertyInfo, p.Select(pr => pr.ParameterType).ToArray()));
        }
开发者ID:LBi-Dick,项目名称:LBi.LostDoc,代码行数:11,代码来源:Naming.cs

示例9: GetId

        public static string GetId(PropertyInfo property)
        {
            var parameters = string.Join(",", property.GetIndexParameters().Select(x => GetTypeName(x.ParameterType)));

            if (!string.IsNullOrEmpty(parameters))
            {
                parameters = "(" + parameters + ")";
            }

            return string.Format(CultureInfo.InvariantCulture, "P:{0}.{1}{2}", GetTypeName(property.ReflectedType), HashEncode(property.Name), parameters);
        }
开发者ID:anderskaplan,项目名称:NuDoc,代码行数:11,代码来源:SlashdocIdentifierProvider.cs

示例10: ToSignature

 internal static string ToSignature (PropertyInfo pi)
 {
     StringBuilder sb = new StringBuilder ();
     sb.Append (ToSignature (pi.PropertyType));
     sb.Append (" ");
     sb.Append (ToSignature (pi.DeclaringType));
     sb.Append (".");
     sb.Append (pi.Name);
     sb.Append (ToSignature ('[', pi.GetIndexParameters (), ']'));
     return sb.ToString ();
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:11,代码来源:CliHelper.cs

示例11: IsCandidateProperty

        private bool IsCandidateProperty(PropertyInfo property)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            return property.CanWrite &&
                property.GetIndexParameters().Length == 0 &&
                IsSupportedPropertyType(property.PropertyType);
        }
开发者ID:leloulight,项目名称:Scaffolding,代码行数:11,代码来源:ActionDescriptor.cs

示例12: UseWhen

        public override bool UseWhen()
        {
            _info = PropertyInfoHelper.GetIndexerPropertyInfo(TargetType, ColumnName);

            if (_info == null)
                return false;

            var parameterType = _info.GetIndexParameters().First().ParameterType;
            _lookUp = Convert.ChangeType(ColumnName, parameterType);

            return true;
        }
开发者ID:ITAGroup,项目名称:SpecAid,代码行数:12,代码来源:IndexerCompareAction.cs

示例13: Match

 public override Boolean Match(PropertyInfo sourceProperty, PropertyInfo targetProperty)
 {
     if (sourceProperty.Name == "Item")
     {
         var pp = sourceProperty.GetIndexParameters();
         //source["key1"]
         if (pp.Length == 1 && pp[0].ParameterType == typeof(String))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:fengweijp,项目名称:higlabo,代码行数:13,代码来源:DictionaryToObjectMappingRule.cs

示例14: GetIndexerTypes

        private static Type[] GetIndexerTypes(PropertyInfo property)
        {
            var indexerParameters = property.GetIndexParameters();

            var result = new Type[indexerParameters.Length];

            for (var i = 0; i < indexerParameters.Length; i++)
            {
                result[i] = indexerParameters[i].ParameterType;
            }

            return result;
        }
开发者ID:bradleyjford,项目名称:inception,代码行数:13,代码来源:PropertyMetadata.cs

示例15: Build

 public static ExpressionTypeMemberDescriptor Build(PropertyInfo p)
 {
     ExpressionTypeMemberDescriptor md = new ExpressionTypeMemberDescriptor
     {
         Kind = "property",
         Name = p.Name,
         ReturnType = p.PropertyType.Name,
         ReturnExpressionType = p.PropertyType.AssemblyQualifiedName
     };
     md.Parameters = (
         from mdp in p.GetIndexParameters()
         select Build(mdp)).ToList();
     return md;
 }
开发者ID:garysharp,项目名称:Disco,代码行数:14,代码来源:ExpressionTypeMemberDescriptor.cs


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