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


C# PropertyInfo.GetSetMethod方法代码示例

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


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

示例1: PropertyAccessor

 public PropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     _hasSetter = (propertyInfo.GetSetMethod(true) != null);
     if (_hasSetter)
         _lateBoundPropertySet = DelegateFactory.CreateSet(propertyInfo);
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:7,代码来源:PropertyAccessor.cs

示例2: ValueTypePropertyAccessor

 public ValueTypePropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     var setMethod = propertyInfo.GetSetMethod(true);
     _hasSetter = (setMethod != null);
     if (_hasSetter)
         _lateBoundPropertySet = setMethod;
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:8,代码来源:ValueTypePropertyAccessor.cs

示例3: GetSetMethod

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

示例4: GetSetMethod

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

示例5: PropertyField

    public PropertyField(System.Object instance, PropertyInfo info, SerializedPropertyType type)
    {
        m_Instance = instance;
        m_Info = info;
        m_Type = type;

        m_Getter = m_Info.GetGetMethod();
        m_Setter = m_Info.GetSetMethod();
    }
开发者ID:Collegiennes,项目名称:picoBattle,代码行数:9,代码来源:ExposeProperties.cs

示例6: initProperty

    private void initProperty( object target, PropertyInfo property )
    {
        this.target = target;
        this.propertyInfo = property;
        this.propertyGetter = property.GetGetMethod();
        this.propertySetter = property.GetSetMethod();
        this.canWrite = ( propertySetter != null );

        Value = getter();
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:10,代码来源:dfObservableProperty.cs

示例7: IsItemThis

    static bool IsItemThis(PropertyInfo info)
    {
        MethodInfo md = info.GetGetMethod();

        if (md != null)
        {
            return md.GetParameters().Length != 0;
        }

        md = info.GetSetMethod();

        if (md != null)
        {
            return md.GetParameters().Length != 1;
        }

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

示例8: 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

示例9: 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

示例10: SetPropertyValue

		/// <summary> Set the value of the property using the set accessor </summary>
		public static Value SetPropertyValue(Value objectInstance, PropertyInfo propertyInfo, Value[] arguments, Value newValue)
		{
			CheckObject(objectInstance, propertyInfo);
			
			if (propertyInfo.GetSetMethod() == null) throw new GetValueException("Property does not have a set method");
			
			arguments = arguments ?? new Value[0];
			
			Value[] allParams = new Value[1 + arguments.Length];
			allParams[0] = newValue;
			arguments.CopyTo(allParams, 1);
			
			return Value.InvokeMethod(objectInstance, (DebugMethodInfo)propertyInfo.GetSetMethod(), allParams);
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:15,代码来源:Value.cs

示例11: 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

示例12: SetPropertyValue

	// Set the current value of the specified property owned by instance. If instance is null then property is static.
	// Returns: boolean indicating whether the property was successfully changed, or if property is read-only.
	public static bool SetPropertyValue(object instance, PropertyInfo propertyInfo, List<string> parameters) {
		if(propertyInfo.GetSetMethod() == null) {
			string output = GetPropertyValue(instance, propertyInfo);
			if(output == null) { return false; } // Fail: Property is not of a supported type
			Echo(propertyInfo.Name + " is read-only!");
			Echo(propertyInfo.Name + " is " + output);
			return true; // Success: Value is printed when property is read-only
		}
		object result = ParseParameterListIntoType(propertyInfo.PropertyType.Name, parameters);
		if(result != null) {
			propertyInfo.SetValue(instance, result, null);
			return true;
		} else {
			return false; // Fail: The parameters could not be parsed into the desired type
		}
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:18,代码来源:Console.cs

示例13: 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

示例14: 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

示例15: 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


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