本文整理汇总了C#中IInvocationInfo类的典型用法代码示例。如果您正苦于以下问题:C# IInvocationInfo类的具体用法?C# IInvocationInfo怎么用?C# IInvocationInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInvocationInfo类属于命名空间,在下文中一共展示了IInvocationInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterInvoke
public void AfterInvoke(IInvocationInfo context, object returnValue)
{
foreach (IAroundInvoke invoke in _aroundInvokeList)
{
invoke.AfterInvoke(context, returnValue);
}
}
示例2: Intercept
public override object Intercept(IInvocationInfo info)
{
//typeof(LobbyMenu).GetField ("_hoverButtonInside", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue (info.Target, false);
try {
Type lobbyMenu = typeof(LobbyMenu);
if (first) {
GUISkin gUISkin7 = ScriptableObject.CreateInstance<GUISkin> ();
text = new Texture2D(87, 39); //115, 39
text.LoadImage(System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream ("ScrollsModLoader.Mods.png").ReadToEnd ());
gUISkin7.button.normal.background = text;
gUISkin7.button.hover.background = text;
gUISkin7.button.active.background = text;
//info.Target.GUISkins.Add (gUISkin5);
FieldInfo GUISkins = lobbyMenu.GetField("GUISkins", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
if (GUISkins == null)
Console.WriteLine ("GuiSkins == null");
((List<GUISkin>)(GUISkins.GetValue(info.Target))).Add(gUISkin7);
first = false;
}
MethodInfo drawHeader = lobbyMenu.GetMethod ("drawHeaderButton", BindingFlags.NonPublic | BindingFlags.Instance);
drawHeader.Invoke(info.Target, new object[] {6, "_Settings"});
} catch (Exception exp) {
Console.WriteLine (exp);
}
return info.TargetMethod.Invoke(info.Target, info.Arguments);
}
示例3: ShouldReplace
/// <summary>
/// Determines whether or not a particular method body should be replaced at runtime.
/// </summary>
/// <param name="host">The host instance that contains the target method.</param>
/// <param name="context">The context surrounding the method call.</param>
/// <returns>Returns <c>true</c> if the method body should be swapped; otherwise, it will return <c>false</c>.</returns>
protected override bool ShouldReplace(object host, IInvocationInfo context)
{
if (MethodReplacementPredicate == null)
return true;
return MethodReplacementPredicate(context);
}
示例4: Intercept
/// <summary>
/// A method that redirects the method calls to
/// the functor instance.
/// </summary>
/// <param name="info">The <see cref="IInvocationInfo"/> instance that describes the context of the method call.</param>
/// <returns>The return value from the target method.</returns>
public object Intercept(IInvocationInfo info)
{
if (_doIntercept == null)
throw new NotImplementedException();
return _doIntercept(info);
}
示例5: GetProvider
/// <summary>
/// Returns the provider that is currently attached to the registry.
/// </summary>
/// <param name="host">The type that is currently being intercepted.</param>
/// <param name="info">The <see cref="IInvocationInfo"/> object that describes the invocation context.</param>
/// <returns>A <see cref="IMethodReplacementProvider"/> that will determine the code that will be executed once a target method is called.</returns>
public static IMethodReplacementProvider GetProvider(object host, IInvocationInfo info)
{
if (_provider == null)
return null;
return _provider.CanReplace(host, info) ? _provider : null;
}
示例6: InvocationInfoInterceptor
/// <summary>
/// Initializes the class with a functor that can provide the actual target instance.
/// </summary>
/// <param name="getActualTarget">The <see cref="Func{TResult}"/> that will provide the target instance that will be used for the method invocation.</param>
/// <param name="methodInvoke">The method invoker.</param>
/// <param name="realInfo">The <see cref="IInvocationInfo"/> instance that describes the current execution context.</param>
internal InvocationInfoInterceptor(IInvocationInfo realInfo, Func<object> getActualTarget,
IMethodInvoke<MethodInfo> methodInvoke)
: base(methodInvoke)
{
_getActualTarget = getActualTarget;
_realInfo = realInfo;
}
示例7: GetSurroundingImplementation
public IAroundInvoke GetSurroundingImplementation(IInvocationInfo context)
{
if (Predicate == null)
return _around;
return Predicate(context) ? _around : null;
}
示例8: Intercept
public object Intercept(IInvocationInfo info)
{
var args = string.Join(", ", info.Arguments.Select(x => (x ?? string.Empty).ToString()));
Debug.WriteLine(string.Format("Linfu: {0}({1})", info.TargetMethod.Name, args));
return info.TargetMethod.Invoke(info.Target, info.Arguments);
}
示例9: Invoke
public object Invoke(IInvocationInfo invocationInfo)
{
if (session.InTransaction)
{
return invocationInfo.Proceed();
}
using (var transaction = session.Connection.BeginTransaction())
{
session.InTransaction = true;
try
{
var result = invocationInfo.Proceed();
transaction.Commit();
return result;
}
catch (Exception)
{
transaction.Rollback();
throw;
}
finally
{
session.InTransaction = false;
}
}
}
示例10: BeforeInvoke
public void BeforeInvoke(IInvocationInfo context)
{
foreach (IAroundInvoke invoke in _aroundInvokeList)
{
invoke.BeforeInvoke(context);
}
}
示例11: Intercept
/// <summary>
/// Intercepts a method call using the given
/// <see cref="IInvocationInfo"/> instance.
/// </summary>
/// <param name="info">The <see cref="IInvocationInfo"/> instance that will
/// contain all the necessary information associated with a
/// particular method call.</param>
/// <returns>The return value of the target method. If the return type of the target
/// method is <see cref="void"/>, then the return value will be ignored.</returns>
public virtual object Intercept(IInvocationInfo info)
{
object target = GetTarget(info);
MethodBase method = info.TargetMethod;
object[] arguments = info.Arguments;
return _methodInvoke.Invoke(target, (MethodInfo) method, arguments);
}
示例12: Intercept
/// <summary>
/// Intercepts a method call using the given
/// <see cref="IInvocationInfo"/> instance.
/// </summary>
/// <param name="info">The <see cref="IInvocationInfo"/> instance that will
/// contain all the necessary information associated with a
/// particular method call.</param>
/// <returns>The return value of the target method. If the return type of the target
/// method is <see cref="Void"/>, then the return value will be ignored.</returns>
public virtual object Intercept(IInvocationInfo info)
{
var target = GetTarget(info);
var method = info.TargetMethod;
var arguments = info.Arguments;
return _methodInvoke.Invoke(target, (MethodInfo)method, arguments);
}
示例13: Intercept
public object Intercept(IInvocationInfo info)
{
var methodName = info.TargetMethod.Name;
Console.WriteLine("method '{0}' called", methodName);
return info.TargetMethod;
}
示例14: GetPendingCalls
public int GetPendingCalls(IInvocationInfo context)
{
int threadId = Thread.CurrentThread.ManagedThreadId;
if (!_counts.ContainsKey(threadId))
return 0;
return _counts[threadId].GetPendingCalls(context);
}
示例15: CanReplace
/// <summary>
/// Determines whether or not the current method implementation can be replaced.
/// </summary>
/// <param name="host">The target instance of the method call.</param>
/// <param name="context">The <see cref="IInvocationInfo"/> that describes the context of the method call.</param>
/// <returns><c>true</c> if the method can be intercepted; otherwise, it will return <c>false</c>.</returns>
public bool CanReplace(object host, IInvocationInfo context)
{
var pendingCalls = _counter.GetPendingCalls(context);
if (pendingCalls > 0)
return false;
return ShouldReplace(host, context);
}