Beispiel #1
0
        void Connect(IFormSubmitter submitter, StreamWriter stream)
        {
            foreach (var entry in _entries)
            {
                entry.Accept(submitter);
            }

            submitter.Serialize(stream);
        }
Beispiel #2
0
 /// <summary>
 /// Applies the given submitter to serialize the form data set.
 /// </summary>
 /// <param name="submitter">The algorithm to use.</param>
 /// <param name="encoding">(Optional) Explicit encoding.</param>
 /// <returns>A stream containing the body.</returns>
 public Stream As(IFormSubmitter submitter, Encoding encoding = null)
 {
     return(BuildRequestContent(encoding, stream => Connect(submitter, stream)));
 }
Beispiel #3
0
 public ReceiptFormSubmitter(IFormSubmitter formSubmitter)
 {
     _formSubmitter = formSubmitter;
 }
        public IList <ISourceValuePointer> GetServerVariables(ClassPointer root)
        {
            Dictionary <UInt32, IAction> actions = root.GetActions();
            SourceValuePointerList       svs     = new SourceValuePointerList();

            foreach (TaskID tid in Sect0)             //check client action return values
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        List <IAction> acts = hmid.HandlerMethod.GetActions();
                        foreach (IAction act in acts)
                        {
                            if (act.ReturnReceiver != null)
                            {
                                ISourceValuePointer sv = act.ReturnReceiver as ISourceValuePointer;
                                if (sv != null && sv.IsWebServerValue() && !sv.IsWebClientValue())
                                {
                                    svs.AddUnique(sv);
                                }
                            }
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null)
                    {
                        if (a.ReturnReceiver != null)
                        {
                            ISourceValuePointer sv = a.ReturnReceiver as ISourceValuePointer;
                            if (sv != null && sv.IsWebServerValue() && !sv.IsWebClientValue())
                            {
                                svs.AddUnique(sv);
                            }
                        }
                    }
                }
            }
            foreach (TaskID tid in Sect1)             //check server action parameters
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        hmid.HandlerMethod.CollectSourceValues(tid.TaskId);
                        //
                        svs.AddUnique(hmid.HandlerMethod.DownloadProperties);
                        //
                        List <MethodClass> ml = new List <MethodClass>();
                        hmid.HandlerMethod.GetCustomMethods(ml);
                        foreach (MethodClass m in ml)
                        {
                            m.CollectSourceValues(tid.TaskId);
                            svs.AddUnique(m.DownloadProperties);
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null && a.ActionMethod != null && a.ActionMethod.Owner != null)
                    {
                        IFormSubmitter fs = a.ActionMethod.Owner.ObjectInstance as IFormSubmitter;
                        if (fs != null && fs.IsSubmissionMethod(a.ActionMethod.MethodName))
                        {
                            continue;
                        }
                        svs.AddUnique(a.GetServerProperties(tid.TaskId));
                        ISourceValuePointer p = a.ReturnReceiver as ISourceValuePointer;
                        if (p != null)
                        {
                            if (p.IsWebServerValue())
                            {
                                svs.AddUnique(p);
                            }
                        }
                    }
                }
            }
            //collect download (server) variables from client actions
            foreach (TaskID tid in Sect2)
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        hmid.HandlerMethod.CollectSourceValues(tid.TaskId);
                        //
                        svs.AddUnique(hmid.HandlerMethod.DownloadProperties);
                        //
                        List <MethodClass> ml = new List <MethodClass>();
                        hmid.HandlerMethod.GetCustomMethods(ml);
                        foreach (MethodClass m in ml)
                        {
                            m.CollectSourceValues(tid.TaskId);
                            svs.AddUnique(m.DownloadProperties);
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null)
                    {
                        svs.AddUnique(a.GetServerProperties(tid.TaskId));
                    }
                }
            }
            return(svs);
        }
 /// <summary>
 /// Dependency injection to pass the type of submitter to use(.Net Core feature)
 /// </summary>
 /// <param name="formSubmitter"></param>
 public FormSubmitterController(IFormSubmitter formSubmitter)
 {
     _formsubmitter = formSubmitter;
 }