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


C# MemberInfo.GetType方法代码示例

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


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

示例1: GetMemberValue

 /// <summary> Vrátí hodnotu fieldu nebo propertry objektu. </summary>
 /// <param name="member"> Popis fieldu nebo property. </param>
 /// <param name="obj"> Objekt. </param>
 /// <returns> Hodnota fieldu nebo property. </returns>
 public static object GetMemberValue ( MemberInfo member, object obj )
 {
   if ( member is FieldInfo )
     return ((FieldInfo)member).GetValue( obj );
   else if ( member is PropertyInfo )
     return ((PropertyInfo)member).GetValue( obj, null );
   else
     throw new Exception( string.Format( "OtherCode.GetMemberValue: unsupported member type '{0}', class '{1}'", member.GetType(), obj.GetType() ) );
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:13,代码来源:Other.cs

示例2: GetMemberType

 /// <summary> Vrátí typ fieldu nebo property objektu. </summary>
 /// <param name="member"> Popis fieldu nebo property. </param>
 /// <returns> Typ fieldu nebo property. </returns>
 public static Type GetMemberType ( MemberInfo member )
 {
   if ( member is FieldInfo )
     return ((FieldInfo)member).FieldType;
   else if ( member is PropertyInfo )
     return ((PropertyInfo)member).PropertyType;
   else
     throw new Exception( string.Format( "OtherCode.GetMemberType: unsupported member type '{0}'", member.GetType() ) );
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:12,代码来源:Other.cs

示例3: SetMemberValue

 /// <summary> Nastaví hodnotu fieldu nebo propertry objektu. </summary>
 /// <param name="member"> Popis fieldu nebo property. </param>
 /// <param name="obj"> Objekt. </param>
 /// <param name="value"> Nastavovaná hodnota. </param>
 public static void SetMemberValue ( MemberInfo member, object obj, object value )
 {
   if ( member is FieldInfo )
     ((FieldInfo)member).SetValue( obj, value );
   else if ( member is PropertyInfo )
     ((PropertyInfo)member).SetValue( obj, value, null );
   else
     throw new Exception( string.Format( "OtherCode.SetMemberValue: unsupported member type '{0}', class '{1}', value '{2}'", member.GetType(), obj.GetType(), value.GetType() ) );
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:13,代码来源:Other.cs

示例4: IsMemberEqual

		// Compares two members.  The .Equals method on the member
		// does not work since the ReflectedType for the members might
		// be different and we don't care about that.
		internal static bool IsMemberEqual(MemberInfo m1,
										   MemberInfo m2)
		{
			if (!m1.GetType().Equals(m1.GetType()))
				return false;
			if (!m1.DeclaringType.Equals(m2.DeclaringType))
				return false;
			if (!m1.Name.Equals(m2.Name))
				return false;

			// All but constructors and methods are equal at this point
			if (!(m1 is MethodBase))
				return true;

			// The method handles check that the methods are actually
			// the same
			if (((MethodBase)m1).MethodHandle.
				Equals(((MethodBase)m2).MethodHandle))
				return true;
			return false;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:24,代码来源:ReflectionHelper.cs

示例5: GetMemberType

 internal Type GetMemberType(MemberInfo objMember)
 {
     if (objMember is FieldInfo)
     {
         return ((FieldInfo) objMember).FieldType;
     }
     if (!(objMember is PropertyInfo))
     {
         throw new SerializationException(Environment.GetResourceString("Serialization_SerMemberInfo", new object[] { objMember.GetType() }));
     }
     return ((PropertyInfo) objMember).PropertyType;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:WriteObjectInfo.cs

示例6: GetMemberType

 internal Type GetMemberType(MemberInfo objMember)
 {
     if (objMember is FieldInfo)
     {
         return ((FieldInfo) objMember).FieldType;
     }
     if (!(objMember is PropertyInfo))
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SerMemberInfo"), new object[] { objMember.GetType() }));
     }
     return ((PropertyInfo) objMember).PropertyType;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:WriteObjectInfo.cs

示例7: Create

        public static MemberAccessor Create(MemberInfo memberInfo, bool requiresSetter)
        {
            FieldInfo fieldInfo;
            PropertyInfo propertyInfo;
            if ((fieldInfo = memberInfo as FieldInfo) != null)
            {
                return new FieldMemberAccessor(fieldInfo);
            }
            else if ((propertyInfo = memberInfo as PropertyInfo) != null)
            {
                return new PropertyMemberAccessor(propertyInfo, requiresSetter);
            }

            throw new NotSupportedException(memberInfo.GetType().ToString());
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:15,代码来源:MemberAccessor.cs

示例8: MemberMapInfo

        internal MemberMapInfo(MemberInfo member, string columnName, SqlType columnType, bool nullable, ConstraintMapInfo[] constraints)
        {
            Member = member;
            ColumnName = columnName;
            ColumnType = columnType;
            IsNullable = nullable;
            Constraints = constraints;

            if (member is PropertyInfo) {
                MemberType = ((PropertyInfo) member).PropertyType;
            } else if (member is FieldInfo) {
                MemberType = ((FieldInfo) member).FieldType;
            } else {
                throw new ArgumentException(String.Format("Member of type '{0}' is not permitted.", member.GetType()));
            }
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:16,代码来源:MemberMapInfo.cs

示例9: Create

        public static IReflectionAccessor Create(MemberInfo memberInfo)
        {
            var propInfo = memberInfo as PropertyInfo;
            if (propInfo != null)
            {
                return new PropertyInfoAccessor(propInfo);
            }

            var fieldInfo = memberInfo as FieldInfo;
            if (fieldInfo != null)
            {
                return new FieldInfoAccessor(fieldInfo);
            }

            throw new ArgumentException("invalid member info:" + memberInfo.GetType());
        }
开发者ID:neuecc,项目名称:LINQ-to-BigQuery,代码行数:16,代码来源:ReflectionAccessor.cs

示例10: GetMemberType

        protected static Type GetMemberType(MemberInfo memberInfo)
        {
            var propertyInfo = memberInfo as PropertyInfo;
            var fieldInfo = memberInfo as FieldInfo;

            if (propertyInfo != null)
            {
                return propertyInfo.PropertyType;
            }

            if (fieldInfo != null)
            {
                return fieldInfo.FieldType;
            }

            throw new NotSupportedException(string.Format("{0} not supported", memberInfo.GetType().Name));
        }
开发者ID:andyvans,项目名称:BinarySerializer,代码行数:17,代码来源:ContainerTypeNode.cs

示例11: GetObjectMemberValue

        /// <summary>
        /// Gets the object member value.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="member">The member.</param>
        /// <returns>The value of object member.</returns>
        /// <exception cref="ArgumentException">If <paramref name="member"/> is of unknown type.</exception>
        public object GetObjectMemberValue(object data, MemberInfo member)
        {
            object ret;
            if (member is PropertyInfo)
            {
                PropertyInfo propInfo = (PropertyInfo)member;
                ret = propInfo.GetValue(data, null);
            }
            else if (member is FieldInfo)
            {
                FieldInfo fieldInfo = (FieldInfo)member;
                ret = fieldInfo.GetValue(data);
            }
            else
            {
                // Unknown member type - throw it away
                string message = "Unknown type of member: " + (null == member ? "(null)" : member.GetType().FullName);
                Log.Error(message);
                throw new ArgumentException(message, "member");
            }

            return ret;
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:30,代码来源:ObjectReflectionProcessor.cs

示例12: GetGetterFast

        // ashmind: this method is a bit too hardcoded, on the other hand it does not make
        // sense to ask IPropertyAccessor to find accessor by name when we already have MemberInfo
        private IGetter GetGetterFast(Type type, MemberInfo member)
        {
            if (member is PropertyInfo)
                return new BasicPropertyAccessor.BasicGetter(type, (PropertyInfo)member, member.Name);

            if (member is FieldInfo)
                return new FieldAccessor.FieldGetter((FieldInfo)member, type, member.Name);

            throw new ArgumentException("Can not get getter for " + member.GetType() + ".", "member");
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:12,代码来源:AttributeSearchMappingBuilder.cs

示例13: ToSignature

 internal static string ToSignature(MemberInfo mi)
 {
     if (mi is PropertyInfo)
         return ToSignature ((PropertyInfo)mi);
     if (mi is FieldInfo)
         return ToSignature ((FieldInfo)mi);
     if (mi is ConstructorInfo)
         return ToSignature ((ConstructorInfo)mi);
     if (mi is MethodInfo)
         return ToSignature ((MethodInfo)mi);
     return "[unknown: " + mi.GetType ().FullName + "]";
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:12,代码来源:CliHelper.cs

示例14: IsDynamic

		/// <summary>Checks if the given member is from a class being compiled at the moment.</summary>
		/// <param name="member">The member to check.</param>
		/// <returns>True if the member is from a dynamic type (one being compiled); false otherwise.</returns>
		public static bool IsDynamic(MemberInfo member){
			Type t=member.GetType();
			return (t==typeof(MethodBuilder)||t==typeof(FieldBuilder)||t==typeof(ConstructorBuilder)||t==typeof(TypeBuilder)||t==typeof(LocalBuilder)||t==typeof(PropertyBuilder)||t==typeof(ParameterBuilder));
		}
开发者ID:KMarshland,项目名称:ChildrensHospitalApp,代码行数:7,代码来源:Types.cs

示例15: IsDefined

 internal static bool IsDefined(MemberInfo target, Type caType, bool inherit) {
   // JScript implements subclasses of MemberInfo which throw an exception when Module is
   // accessed. We know that none of these are from a ReflectionOnly assembly.
   Type t = target.GetType();
   if (t.Assembly == typeof(CustomAttribute).Assembly || !target.Module.Assembly.ReflectionOnly)
     return target.IsDefined(caType, inherit);
   return CustomAttribute.CheckForCustomAttribute(CustomAttributeData.GetCustomAttributes(target), caType);
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:8,代码来源:customattribute.cs


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