コード例 #1
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            if (OperationCache == null)
            {
                return(InnerOperationInvoker.InvokeEnd(instance, out outputs, result));
            }

            OperationCachingInvokerAsyncResult asyncResult = result as OperationCachingInvokerAsyncResult;

            if (asyncResult == null)
            {
                throw new ArgumentException("Invalid AsyncResult", "result");
            }
            OperationCachingInvokerAsyncResult.End(asyncResult);

            if (asyncResult.IsNewResult)
            {
                OperationCacheKey   key   = new OperationCacheKey(asyncResult.Action, asyncResult.Inputs);
                OperationCacheValue value = new OperationCacheValue(asyncResult.Outputs, asyncResult.ReturnValue);
                OperationCache.Insert(key, value);
            }

            outputs = asyncResult.Outputs;
            return(asyncResult.ReturnValue);
        }
コード例 #2
0
        public object Invoke(object instance, object[] inputs, out object[] outputs)
        {
            if (OperationCache == null)
            {
                return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
            }

            OperationCacheKey   key   = new OperationCacheKey(action, inputs);
            OperationCacheValue value = OperationCache.Lookup(key);

            // if it's not in the cache, invoke and then add to the cache.
            if (value == null)
            {
                Console.WriteLine("Not in the cache. Creating new and caching.");
                object returnValue = InnerOperationInvoker.Invoke(instance, inputs, out outputs);
                value = new OperationCacheValue(outputs, returnValue);
                OperationCache.Insert(key, value);
                return(returnValue);
            }

            // otherwise, just return the data
            Console.WriteLine("In cache; returning cache instance.");
            outputs = value.Outputs;
            return(value.ReturnValue);
        }
コード例 #3
0
 //- @Invoke -//
 public Object Invoke(Object instance, Object[] inputs, out Object[] outputs)
 {
     //+ authorization
     try
     {
         if (this.PermissionLevel == Minima.Service.PermissionLevel.Blog)
         {
             String blogGuid = MinimaMessageHeaderHelper.GetBlogGuidFromMessageHeader();
             SecurityValidator.ValidateBlogPermission(this.PermissionRequired, blogGuid);
         }
         else if (this.PermissionLevel == Minima.Service.PermissionLevel.System)
         {
             SecurityValidator.ValidateSystemPermission(this.PermissionRequired);
         }
     }
     catch (SecurityException exception)
     {
         FaultThrower.Throw <SecurityException>(exception);
     }
     catch (ArgumentException exception)
     {
         FaultThrower.Throw <ArgumentException>(exception);
     }
     //+
     return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
 }
コード例 #4
0
        //- @Invoke -//
        public Object Invoke(Object instance, Object[] inputs, out Object[] outputs)
        {
            // Security by passed temporarily. Need to test it properly.

            /*   //+ authorization
             * MessageHeaders messageHeadersElement = OperationContext.Current.IncomingMessageHeaders;
             * Int32 id = messageHeadersElement.FindHeader("UserName", "") + messageHeadersElement.FindHeader("Password", "");
             * if (id > -1)
             * {
             *     String username = messageHeadersElement.GetHeader<String>("UserName", "");
             *     String password = messageHeadersElement.GetHeader<String>("Password", "");
             *     //  SecurityValidator.Authenticate(username, password);
             *
             *     //+
             *     return InnerOperationInvoker.Invoke(instance, inputs, out outputs);
             * }
             *
             * FaultDetail faultDetail = new FaultDetail
             * {
             *     Type = "Unauthorized access of the service",
             *     ErrorCode = 63873928
             * };     //+ throw
             *
             * throw new FaultException<FaultDetail>(faultDetail, "Unauthorized access of the service");      */

            return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
        }
コード例 #5
0
        public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state)
        {
            if (OperationCache == null)
            {
                return(InnerOperationInvoker.InvokeBegin(instance, inputs, callback, state));
            }

            OperationCacheKey   key   = new OperationCacheKey(action, inputs);
            OperationCacheValue value = OperationCache.Lookup(key);

            // if it's not in the cache, let the async invoke and let the end handle caching
            if (value == null)
            {
                return(new OperationCachingInvokerAsyncResult(instance, action, inputs, innerOperationInvoker, callback, state));
            }

            // otherwise, just pass all the data to the async result and let it complete synchronously
            return(new OperationCachingInvokerAsyncResult(instance, action, inputs, value.ReturnValue, value.Outputs, callback, state));
        }
コード例 #6
0
 public object[] AllocateInputs()
 {
     return(InnerOperationInvoker.AllocateInputs());
 }
コード例 #7
0
 //- @InvokeEnd -//
 public Object InvokeEnd(Object instance, out Object[] outputs, IAsyncResult result)
 {
     return(InnerOperationInvoker.InvokeEnd(instance, out outputs, result));
 }
コード例 #8
0
 //- @InvokeBegin -//
 public IAsyncResult InvokeBegin(Object instance, Object[] inputs, AsyncCallback callback, Object state)
 {
     return(InnerOperationInvoker.InvokeBegin(instance, inputs, callback, state));
 }