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


C# IInvocation.GetArgumentValue方法代码示例

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


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

示例1: Intercept

        public void Intercept(IInvocation invocation)
        {
            PropertyInfo setter =
                invocation.Method.DeclaringType.GetProperties()
                          .FirstOrDefault(p => p.GetSetMethod() == invocation.Method);

            if (setter != null && setter.HasAttribute<OutAttribute>())
            {
                string mappingName = setter.GetOutMappingName();

                invocation.Proceed();
                if (setter.GetGetMethod(true) != null)
                {
                    data[mappingName] = setter.GetValue(ProxyUtil.GetUnproxiedInstance(invocation.InvocationTarget));
                }
                else
                {
                    data[mappingName] = invocation.GetArgumentValue(0);
                }
            }

            PropertyInfo getter =
                invocation.Method.DeclaringType.GetProperties()
                          .FirstOrDefault(p => p.GetGetMethod() == invocation.Method);

            if (getter != null && getter.HasAttribute<InAttribute>())
            {
                string mappingName = getter.GetInMappingName();

                invocation.ReturnValue = data[mappingName];
            }
        }
开发者ID:dkschlos,项目名称:PVM.NET,代码行数:32,代码来源:DataInterceptor.cs

示例2: CalculateKey

        protected override CompositeKey CalculateKey(IInvocation invocation, string[] keyAttributes = null)
        {
            try
            {
                CompositeKey result = new CompositeKey();
                List<object> argumentsForKey = null;

                argumentsForKey = new List<object>() { invocation.Method.Name };
                result.MinimalKey = invocation.Method.Name;

                if (keyAttributes != null && keyAttributes.Length > 0)
                {
                    // note: not expanding parameters of type list/array - the key may be longer than the actual data
                    var values = invocation.Method.GetParameters().Where(p => keyAttributes.Contains(p.Name)).Select(
                        p => invocation.GetArgumentValue(p.Position).ToString());
                    argumentsForKey.AddRange(values);
                }

                result.FullKey = string.Join("-", argumentsForKey);
                return result;
            }
            catch (Exception)
            {
                throw;
            }
        }
开发者ID:oduma,项目名称:Simulation.UI,代码行数:26,代码来源:CacheProviderForMethods.cs

示例3: Intercept

        public void Intercept(IInvocation invocation)
        {
#if DEBUG
            Count++;
#endif
            if (invocation.Method.Name.StartsWith("get_", StringComparison.OrdinalIgnoreCase))
            {
                string propertyName = invocation.Method.Name.Substring(4);
                var property = classMapping.Properties.FirstOrDefault(p => p.Name.Matches(propertyName));
                if (property != null)
                {
                    if (property.HasReference)
                    {
                        invocation.ReturnValue = entityProxyObject.HandleReferencePropertyGet(property);
                    }
                    else if (property.HasOneToMany)
                    {
                        invocation.ReturnValue = entityProxyObject.HandleOneToManyPropertyGet(property);
                    }
                    else
                    {
                        var value = entityProxyObject.GetCurrentFieldValue(property.Column);
                        if (property.CustomTypeConverter != null)
                            invocation.ReturnValue = property.CustomTypeConverter.ConvertTo(value);
                        else
                            invocation.ReturnValue = value;
                    }
                    return;
                }
            }
            else if (invocation.Method.Name.StartsWith("set_", StringComparison.OrdinalIgnoreCase))
            {
                string propertyName = invocation.Method.Name.Substring(4);
                var property = classMapping.Properties.FirstOrDefault(p => p.Name.Matches(propertyName));
                if (property != null)
                {
                    var value = invocation.GetArgumentValue(0);
                    if (property.HasReference)
                    {
                        entityProxyObject.HandleReferencePropertySet(property, value);
                    }
                    else
                    {
                        if (property.CustomTypeConverter != null)
                            entityProxyObject.SetNewFieldValue(property.Column, property.CustomTypeConverter.ConvertFrom(value));
                        else
                            entityProxyObject.SetNewFieldValue(property.Column, value);
                    }
                    return;
                }
            }
            invocation.Proceed();
        }
开发者ID:jdaigle,项目名称:Centro,代码行数:53,代码来源:EntityFieldInterceptor.cs

示例4: AddHandler

        static void AddHandler(IInvocation invocation, PropertyChangedInterceptor propertyChangedInterceptor)
        {
            if (!handlers.ContainsKey(invocation.InvocationTarget))
                handlers.Add(invocation.InvocationTarget, new Dictionary<string, PropertyChangedEventHandler>());

            handlers[invocation.InvocationTarget].Add(invocation.PropertyName(), (o, e) =>
            {
                propertyChangedInterceptor.Notify(invocation);
                propertyChangedInterceptor.SetDependents(invocation);
            });

            (invocation.GetArgumentValue(0) as INotifyPropertyChanged).PropertyChanged += handlers[invocation.InvocationTarget][invocation.PropertyName()];
        }
开发者ID:paulyoder,项目名称:autonotify,代码行数:13,代码来源:PropertySetterInterception.cs

示例5: GetCacheKey

        private string GetCacheKey(IInvocation invocation)
        {
            var sb = new StringBuilder();
            sb.Append(invocation.Method.Name);
            sb.Append(";");

            ParameterInfo[] parameters = InvocationHelper.MethodParameters(invocation);
            
            foreach (var parameter in parameters)
            {
                var objectValue = invocation.GetArgumentValue(parameter.Position);
                string valueHash = EqualityHelper.ValueTypeHashCode(objectValue);
                sb.Append(valueHash);
            }

            return sb.ToString();
            //return InvocationHelper.InvocationNameAndArguments(invocation);
        }
开发者ID:markeverard,项目名称:FortuneCookie.BuildStatus,代码行数:18,代码来源:MethodCacheInterceptor.cs

示例6: Intercept

        public void Intercept(IInvocation invocation)
        {
            ParameterInfo[] paras = invocation.Method.GetParameters();
            int argLength = paras.Length;
            if (argLength > 0)
            {
                for (int i = 0; i < argLength; i++)
                {
                    ParameterInfo para = paras[i];
                    Type paraType = para.ParameterType;
                    if (paraType == typeof(String))
                    {
                        string paraOriginalValue = Convert.ToString(invocation.GetArgumentValue(i));
                        string paraConveredValue = SQLInjectionHelper.GetSafeSqlBeforeSave(paraOriginalValue);
                        invocation.SetArgumentValue(i, paraConveredValue);
                    }
                }
            }

            invocation.Proceed();
        }
开发者ID:notinmood,项目名称:hiland,代码行数:21,代码来源:SQLInjectionInterceptor.cs

示例7: Intercept

        public void Intercept(IInvocation invocation)
        {
            if (!(invocation.InvocationTarget is Device)) {
                invocation.Proceed();
                return;
            }

            if (!invocation.Method.Name.StartsWith("set_")) {
                invocation.Proceed();
                return;
            }

            var propertyName = invocation.Method.Name.Substring(4);
            var getterName = "get_" + propertyName;

            var getter = invocation.TargetType.GetMethod(getterName);

            if (getter == null) {
                invocation.Proceed();
                return;
            }

            if (!getter.IsPublic) {
                invocation.Proceed();
                return;
            }

            invocation.Proceed();

            var device = (Device)(invocation.InvocationTarget);

            var command = new SetPropertyCommand(device.Id, Serializer.Resolver.GetResolvedPropertyName(propertyName),
                invocation.GetArgumentValue(0));

            CommandBus.Instance.Publish(command).ContinueWith((obj) => { });
        }
开发者ID:kevinswiber,项目名称:zetta-dot-net,代码行数:36,代码来源:SetterInterceptor.cs

示例8: Intercept

		//public DataBindingInterceptor(System.Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, ISessionImplementor session)
		//  : base(persistentClass, id, getIdentifierMethod, setIdentifierMethod, session)
		//{
		//}

		public override void Intercept(IInvocation invocation)
		{
			object result;
			if (invocation.Method.DeclaringType == typeof (INotifyPropertyChanged))
			{
				var propertyChangedEventHandler = (PropertyChangedEventHandler) invocation.GetArgumentValue(0);
				if (invocation.Method.Name.StartsWith("add_"))
				{
					subscribers += propertyChangedEventHandler;
				}
				else
				{
					subscribers -= propertyChangedEventHandler;
				}
				return;
			}
			base.Intercept(invocation);
			result = invocation.ReturnValue;
			if (invocation.Method.Name.StartsWith("set_"))
			{
				subscribers(this, new PropertyChangedEventArgs(invocation.Method.Name.Substring(4)));
			}
			invocation.ReturnValue = result;
		}
开发者ID:rbellamy,项目名称:NHibernate.ByteCode.Castle,代码行数:29,代码来源:CustomProxyFixture.cs

示例9: HandleSetter

        private void HandleSetter(MethodInfo method, IInvocation invocation)
        {
            // Find the get method
            var getter = invocation.TargetType.GetMethod("g" + method.Name.Remove(0, 1));

            PropertyValue propValue;
            if (Properties.TryGetValue(getter, out propValue))
            {
                // Resets the value...
                propValue.Value = invocation.GetArgumentValue(0);
                return;
            }

            // Sets the value and caches it.
            propValue = Properties[getter] = new PropertyValue
            {
                Value = invocation.GetArgumentValue(0),

                // If this is a collection field interceptor then the value
                // returned should allways be considered as loaded.
                IsLoaded = InterceptCollections
            };
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:23,代码来源:FieldInterceptorBase.cs


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