本文整理汇总了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];
}
}
示例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;
}
}
示例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();
}
示例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()];
}
示例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);
}
示例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();
}
示例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) => { });
}
示例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;
}
示例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
};
}