Esempio n. 1
0
        public static object Call(StaticAdapter adapter, MethodBase method, params object[] args)
        {
            ObjectTypeHandle[] argHandles = Marshal(args);
            ObjectTypeHandle   resHandle  = adapter.InvokeMember(method, ref argHandles);

            Unmarshal(argHandles).CopyTo(args, 0);
            return(Unmarshal(resHandle));
        }
Esempio n. 2
0
        public static T GetProxy(StaticAdapter adapter)
        {
            if (!proxyType.IsAssignableFrom(adapter.ProxyType))
            {
                throw new ArgumentException("Wrong adapter type.", "adapter");
            }

            return(constructor(adapter));
        }
Esempio n. 3
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());
     }
 }
Esempio n. 4
0
 public StaticProxy(StaticAdapter adapter)
 {
     Adapter = adapter;
 }
Esempio n. 5
0
 /// <summary>
 /// Assigns a newly created proxy to a passed adapter, proxying all calls on it.
 /// </summary>
 /// <param name="adapter">The adapter to assign.</param>
 /// <returns>The new static proxy transmitting all calls on it to the adapter.</returns>
 public static StaticProxy CreateProxy(StaticAdapter adapter)
 {
     return(new StaticProxy(adapter));
 }
Esempio n. 6
0
 public MarshallerProxy(StaticAdapter adapter) : base(GetMarshalByRefType(adapter.ProxyType))
 {
     Adapter = adapter;
 }