Пример #1
0
        /// <summary>
        /// Creates a default wrapped data service context without registering SendingRequest(2) event.
        /// </summary>
        /// <param name="scope">DataServiceContext TrackingScope</param>
        /// <param name="dataServiceContextType">The type of the DataServiceContext instance to be created</param>
        /// <param name="serviceBaseUri">service BaseUri</param>
        /// <returns>Wrapped DataServiceContext</returns>
        public WrappedDataServiceContext CreateContextWithoutSendingRequest(IWrapperScope scope, Type dataServiceContextType, Uri serviceBaseUri)
        {
            ExceptionUtilities.CheckAllRequiredDependencies(this);
            ExceptionUtilities.CheckArgumentNotNull(scope, "scope");
            ExceptionUtilities.CheckArgumentNotNull(dataServiceContextType, "dataServiceContextType");
            ExceptionUtilities.Assert(typeof(DataServiceContext).IsAssignableFrom(dataServiceContextType), "Given type did not derive from DataServiceContext");

            WrappedDataServiceContext ctx     = scope.CreateDataServiceContext(dataServiceContextType, serviceBaseUri, this.MaxProtocolVersion);
            DataServiceContext        context = ctx.Product as DataServiceContext;

            this.SetCredentials(context);
            this.authenticationHeaders = this.AuthenticationProvider.GetAuthenticationHeaders();

            this.SetAcceptAndContentTypeHeaders(context);
            //ctx.UndeclaredPropertyBehavior = this.UndeclaredPropertyBehavior;

            this.FormatApplier.Apply(context);

            if (this.FormatApplier.IsUsingContentType(MimeTypes.ApplicationJsonLight))
            {
                // Setup the resolver.
                context.ResolveType = (name) => dataServiceContextType.Assembly.GetType(name);
                context.ResolveName = (type) => type.Namespace + "." + type.Name;
            }

#if !WINDOWS_PHONE
            if (this.EntitySetResolver != null)
            {
                ctx.ResolveEntitySet = this.EntitySetResolver.ResolveEntitySetUri;
            }
#endif
            return(ctx);
        }
Пример #2
0
        /// <summary>
        /// Creates a default wrapped data service context.
        /// </summary>
        /// <param name="scope">DataServiceContext TrackingScope</param>
        /// <param name="dataServiceContextType">The type of the DataServiceContext instance to be created</param>
        /// <param name="serviceBaseUri">service BaseUri</param>
        /// <returns>Wrapped DataServiceContext</returns>
        public virtual WrappedDataServiceContext CreateContext(IWrapperScope scope, Type dataServiceContextType, Uri serviceBaseUri)
        {
            WrappedDataServiceContext ctx = this.CreateContextWithoutSendingRequest(scope, dataServiceContextType, serviceBaseUri);

            this.RegisterSendingRequestEvent(ctx);
            return(ctx);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the WrappedObject class.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="product">The product.</param>
        public WrappedObject(IWrapperScope wrapperScope, object product)
        {
            ExceptionUtilities.CheckObjectNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckObjectNotNull(product, "product");

            this.Scope   = wrapperScope;
            this.Product = product;
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the OrderedQueryableProxy class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
 public OrderedQueryableProxy(IWrapperScope wrapperScope, System.Linq.IOrderedQueryable underlyingImplementation)
 {
     ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
     ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");
     
     this.Scope = wrapperScope;
     this.underlyingImplementation = underlyingImplementation;
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the EnumerableProxy class.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
        public EnumerableProxy(IWrapperScope wrapperScope, System.Collections.IEnumerable underlyingImplementation)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");

            this.Scope = wrapperScope;
            this.underlyingImplementation = underlyingImplementation;
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the QueryableProxy class.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
        public QueryableProxy(IWrapperScope wrapperScope, System.Linq.IQueryable underlyingImplementation)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");

            this.Scope = wrapperScope;
            this.underlyingImplementation = underlyingImplementation;
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the EnumeratorProxy class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
 public EnumeratorProxy(IWrapperScope wrapperScope, System.Collections.IEnumerator underlyingImplementation)
 {
     ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
     ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");
     
     this.Scope = wrapperScope;
     this.underlyingImplementation = underlyingImplementation;
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the StreamProxy class.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
        public StreamProxy(IWrapperScope wrapperScope, System.IO.Stream underlyingImplementation)
            : base()
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");

            this.Scope = wrapperScope;
            this.underlyingImplementation = underlyingImplementation;
        }
Пример #9
0
        /// <summary>
        /// Creates and wraps the entity instance for a given CLR type.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="entityClrType">Type of the entity CLR.</param>
        /// <returns>Wrapper for newly created entity instance.</returns>
        public static WrappedEntityInstance CreateEntityInstance(this IWrapperScope wrapperScope, Type entityClrType)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(entityClrType, "entityClrType");

            object entityInstance = Activator.CreateInstance(entityClrType);

            return(wrapperScope.Wrap <WrappedEntityInstance>(entityInstance));
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the StreamProxy class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
 public StreamProxy(IWrapperScope wrapperScope, System.IO.Stream underlyingImplementation)
     : base()
 {
     ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
     ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");
     
     this.Scope = wrapperScope;
     this.underlyingImplementation = underlyingImplementation;
 }
Пример #11
0
        /// <summary>
        /// Creates the data service context instance for a given type and URI and wraps it.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="contextType">Type of the context.</param>
        /// <param name="serviceUri">The service URI.</param>
        /// <param name="maxProtocolVersion">max protocol version that the client understands.</param>
        /// <returns>Wrapped object context object.</returns>
        public static WrappedDataServiceContext CreateDataServiceContext(this IWrapperScope wrapperScope, Type contextType, Uri serviceUri, DataServiceProtocolVersion maxProtocolVersion)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(contextType, "contextType");

            object dataServiceContext = null;

            if (maxProtocolVersion != DataServiceProtocolVersion.Unspecified)
            {
                dataServiceContext = Activator.CreateInstance(contextType, serviceUri, maxProtocolVersion.ToProductEnum());
            }
            else
            {
                dataServiceContext = Activator.CreateInstance(contextType, serviceUri);
            }

            return(wrapperScope.Wrap <WrappedDataServiceContext>(dataServiceContext));
        }
Пример #12
0
        /// <summary>
        /// Returns a proxy that wraps the given instance
        /// </summary>
        /// <param name="scope">the wrapper scope to use</param>
        /// <param name="instance">the instance to wrap with an proxy</param>
        /// <param name="hintType">optional type hint in case the instance implements multiple interfaces</param>
        /// <returns>A proxy or the original instance if no proxy could be built</returns>
        public static object CreateProxyIfPossible(IWrapperScope scope, object instance, Type hintType)
        {
            ExceptionUtilities.CheckArgumentNotNull(scope, "scope");
            ExceptionUtilities.CheckArgumentNotNull(instance, "instance");

            var instanceType = instance.GetType();

            if (hintType == null)
            {
                hintType = instanceType;
            }
            else
            {
                ExceptionUtilities.Assert(hintType.IsAssignableFrom(instanceType), "Invalid hint type for given instance");
            }

            var genericArguments = instanceType.GetGenericArguments();

            foreach (var typePair in proxyTypes)
            {
                if (typePair.Key.IsGenericTypeDefinition())
                {
                    if (typePair.Key.GetGenericArguments().Length != genericArguments.Length)
                    {
                        continue;
                    }

                    var genericType = typePair.Key.MakeGenericType(genericArguments);
                    if (hintType.IsAssignableFrom(genericType) && genericType.IsAssignableFrom(instanceType))
                    {
                        return(Activator.CreateInstance(typePair.Value.MakeGenericType(genericArguments), scope, instance));
                    }
                }
                else if (hintType.IsAssignableFrom(typePair.Key) && typePair.Key.IsAssignableFrom(instanceType))
                {
                    return(Activator.CreateInstance(typePair.Value, scope, instance));
                }
            }

            return(instance);
        }
Пример #13
0
 /// <summary>
 /// Returns a proxy that wraps the given instance
 /// </summary>
 /// <param name="scope">the wrapper scope to use</param>
 /// <param name="instance">the instance to wrap with an proxy</param>
 /// <param name="hintType">optional type hint in case the instance implements multiple interfaces</param>
 /// <returns>A proxy or the original instance if no proxy could be built</returns>
 public static object CreateProxyIfPossible(IWrapperScope scope, object instance, Type hintType)
 {
     ExceptionUtilities.CheckArgumentNotNull(scope, "scope");
     ExceptionUtilities.CheckArgumentNotNull(instance, "instance");
     
     var instanceType = instance.GetType();
     if (hintType == null)
     {
         hintType = instanceType;
     }
     else
     {
         ExceptionUtilities.Assert(hintType.IsAssignableFrom(instanceType), "Invalid hint type for given instance");
     }
     
     var genericArguments = instanceType.GetGenericArguments();
     foreach (var typePair in proxyTypes)
     {
         if (typePair.Key.IsGenericTypeDefinition())
         {
             if (typePair.Key.GetGenericArguments().Length != genericArguments.Length)
             {
                 continue;
             }
             
             var genericType = typePair.Key.MakeGenericType(genericArguments);
             if (hintType.IsAssignableFrom(genericType) && genericType.IsAssignableFrom(instanceType))
             {
                 return Activator.CreateInstance(typePair.Value.MakeGenericType(genericArguments), scope, instance);
             }
         }
         else if (hintType.IsAssignableFrom(typePair.Key) && typePair.Key.IsAssignableFrom(instanceType))
         {
             return Activator.CreateInstance(typePair.Value, scope, instance);
         }
     }
     
     return instance;
 }
Пример #14
0
        /// <summary>
        /// Creates the data service context instance for a given type and URI and wraps it.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="contextType">Type of the context.</param>
        /// <param name="serviceUri">The service URI.</param>
        /// <param name="maxProtocolVersion">max protocol version that the client understands.</param>
        /// <returns>Wrapped object context object.</returns>
        public static WrappedDataServiceContext CreateDataServiceContext(this IWrapperScope wrapperScope, Type contextType, Uri serviceUri, DataServiceProtocolVersion maxProtocolVersion)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(contextType, "contextType");

            object dataServiceContext = null;

#if !WINDOWS_PHONE && !WIN8
            if (maxProtocolVersion != DataServiceProtocolVersion.Unspecified)
            {
                dataServiceContext = Activator.CreateInstance(contextType, serviceUri, maxProtocolVersion.ToProductEnum());
            }
            else
#endif
            {
#if WIN8
                // In win8 CreateInstance fails to find container constructor taking serviceRoot and DataServiceProtocolVersion, add this to ensure that the tests that need to specify non-V3 version work around the issue
                ExceptionUtilities.Assert(maxProtocolVersion == DataServiceProtocolVersion.V4, "Win8 DataServiceProtocolVersion");
#endif
                dataServiceContext = Activator.CreateInstance(contextType, serviceUri);
            }

            return(wrapperScope.Wrap <WrappedDataServiceContext>(dataServiceContext));
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the WrappedIList class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIList(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the WrappedOperationParameter class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedOperationParameter(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the WrappedLinkInfo class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedLinkInfo(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the WrappedOperationDescriptor class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedOperationDescriptor(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the WrappedIQueryProvider class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIQueryProvider(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceQuery class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceQuery(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the WrappedIEnumerator class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIEnumerator(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the WrappedEntityInstance class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedEntityInstance(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
        /// <summary>
        /// Creates a default wrapped data service context without registering SendingRequest(2) event.
        /// </summary>
        /// <param name="scope">DataServiceContext TrackingScope</param>
        /// <param name="dataServiceContextType">The type of the DataServiceContext instance to be created</param>
        /// <param name="serviceBaseUri">service BaseUri</param>
        /// <returns>Wrapped DataServiceContext</returns>
        public WrappedDataServiceContext CreateContextWithoutSendingRequest(IWrapperScope scope, Type dataServiceContextType, Uri serviceBaseUri)
        {
            ExceptionUtilities.CheckAllRequiredDependencies(this);
            ExceptionUtilities.CheckArgumentNotNull(scope, "scope");
            ExceptionUtilities.CheckArgumentNotNull(dataServiceContextType, "dataServiceContextType");
            ExceptionUtilities.Assert(typeof(DataServiceContext).IsAssignableFrom(dataServiceContextType), "Given type did not derive from DataServiceContext");

            WrappedDataServiceContext ctx = scope.CreateDataServiceContext(dataServiceContextType, serviceBaseUri, this.MaxProtocolVersion);
            DataServiceContext context = ctx.Product as DataServiceContext;

            this.SetCredentials(context);
            this.authenticationHeaders = this.AuthenticationProvider.GetAuthenticationHeaders();

            this.SetAcceptAndContentTypeHeaders(context);
            ctx.IgnoreMissingProperties = this.IgnoreMissingProperties;

            this.FormatApplier.Apply(context);

            if (this.FormatApplier.IsUsingContentType(MimeTypes.ApplicationJsonLight))
            {
                // Setup the resolver.
                context.ResolveType = (name) => dataServiceContextType.Assembly.GetType(name);
                context.ResolveName = (type) => type.Namespace + "." + type.Name;
            }

#if !WINDOWS_PHONE
            if (this.EntitySetResolver != null)
            {
                ctx.ResolveEntitySet = this.EntitySetResolver.ResolveEntitySetUri;
            }
#endif
            return ctx;
        }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the WrappedIDisposable class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIDisposable(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
 /// <summary>
 /// Creates a default wrapped data service context.
 /// </summary>
 /// <param name="scope">DataServiceContext TrackingScope</param>
 /// <param name="dataServiceContextType">The type of the DataServiceContext instance to be created</param>
 /// <param name="serviceBaseUri">service BaseUri</param>
 /// <returns>Wrapped DataServiceContext</returns>
 public virtual WrappedDataServiceContext CreateContext(IWrapperScope scope, Type dataServiceContextType, Uri serviceBaseUri)
 {
     WrappedDataServiceContext ctx = this.CreateContextWithoutSendingRequest(scope, dataServiceContextType, serviceBaseUri);
     this.RegisterSendingRequestEvent(ctx);
     return ctx;
 }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the WrappedArray class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="product">The product.</param>
 public WrappedArray(IWrapperScope wrapperScope, object product)
     : base(wrapperScope, product)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedUriOperationParameter class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedUriOperationParameter(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceResponse class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceResponse(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the WrappedEntityInstance class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedEntityInstance(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the WrappedArray class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 protected WrappedArray(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #31
0
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceRequest class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceRequest(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the WrappedLinkDescriptor class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedLinkDescriptor(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceStreamLink class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceStreamLink(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedFunctionDescriptor class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedFunctionDescriptor(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #35
0
        private static TReturn TryWrapArbitraryMethodCall <TReturn>(LambdaExpression callExpression, Func <TReturn> realWork)
        {
            ExceptionUtilities.CheckArgumentNotNull(callExpression, "callExpression");
            ExceptionUtilities.CheckObjectNotNull(realWork, "realWork");

            var methodCall = callExpression.Body as MethodCallExpression;

            ExceptionUtilities.CheckObjectNotNull(methodCall, "Expression must be a method call");
            var methodInfo = methodCall.Method;

            object instance = null;

            if (methodCall.Object != null)
            {
                instance = ExtractConstantValue(methodCall.Object);
            }

            IWrapperScope scope   = CurrentScope;
            var           wrapped = instance as IWrappedObject;

            if (wrapped != null)
            {
                scope = wrapped.Scope;
            }

            if (scope == null)
            {
                return(realWork());
            }

            var argumentList = new List <object>();

            foreach (var argumentExpression in methodCall.Arguments)
            {
                argumentList.Add(ExtractConstantValue(argumentExpression));
            }

            var arguments = argumentList.ToArray();

            int callId = scope.BeginTraceCall(methodInfo, instance, arguments);

            try
            {
                var result = realWork();

                if (callId != 0)
                {
                    object returnValue = result;
                    scope.TraceResult(callId, methodInfo, instance, arguments, ref returnValue);
                    result = (TReturn)returnValue;
                }

                return(result);
            }
            catch (Exception exception)
            {
                if (callId != 0)
                {
                    scope.TraceException(callId, methodInfo, instance, exception.GetBaseException());
                }

                throw;
            }
        }
Пример #36
0
 /// <summary>
 /// Initializes a new instance of the WrappedLinkInfo class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedLinkInfo(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #37
0
 /// <summary>
 /// Initializes a new instance of the WrappedEnum class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="product">The product.</param>
 public WrappedEnum(IWrapperScope wrapperScope, object product)
     : base(wrapperScope, product)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceStreamLink class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceStreamLink(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #39
0
 /// <summary>
 /// Initializes a new instance of the WrappedLinkDescriptor class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedLinkDescriptor(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #40
0
 /// <summary>
 /// Initializes a new instance of the WrappedIDisposable class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIDisposable(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #41
0
 /// <summary>
 /// Initializes a new instance of the WrappedEnum class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="product">The product.</param>
 public WrappedEnum(IWrapperScope wrapperScope, object product)
     : base(wrapperScope, product)
 {
 }
Пример #42
0
 /// <summary>
 /// Initializes a new instance of the WrappedIEnumerable class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIEnumerable(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #43
0
 /// <summary>
 /// Initializes a new instance of the WrappedArray class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 protected WrappedArray(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #44
0
 /// <summary>
 /// Initializes a new instance of the WrappedICollection class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedICollection(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #45
0
 /// <summary>
 /// Initializes a new instance of the WrappedQueryOperationResponse class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedQueryOperationResponse(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceQueryContinuation class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceQueryContinuation(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #47
0
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceQuery class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceQuery(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
     this.TrackEvents = new EventsTracker(this);
 }
Пример #48
0
 /// <summary>
 /// Initializes a new instance of the WrappedICollection class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedICollection(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #49
0
 /// <summary>
 /// Initializes a new instance of the WrappedDataServiceQuery class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedDataServiceQuery(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
     this.TrackEvents = new EventsTracker(this);
 }
Пример #50
0
 /// <summary>
 /// Initializes a new instance of the WrappedIQueryable class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIQueryable(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }
Пример #51
0
 /// <summary>
 /// Initializes a new instance of the WrappedIQueryable class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="wrappedInstance">The wrapped instance.</param>
 public WrappedIQueryable(IWrapperScope wrapperScope, object wrappedInstance)
     : base(wrapperScope, wrappedInstance)
 {
 }