示例#1
0
        public static object Unmarshal(this MarshalledStream stream)
        {
            object obj;
            var    hr = CoGetInterfaceAndReleaseStream(stream.Stream, ref IID_IUnknown, out obj);

            if (hr != 0)
            {
                System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(hr);
            }

            return((object)obj);
        }
示例#2
0
        public static void RunAsMarshalled <T>(this MarshalledStream stream, Action <T> action)
        {
            if (Thread.CurrentThread.ManagedThreadId == stream.MarshalledFromThread.ManagedThreadId)
            {
                action((T)stream.MarshalledObject);
            }
            else
            {
                var obj = Unmarshal <T>(stream.Stream);

                action((T)obj);
            }
        }
示例#3
0
 public static T Unmarshal <T>(this MarshalledStream stream)
 {
     return(Unmarshal <T>(stream.Stream));
 }