コード例 #1
0
ファイル: TaskAdapter.cs プロジェクト: studentutu/SharpUtils
        public static Task CreateTask(TaskAdapter adapter)
        {
            Type           resType = adapter.ResultType;
            TaskMarshaller marshal;

            if (resType != null)
            {
                marshal = (TaskMarshaller)Activator.CreateInstance(TaskMarshaller.Type.MakeGenericType(resType));
            }
            else
            {
                marshal = new TaskMarshaller <NoResult>();
            }
            adapter.RegisterMarshaller(marshal);
            return(marshal.Task);
        }
コード例 #2
0
 public static object Unmarshal(ObjectHandle arg)
 {
     if (arg == null)
     {
         return(null);
     }
     else
     {
         DelegateAdapter delAd = arg as DelegateAdapter;
         if (delAd != null)
         {
             return(DelegateAdapter.CreateDelegate(delAd));
         }
         TaskAdapter taskAd = arg as TaskAdapter;
         if (taskAd != null)
         {
             return(TaskAdapter.CreateTask(taskAd));
         }
         DynamicAdapter dynAd = arg as DynamicAdapter;
         if (dynAd != null)
         {
             return(DynamicAdapter.CreateProxy(dynAd));
         }
         StaticAdapter statAd = arg as StaticAdapter;
         if (statAd != null)
         {
             return(StaticAdapter.CreateProxy(statAd));
         }
         UnsafeHandle uns = arg as UnsafeHandle;
         if (uns != null)
         {
             return(UnsafeHandle.GetObject(uns));
         }
         return(arg.Unwrap());
     }
 }