Exemple #1
0
        public static T Create <T>(params IIntercept[] intercepts)
        {
            var result = Activator.CreateInstance(typeof(T));

            var myProxy = new MyProxy(result, typeof(T), intercepts);

            return((T)myProxy.GetTransparentProxy());
        }
Exemple #2
0
        public override MarshalByRefObject CreateInstance(Type serverType)
        {
            System.Console.WriteLine("Start!");
            var target = base.CreateInstance(serverType);
            List <IIntercept> intercepts = null;

            if (_types != null)
            {
                intercepts = new List <IIntercept>();
                intercepts.AddRange(_types.Select(s =>
                {
                    return((IIntercept)Activator.CreateInstance(s));
                }));
            }
            var myProxy = new MyProxy(target, serverType, intercepts?.ToArray());

            return((MarshalByRefObject)myProxy.GetTransparentProxy());
        }