本文整理汇总了C#中Engine.Trace方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.Trace方法的具体用法?C# Engine.Trace怎么用?C# Engine.Trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.Trace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public object Get(Engine engine)
{
engine.Trace(TraceFlags.Path, "Path: {0}: Get", this.GetType().Name);
var result = OnGet(engine);
engine.Trace(TraceFlags.Path, "Path: {0} = {1}", this.GetType().Name, result);
return result;
}
示例2: CallMethod
public static object CallMethod(string methodName, bool staticMethod, Type typeToCall, object callee, IEnumerable<object> args, Type[] typeArgs, Engine engine)
{
var bindingFlags = (staticMethod ? BindingFlags.Static : BindingFlags.Instance) |
BindingFlags.Public | BindingFlags.FlattenHierarchy;
var methodInfo = null as MethodInfo;
if (typeArgs != null)
{
// Use type arguments to choose overload.
methodInfo = typeToCall.GetMethod(methodName, bindingFlags, null, typeArgs, null);
}
else
{
// Look for a matching method.
var candidates = typeToCall.GetMethods(bindingFlags).Where(info => info.Name == methodName);
var count = candidates.Count();
if (count >= 1)
{
if (count == 1)
methodInfo = candidates.First();
else
{
// Use arguments to choose overload.
var types = args.Select(value => value != null ? value.GetType() : typeof(object));
methodInfo = typeToCall.GetMethod(methodName, bindingFlags, null, types.ToArray(), null);
if (methodInfo == null) engine.Throw("method overload not found: " + methodName);
}
}
}
if (methodInfo == null) engine.Throw("method not found: " + methodName);
var parameters = methodInfo.GetParameters();
var methodArgs = null as object[];
if (HasParamsParameter(parameters))
{
var m = parameters.Length - 1;
var initiaArgs = ConvertArguments(parameters.Take(m), args.Take(m));
var paramsType = parameters[m].ParameterType.GetElementType();
var remainingArgs = TypeHelper.CreateArray(args.Skip(m).ToArray(), paramsType);
methodArgs = initiaArgs.Concat(new object[] { remainingArgs }).ToArray();
}
else
{
if (parameters.Length != args.Count()) engine.Throw("argument count mismatch: {0} != {1}", parameters.Length, args.Count());
methodArgs = ConvertArguments(parameters, args).ToArray();
}
bool trace = engine.ShouldTrace(TraceFlags.Call);
if (trace)
{
TraceCall("args", methodName, args, engine);
TraceCall("methodArgs", methodName, methodArgs, engine);
}
var result = methodInfo.Invoke(callee, methodArgs);
if (trace) engine.Trace(TraceFlags.Call, "Call {0} = {1}", methodName, result);
return result;
}
示例3: EventHandler
private void EventHandler(Engine engine)
{
if (Configuration.IsInDesignMode) return;
engine.Trace(TraceFlags.Events, "Event: {0}, sender {1}", registeredEventName, engine.Sender);
SetContext(engine);
OnEventHandler(engine);
#if !SILVERLIGHT
if (!Configuration.Silverlight && SetHandled && engine.EventArgs is RoutedEventArgs)
(engine.EventArgs as RoutedEventArgs).Handled = true;
#endif
}
示例4: TraceCall
private static void TraceCall(string info, string methodName, IEnumerable<object> args, Engine engine)
{
var text = args.Count() == 0 ? "" : args.Aggregate((current, next) => current + ", " + next);
engine.Trace(TraceFlags.Call, "Call {0}: {1}({2})", info, methodName, text);
}
示例5: Set
public object Set(Engine engine, object value)
{
engine.Trace(TraceFlags.Path, "Path: {0}: Set {1}", this.GetType().Name, value);
OnSet(engine, value);
return value;
}