本文整理汇总了C#中System.Reflection.MethodBase.SerializeMethodHandle方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBase.SerializeMethodHandle方法的具体用法?C# MethodBase.SerializeMethodHandle怎么用?C# MethodBase.SerializeMethodHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodBase
的用法示例。
在下文中一共展示了MethodBase.SerializeMethodHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeFromMethod
protected override void InitializeFromMethod(MethodBase method)
{
if (!method.IsStatic)
{
throw new ArgumentException("Remote executor supports only static methods.", "method");
}
var parameters = method.GetParameters();
this.serializeParameters = new bool[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
{
var parameterType = parameters[i].ParameterType;
// TODO: it is not going to work with structs
if (parameterType.IsClass)
{
if (!parameterType.IsSerializable)
{
throw new ArgumentException(
string.Format("Remote executor supports only serializable classes as method parameters[{0}]. Consider adding [Serializable] attribute.", parameterType.FullName),
"method");
}
this.serializeParameters[i] = true;
}
}
var methodInfo = method as MethodInfo;
if (methodInfo != null)
{
var returnType = methodInfo.ReturnType;
if (returnType.IsClass)
{
if (!returnType.IsSerializable)
{
throw new ArgumentException(
string.Format("Remote executor supports only serializable classes as method result[{0}]. Consider adding [Serializable] attribute.", returnType.FullName),
"method");
}
this.serializeResult = true;
}
}
var methodHandle = method.SerializeMethodHandle();
Log.TraceMessage(Log.Activity.Calling_initialize_on_remote_executor, string.Format("Calling initialize on remote executor. Method handle: '{0}'.", methodHandle.ToReadableString()));
this.Eid = this.Client.Initialize(methodHandle);
}