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


C# PropertyInfo.GetGetMethod方法代码示例

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


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

示例1: GetPropertyModifiers

        static string GetPropertyModifiers (PropertyInfo property)
        {
                MethodBase mb = property.GetSetMethod (true);

                if (mb == null)
                        mb = property.GetGetMethod (true);

                return GetMethodModifiers (mb);
        }
开发者ID:emtees,项目名称:old-code,代码行数:9,代码来源:updater.cs

示例2: AddProperty

        static void AddProperty (XmlElement members, PropertyInfo property)
        {
                XmlDocument document = members.OwnerDocument;
                string signature = AddPropertySignature (property);

                if (signature == null)
                        return;

                XmlElement member = document.CreateElement ("Member");
                member.SetAttribute ("MemberName", property.Name);
                members.AppendChild (member);
                XmlElement property_signature = document.CreateElement ("MemberSignature");
                property_signature.SetAttribute ("Language", "C#");
                property_signature.SetAttribute ("Value", signature);
                member.AppendChild (property_signature);
                member.AppendChild (AddElement (document, "MemberType", "Property"));

                Type return_type = property.PropertyType;
                member.AppendChild (AddReturnValue (document, return_type));

                if (property.CanRead && property.GetGetMethod () != null) {
                        ParameterInfo [] parameters = property.GetGetMethod ().GetParameters ();
                        member.AppendChild (AddParameters (document, parameters));
                        member.AppendChild (AddDocsNode (document, return_type, parameters));
                } else
                        member.AppendChild (AddDocsNode (document, return_type, null));
        }
开发者ID:emtees,项目名称:old-code,代码行数:27,代码来源:updater.cs

示例3: GetPropertyVisibility

        static string GetPropertyVisibility (PropertyInfo property)
        {
                MethodBase mb = property.GetSetMethod (true);

                if (mb == null)
                        mb = property.GetGetMethod (true);

                return GetMethodVisibility (mb);
        }
开发者ID:emtees,项目名称:old-code,代码行数:9,代码来源:updater.cs

示例4: GetGetMethod

 public static MethodInfo GetGetMethod(PropertyInfo property)
 {
     Requires.NotNull(property, nameof(property));
     return property.GetGetMethod();
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例5: GetGetMethod

 public static MethodInfo GetGetMethod(PropertyInfo property, bool nonPublic)
 {
     Requires.NotNull(property, "property");
     return property.GetGetMethod(nonPublic);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例6: GetModifiers

		private static Modifiers GetModifiers(PropertyInfo property)
		{
			// NOTE we only support the subset of modifiers that is expected for "access stub" properties
			MethodInfo getter = property.GetGetMethod(true);
			Modifiers modifiers = getter.IsPublic ? Modifiers.Public : Modifiers.Protected;
			if(!property.CanWrite)
			{
				modifiers |= Modifiers.Final;
			}
			if(getter.IsStatic)
			{
				modifiers |= Modifiers.Static;
			}
			return modifiers;
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:15,代码来源:MemberWrapper.cs

示例7: CompiledAccessStubFieldWrapper

 private CompiledAccessStubFieldWrapper(TypeWrapper wrapper, PropertyInfo property, TypeWrapper propertyType, string name, string signature, Modifiers modifiers, MemberFlags flags)
     : base(wrapper, propertyType, name, signature, modifiers, null, flags)
 {
     this.getter = property.GetGetMethod(true);
     this.setter = property.GetSetMethod(true);
 }
开发者ID:badlogic,项目名称:ikvm-monotouch,代码行数:6,代码来源:MemberWrapper.cs

示例8: RegisterProperty

 static void RegisterProperty(PropertyInfo p, StringBuilder sb) {
     string getMethod = "Lua" + p.ReflectedType.Name + "." + p.GetGetMethod().Name;
     string setMethod = p.GetSetMethod() == null ? "null" : "Lua" + p.ReflectedType.Name + "." + p.GetSetMethod().Name;
     sb.AppendFormat("            LuaDLL.lua_pushcsharpproperty(L, '{0}', {1}, {2});\r\n", p.Name, getMethod, setMethod);
 }
开发者ID:musicseli,项目名称:emoji,代码行数:5,代码来源:LuaApiMaker.cs

示例9: CreateGetHandler

        // CreateGetDelegate
        internal static GetHandler CreateGetHandler(Type type, PropertyInfo propertyInfo)
        {
            MethodInfo getMethodInfo = propertyInfo.GetGetMethod(true);
            DynamicMethod dynamicGet = CreateGetDynamicMethod(type);
            ILGenerator getGenerator = dynamicGet.GetILGenerator();

            getGenerator.Emit(OpCodes.Ldarg_0);
            getGenerator.Emit(OpCodes.Call, getMethodInfo);
            BoxIfNeeded(getMethodInfo.ReturnType, getGenerator);
            getGenerator.Emit(OpCodes.Ret);

            return (GetHandler)dynamicGet.CreateDelegate(typeof(GetHandler));
        }
开发者ID:dpradov,项目名称:object-binding-source,代码行数:14,代码来源:DynamicAccessor.cs

示例10: GetPropertyValue

		/// <summary> Get the value of the property using the get accessor </summary>
		public static Value GetPropertyValue(Value objectInstance, PropertyInfo propertyInfo, params Value[] arguments)
		{
			CheckObject(objectInstance, propertyInfo);
			
			if (propertyInfo.GetGetMethod() == null) throw new GetValueException("Property does not have a get method");
			
			Value val = Value.InvokeMethod(objectInstance, (DebugMethodInfo)propertyInfo.GetGetMethod(), arguments);
			
			return val;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:11,代码来源:Value.cs

示例11: GenProperty

    static void GenProperty(PropertyInfo p, StringBuilder sb) {

        //先注册get方法
        MethodInfo m = p.GetGetMethod();
        AppendFunctionHead(m, sb);
        string text = m.ReflectedType.Name + "." + m.Name + "(";
        string name = "";
        int count = m.IsStatic ? 0 : 1;
        if (m.IsStatic) {
            text = TrimNameSpace(p.ReflectedType) + ".";
        }
        else {
            text = "obj.";
        }
        if (count > 0) {
            text += p.Name;
            CheckArgsCount(m, count, sb, true);
        }

        text += ";\r\n";
        sb.Append("\r\n            ");

        text = text.Remove(text.Length - 3, 3);
        GenPushStr(m.ReturnType, text, sb, null);
        AppendFunctionEnd(sb);

        //注册set方法
        m = p.GetSetMethod();
        if (m == null) return;
        AppendFunctionHead(m, sb);
        ParameterInfo[] paramInfos = m.GetParameters();
        text = m.ReflectedType.Name + ".";
        count = m.IsStatic ? 1 : 2;
        if (m.IsStatic) {
            text = "\r\n            " + TrimNameSpace(m.ReturnType) + ".";
        }
        else {
            text = "\r\n            " + "obj.";
        }
        name = string.Format("({0})", TrimNameSpace(paramInfos[0].ParameterType));

        if (paramInfos[0].ParameterType.IsPrimitive && paramInfos[0].ParameterType != typeof(bool)) {
            name += "(double)";
        }
        if (count > 0) {
            if (!m.IsStatic) {
                CheckArgsCount(m, count, sb, true);
                text += string.Format("{0} = {1}LuaStatic.GetObj(L, {2});\r\n", p.Name, name, 2);
            }
            else {
                text += string.Format("{0} = {1}LuaStatic.GetObj(L, {2});\r\n", p.Name, name, 1);
            }
        }

        sb.Append("\r\n            ");
        sb.Append(text);

        AppendFunctionEnd(sb);
    }
开发者ID:musicseli,项目名称:emoji,代码行数:59,代码来源:LuaApiMaker.cs

示例12: GetSetMethod

        internal static MethodInfo GetSetMethod(PropertyInfo property, bool nonPublic, bool allowInternal)
        {
            if (property == null) return null;
#if WINRT
            MethodInfo method = property.SetMethod;
            if (!nonPublic && method != null && !method.IsPublic) method = null;
            return method;
#else
            MethodInfo method = property.GetSetMethod(nonPublic);
            if (method == null && !nonPublic && allowInternal)
            { // could be "internal" or "protected internal"; look for a non-public, then back-check
                method = property.GetGetMethod(true);
                if (method == null && !(method.IsAssembly || method.IsFamilyOrAssembly))
                {
                    method = null;
                }
            }
            return method;
#endif
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:20,代码来源:Helpers.cs

示例13: GetPropertyValue

	// Get the current value of the specified property owned by instance. If instance is null then property is static.
	// Returns: results of the ToString method when called on the result of the property, "write-only" if property is write-only, or null if property is of unsupported type.
	public static string GetPropertyValue(object instance, PropertyInfo propertyInfo) {
		if(propertyInfo == null) { return null; }
		if(propertyInfo.GetGetMethod() == null) { return "write-only!"; }
		switch(propertyInfo.PropertyType.Name) {
			case "Vector2":
			case "Vector3":
			case "Color":
			case "String":
			case "Char":
			case "Byte":
			case "SByte":
			case "Int16":
			case "Int32":
			case "Int64":
			case "UInt16":
			case "UInt32":
			case "UInt64":
			case "Single":
			case "Double":
			case "Boolean":
				return propertyInfo.GetValue(instance, null).ToString();
			default:
				return null;
		}
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:27,代码来源:Console.cs

示例14: OutlineProperty

	void OutlineProperty (PropertyInfo pi)
	{
		ParameterInfo [] idxp = pi.GetIndexParameters ();
		MethodBase g = pi.GetGetMethod (true);
		MethodBase s = pi.GetSetMethod (true);
		MethodBase accessor = g != null ? g : s;
		
		if (pi.CanRead && pi.CanWrite) {

			
			// Get the more accessible accessor
			if ((g.Attributes & MethodAttributes.MemberAccessMask) !=
			    (s.Attributes & MethodAttributes.MemberAccessMask)) {
				
				if (g.IsPublic) accessor = g;
				else if (s.IsPublic) accessor = s;
				else if (g.IsFamilyOrAssembly) accessor = g;
				else if (s.IsFamilyOrAssembly) accessor = s;
				else if (g.IsAssembly || g.IsFamily) accessor = g;
				else if (s.IsAssembly || s.IsFamily) accessor = s;
			}
		}
		
		o.Write (GetMethodVisibility (accessor));
		o.Write (GetMethodModifiers  (accessor));
		o.Write (FormatType (pi.PropertyType));
		o.Write (" ");
		
		if (idxp.Length == 0)
			o.Write (pi.Name);
		else {
			o.Write ("this [");
			OutlineParams (idxp);
			o.Write ("]");
		}
		
		o.WriteLine (" {");
		o.Indent ++;
		
		if (g != null && ShowMember (g)) {
			if ((g.Attributes & MethodAttributes.MemberAccessMask) !=
			    (accessor.Attributes & MethodAttributes.MemberAccessMask))
				o.Write (GetMethodVisibility (g));
			o.WriteLine ("get;");
		}
		
		if (s != null && ShowMember (s)) {
			if ((s.Attributes & MethodAttributes.MemberAccessMask) !=
			    (accessor.Attributes & MethodAttributes.MemberAccessMask))
				o.Write (GetMethodVisibility (s));
			o.WriteLine ("set;");
		}
		
		o.Indent --;
		o.Write ("}");
	}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:56,代码来源:outline.cs

示例15: GetMethodType

    static int GetMethodType(MethodBase md, out PropertyInfo pi)
    {
        int methodType = 0;
        pi = null;
        int pos = allProps.FindIndex((p) => { return p.GetGetMethod() == md || p.GetSetMethod() == md; });

        if (pos >= 0)
        {
            methodType = 1;
            pi = allProps[pos];

            if (md == pi.GetGetMethod())
            {
                if (md.GetParameters().Length > 0)
                {
                    methodType = 2;
                }
            }
            else if (md == pi.GetSetMethod())
            {
                if (md.GetParameters().Length > 1)
                {
                    methodType = 2;
                }
            }
        }

        return methodType;
    }
开发者ID:xlwangcs,项目名称:LuaFramework_UGUI,代码行数:29,代码来源:ToLuaExport.cs


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