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


C# MethodInfo.IsPropertySetter方法代码示例

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


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

示例1: TimestampedPropertyVersionDelta

        public TimestampedPropertyVersionDelta(object setValue, MethodInfo targetSite, long timeStamp, bool isActive = true)
            : base(new[]{setValue}, targetSite, timeStamp, isActive)
        {
            if( ! targetSite.IsPropertySetter())
                throw new Exception(string.Format("method {0} is not a property setter.", targetSite));

            var actualType = targetSite.GetParameters().Single().ParameterType;

            if (setValue == null && actualType.IsValueType && actualType != typeof(Nullable<>)) //nullable being a struct is annoying.
                throw new Exception(String.Format("Attempting to set null to a value type"));
                //actually looking at the comments from microsoft symbole servers on nullable, Microsoft seems to think the whole concept
                //of nullable is pretty annoying. Wierd serialization issues.

            if (setValue != null && ! setValue.GetType().IsAssignableTo(actualType))
                throw new Exception(String.Format("supplied value to set is not the correct type. Supplied value is a {0} but the setter is setting a {1}",
                                                  setValue.GetType(), actualType));
        }
开发者ID:Groostav,项目名称:VersionCommander,代码行数:17,代码来源:PropertyVersionDelta.cs

示例2: GetMethodCall

		// TODO Property formating
		// TODO ParamArray method
		// TODO Void members
		// TODO indexers
		private string GetMethodCall(MethodInfo method)
		{
			if (method.IsPropertyGetter())
			{
				return method.Name.Substring(4) + " → " + this.ReturnValue;
			}

			if (method.IsPropertySetter())
			{
				return method.Name.Substring(4) + " = " + this.GetValue(this.Arguments.ElementAt(0).Value);
			}

			var methodCall = this.Method + "(" +
				string.Join(",", this.Arguments.Select(a => GetKind(a) + a.Name + ": " + a.Value.ToString()).ToArray()) + ")";
			if (this.IsVoid)
			{
				return methodCall;
			}

			return " → " + this.ReturnValue.ToString();
		}
开发者ID:CharlieBP,项目名称:moq4,代码行数:25,代码来源:CallViewModel.cs


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