Esempio n. 1
0
        static RenderPipeline()
        {
            // add the default inbuilt commands
            Type type = typeof(IPipelineCommand);
            IEnumerable <Type> types = typeof(RenderPipeline).Assembly.GetTypes().Where(p => type.IsAssignableFrom(p) && p != type);

            foreach (Type t in types)
            {
                object[] attributes = t.GetCustomAttributes(typeof(PipelineCommandAttribute), false);
                string   name;
                if (attributes.Length == 0)
                {
                    // if no PipelineCommandAttribute set the command name to the class name with Command removed from the end.
                    name = t.Name;
                    if (name.EndsWith("Command"))
                    {
                        name = name.Substring(0, name.Length - 7);
                    }
                }
                else
                {
                    name = ((PipelineCommandAttribute)attributes[0]).Name;
                }
                if (_commandMap.ContainsKey(name))
                {
                    throw new ApplicationException(string.Format("Attempted to add command with duplicate name: {0}", name));
                }
                IPipelineCommand command = Activator.CreateInstance(t) as IPipelineCommand;
                _commandMap[name] = command;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Add a pipeline command getting its command name from a PipelineCommandAttribute, or its name with Command removed from the end.
        /// </summary>
        /// <param name="command"></param>
        public static void AddCommand(IPipelineCommand command)
        {
            object[] attributes = command.GetType().GetCustomAttributes(typeof(PipelineCommandAttribute), false);
            string   name;

            if (attributes.Length == 0)
            {
                // if no PipelineCommandAttribute set the command name to the class name with Command removed from the end.
                name = command.GetType().Name;
                if (name.EndsWith("Command"))
                {
                    name = name.Substring(0, name.Length - 7);
                }
            }
            else
            {
                name = ((PipelineCommandAttribute)attributes[0]).Name;
            }
            if (_commandMap.ContainsKey(name))
            {
                throw new ApplicationException(string.Format("Attempted to add command with duplicate name: {0}", name));
            }
            _commandMap[name] = command;
        }
Esempio n. 3
0
 public static void AddCommand(string name, IPipelineCommand command)
 {
     _commandMap[name] = command;
 }
        /// <summary>
        /// Event call from Worker Process, sends ReponseEventArgs to ResponseCallbackDelegate on callee.
        /// </summary>
        /// <param name="command"> The IPipelineCommand.</param>
        private void RequestCallback(IPipelineCommand command)
        {
            ScriptingResponseArgs args = new ScriptingResponseArgs();
            args.Context = ((ScriptingHttpState)command.HttpStateData).HttpRequestResponseContext;

            if ( args.Context.Request.WebResponse.ErrorMessage.Length == 0 )
            {
                // Saves Cookies
                _cookieManager.AddCookies(command.HttpResponseData.CookieCollection);
            }

            // Return response in a event
            ScriptingRequestClientResult(this, args);
        }
        /// <summary>
        /// Callback method that returns the IPipelineCommand from WorkerProcess and dynamically invokes the delegate associated with the state.
        /// </summary>
        /// <param name="command"> The IPipelineCommand.</param>
        private void WorkerProcess_PipelineCommandResultEvent(IPipelineCommand command)
        {
            Delegate method = command.CallbackMethod;
            object[] a = {command};

            try
            {
                method.DynamicInvoke(a);
            }
            catch ( Exception ex)
            {
                ExceptionHandler.RegisterException(ex);
            }
        }
        /// <summary>
        /// Event call from Worker Process, sends ReponseEventArgs to ResponseCallbackDelegate on callee.
        /// </summary>
        /// <param name="command"> The IPipelineCommand.</param>
        private void PipelineCallback(IPipelineCommand command)
        {
            ResponseEventArgs args = new ResponseEventArgs();
            args.Response = command.HttpResponseData;
            args.State = command.HttpStateData;

            if ( command.ErrorMessage.Length == 0 )
            {
                // Saves cookies
                _cookieManager.AddCookies(command.HttpResponseData.CookieCollection);
            }

            // return response in a event
            EndHttp(this, args);
        }
Esempio n. 7
0
 public static IPipelineCommand <TContext, TResult> ContinueWith <TContext, TResult>(this IPipelineCommand <TContext, TResult> command,
                                                                                     IPipelineCommand <TContext, TResult> next)
 {
     command.Next = next;
     return(next);
 }