| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Linq; |
| | | 4 | | using System.Runtime.Serialization; |
| | | 5 | | using System.Text; |
| | | 6 | | |
| | | 7 | | namespace ImpromptuInterface.Build |
| | | 8 | | { |
| | | 9 | | #if !SILVERLIGHT |
| | | 10 | | |
| | | 11 | | |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Support Deserializing the proxy since on separate runs of an executable |
| | | 15 | | /// </summary> |
| | | 16 | | [Serializable] |
| | | 17 | | public class ActLikeProxySerializationHelper : IObjectReference |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Original Object |
| | | 21 | | /// </summary> |
| | | 22 | | public object Original; |
| | | 23 | | /// <summary> |
| | | 24 | | /// Intefaces |
| | | 25 | | /// </summary> |
| | | 26 | | public Type[] Interfaces; |
| | | 27 | | /// <summary> |
| | | 28 | | /// Interfaces by name for Mono workaround |
| | | 29 | | /// </summary> |
| | | 30 | | public string[] MonoInterfaces; |
| | | 31 | | /// <summary> |
| | | 32 | | /// Type Context |
| | | 33 | | /// </summary> |
| | | 34 | | public Type Context; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Returns the real object that should be deserialized, rather than the object that the serialized stream speci |
| | | 38 | | /// </summary> |
| | | 39 | | /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> from which the curre |
| | | 40 | | /// <returns> |
| | | 41 | | /// Returns the actual object that is put into the graph. |
| | | 42 | | /// </returns> |
| | | 43 | | /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. The |
| | | 44 | | public object GetRealObject(StreamingContext context) |
| | | 45 | | { |
| | 0 | 46 | | var tInterfaces = Interfaces ?? MonoInterfaces.Select(it=>Type.GetType(it)).ToArray(); |
| | 0 | 47 | | var tType =BuildProxy.DefaultProxyMaker.BuildType(Context, tInterfaces.First(), tInterfaces.Skip(1).ToArray() |
| | 0 | 48 | | return ActLikeMaker.InitializeProxy(tType, Original, tInterfaces, maker:BuildProxy.DefaultProxyMaker); |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | } |
| | | 52 | | #endif |
| | | 53 | | } |