Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override bool RequestResolve(SiteControllerContext context)
        {
            string changeState = context.ScriptSettings.MappingState;

            context.CheckChangeState("RS_" + changeState);

            return true;
        }
Esempio n. 2
0
        /// <summary>
        /// This method initializes the request and resolves the request to the appropriate section.
        /// </summary>
        /// <param name="context">The current context.</param>
        public override void Initialize(SiteControllerContext context)
        {
            try
            {
                MappingSettings map;
                IDictionary<string, string> variables;

                //Resolve the incoming Uri from the scripts.
                bool resolved = context.ContextSettings.ResolvePath(
                    context.RequestServerType,
                    context.RequestURI,
                    context.RequestUserAgent,
                    context.RequestMethod,
                    out variables,
                    out map);

                context.ScriptSettings = map;
                context.ScriptRequestResolved = resolved;

                context.ScriptRequest.ResponseID = map.MappingID;
                context.ScriptRequest.ResponseTemplate = map.Template;

                //Add the variables for the request.
                foreach (KeyValuePair<string, string> item in variables)
                {
                    context.ScriptRequest.VariableAdd(item.Key, item.Value);
                }
                //Add any Uri or script query parameters
                if (map.VariableColl != null && map.VariableColl.Count > 0)
                {
                    foreach (VariableHolder vh in map.VariableColl)
                    {
                        switch (vh.VariableType)
                        {
                            case "parameter":
                                context.ScriptRequest.VariableAdd(vh.VariableID, vh.Variable);
                                break;
                            case "query":
                                context.ScriptRequest.RequestQueryParameterSet(vh.VariableID, vh.Variable);
                                break;
                        }
                    }
                }

                context.CheckChangeState("PR_" + map.ProtocolState);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }