Ejemplo n.º 1
0
        protected override bool Process(IInteraction parameters)
        {
            bool   success = true;
            object postDataObject;
            VerificationInteraction parsedData;

            string sourceName = GetSourceName(parameters);

            parsedData = new VerificationInteraction(parameters, sourceName, FieldExpressions, InteractionFallbackNames)
            {
                HtmlEscape = HtmlEscape
            };

            if (parameters.TryGetFallback(sourceName, out postDataObject))
            {
                parsedData [sourceName] = (Map <object>)postDataObject;
            }
            else
            {
                parsedData [sourceName] = Deserialize(AcquireData(parameters));
            }

            parsedData.LoadFields(FieldDefaults);

            if (parsedData.FaultyFields.Count == 0)
            {
                success &= DoSuccessfulForm(parsedData, parameters);
            }
            else
            {
                success &= DoFaultyForm(parsedData, parameters);
            }

            return(success);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows form for faulty input
        /// </summary>
        /// <returns><c>true</c>, if successfully shown form, <c>false</c> otherwise.</returns>
        /// <param name="parsedData">Parsed data.</param>
        /// <param name="parameters">Parameters.</param>
        private bool DoFaultyForm(VerificationInteraction parsedData, IInteraction parameters)
        {
            bool success = true;

            Encoding encoding;

            IInteraction outgoingCandidate;

            if (parameters.TryGetClosest(typeof(IOutgoingBodiedInteraction), out outgoingCandidate))
            {
                IOutgoingBodiedInteraction outgoing = (IOutgoingBodiedInteraction)outgoingCandidate;

                encoding = outgoing.Encoding;
            }
            else
            {
                encoding = Encoding.UTF8;
            }

            foreach (string fieldName in parsedData.FaultyFields)
            {
                string failName = string.Format("{0}_failure", fieldName);

                Service handler;
                FailureWrapperInteraction fwInteraction = null;
                IInteraction interaction = parameters;

                handler = FailureHandler ?? Branches [failName];

                if (handler != null)
                {
                    if (MapErrorStrings)
                    {
                        interaction = fwInteraction = new FailureWrapperInteraction(parameters, encoding);
                    }

                    if (FailureHandler != null)
                    {
                        SimpleInteraction failureInteraction;
                        interaction = failureInteraction = new SimpleInteraction(interaction);
                        failureInteraction ["failurename"] = failName;
                    }

                    success &= handler.TryProcess(interaction);

                    if (fwInteraction != null)
                    {
                        parsedData [failName] = fwInteraction.GetTextAndClose();
                    }
                }
            }

            return(success & Form.TryProcess(parsedData));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows form for successful input
        /// </summary>
        /// <returns><c>true</c>, if successfully shown form, <c>false</c> otherwise.</returns>
        /// <param name="parsedData">Parsed data.</param>
        /// <param name="parameters">Parameters.</param>
        private bool DoSuccessfulForm(VerificationInteraction parsedData, IInteraction parameters)
        {
            bool success = true;

            if (ShowFormBefore)
            {
                success &= Form.TryProcess(parsedData);
            }
            success &= Succesful.TryProcess(parsedData);
            if (ShowFormAfter)
            {
                success &= Form.TryProcess(parsedData);
            }

            return(success);
        }