コード例 #1
0
 internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
 {
     if (_type.IsAppendingData(submitter))
     {
         _type.ConstructDataSet(dataSet);
     }
 }
コード例 #2
0
 private void showDiagram()
 {
     try
     {
         if (provider == null)
         {
             return;
         }
         IDataSetDesktop desktop = provider.Desktop;
         IDataSetFactory factory = DataSetFactoryChooser.Chooser[provider.FactoryName];
         DataSetService.Forms.FormDataSet form = new FormDataSet(desktop,
                                                                 new DataSetSerializable.DataDesktopSerializable(), factory, provider.ConnecionString);
         form.ShowDialog(this);
         desktop = form.Desktop;
         if (desktop != null)
         {
             provider.Desktop = desktop;
             string st = factory.GenerateStatement(desktop);
             textBoxStatement.Text = st;
         }
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
コード例 #3
0
ファイル: FileInputType.cs プロジェクト: sparra/AngleSharp
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (_files.Length == 0)
                dataSet.Append(Input.Name, String.Empty, MimeTypes.Binary);

            foreach (var file in _files)
                dataSet.Append(Input.Name, file, Input.Type);
        }
コード例 #4
0
 public override void ConstructDataSet(FormDataSet dataSet)
 {
     if (Input.IsChecked)
     {
         var value = Input.HasValue ? Input.Value : Keywords.On;
         dataSet.Append(Input.Name, value, Input.Type);
     }
 }
コード例 #5
0
ファイル: FileInputType.cs プロジェクト: JBTech/AngleSharp
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (_files.Length == 0)
                dataSet.Append(Input.Name, default(IFile), Input.Type);

            foreach (var file in _files)
                dataSet.Append(Input.Name, file, Input.Type);
        }
コード例 #6
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            base.ConstructDataSet(dataSet);
            var dirname = Input.GetAttribute(null, AttributeNames.DirName);

            if (!String.IsNullOrEmpty(dirname))
                dataSet.Append(dirname, Input.Direction.ToLowerInvariant(), "Direction");
        }
コード例 #7
0
        internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
        {
            var type = Type;

            if (Object.ReferenceEquals(this, submitter) && type.IsOneOf(InputTypeNames.Submit, InputTypeNames.Reset))
            {
                dataSet.Append(Name, Value, type);
            }
        }
コード例 #8
0
        protected void ConstructDataSet(FormDataSet dataSet, String type)
        {
            dataSet.Append(Name, Value, type);
            var dirname = this.GetOwnAttribute(AttributeNames.DirName);

            if (!String.IsNullOrEmpty(dirname))
            {
                dataSet.Append(dirname, Direction.ToString().ToLowerInvariant(), "Direction");
            }
        }
コード例 #9
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            base.ConstructDataSet(dataSet);
            var dirname = Input.GetAttribute(null, AttributeNames.DirName);

            if (!String.IsNullOrEmpty(dirname))
            {
                dataSet.Append(dirname, Input.Direction.ToLowerInvariant(), "Direction");
            }
        }
コード例 #10
0
ファイル: ImageInputType.cs プロジェクト: kk9599/AngleSharp
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            var name = Input.Name;
            var value = Input.Value;

            dataSet.Append(name + ".x", "0", Input.Type);
            dataSet.Append(name + ".y", "0", Input.Type);

            if (!String.IsNullOrEmpty(value))
                dataSet.Append(name, value, Input.Type);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: Suchiman/JsonFormPrototype
        private static byte[] ApplicationJsonEncode(FormDataSet formDataSet)
        {
            //1. Let resulting object be a new Object.
            var resultingObject = new JsonObject();

            //2. For each entry in the form data set, perform these substeps:
            foreach (var entry in formDataSet._entries)
            {
                //2.1. If the entry's type is file, set the is file flag.
                bool isFile = entry is FileDataSetEntry;

                TextDataSetEntry text = entry as TextDataSetEntry;
                FileDataSetEntry file = entry as FileDataSetEntry;
                JsonValue entryValue;
                if (text != null)
                {
                    entryValue = new JsonValue(text.Value);
                }
                else
                {
                    var stream = file.Value.Body;
                    MemoryStream ms = stream as MemoryStream;
                    if (ms == null)
                    {
                        ms = new MemoryStream();
                        stream.CopyTo(ms);
                    }
                    entryValue = new JsonValue(Convert.ToBase64String(ms.ToArray()));
                }

                //2.2. Let steps be the result of running the steps to parse a JSON encoding path on the entry's name.
                List<Step> steps = ParseJSONPath(entry.Name);

                //2.3. Let context be set to the value of resulting object.
                JsonElement context = resultingObject;

                //2.4. For each step in the list of steps, run the following subsubsteps:
                foreach (var step in steps)
                {
                    //2.4.1. Let the current value be the value obtained by getting the step's key from the current context.
                    JsonElement currentValue = context[step.Key];

                    //2.4.2. Run the steps to set a JSON encoding value with the current context, the step, the current value, the entry's value, and the is file flag.
                    //2.4.3. Update context to be the value returned by the steps to set a JSON encoding value ran above.
                    context = JsonEncodeValue(context, step, currentValue, entryValue, isFile);
                }
            }

            //3. Let result be the value returned from calling the stringify operation with resulting object as its first parameter and the two remaining parameters left undefined.
            string result = Stringify(resultingObject);

            //4. Encode result as UTF - 8 and return the resulting byte stream.
            return Encoding.UTF8.GetBytes(result);
        }
コード例 #12
0
ファイル: CheckedInputType.cs プロジェクト: sparra/AngleSharp
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (Input.IsChecked)
            {
                var value = Keywords.On;

                if (!String.IsNullOrEmpty(Input.Value))
                    value = Input.Value;

                dataSet.Append(Input.Name, value, Input.Type);
            }
        }
コード例 #13
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (_files.Length == 0)
            {
                dataSet.Append(Input.Name, String.Empty, MimeTypes.Binary);
            }

            foreach (var file in _files)
            {
                dataSet.Append(Input.Name, file, Input.Type);
            }
        }
コード例 #14
0
        internal override void ConstructDataSet(FormDataSet dataSet, HtmlElement submitter)
        {
            for (int i = 0; i < _options.Length; i++)
            {
                var option = _options.GetOptionAt(i);

                if (option.IsSelected && !option.IsDisabled)
                {
                    dataSet.Append(Name, option.Value, Type);
                }
            }
        }
コード例 #15
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (_files.Length == 0)
            {
                dataSet.Append(Input.Name, default(IFile), Input.Type);
            }

            foreach (var file in _files)
            {
                dataSet.Append(Input.Name, file, Input.Type);
            }
        }
コード例 #16
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            var name  = Input.Name;
            var value = Input.Value;

            dataSet.Append(name + ".x", "0", Input.Type);
            dataSet.Append(name + ".y", "0", Input.Type);

            if (!String.IsNullOrEmpty(value))
            {
                dataSet.Append(name !, value, Input.Type);
            }
        }
コード例 #17
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (!String.IsNullOrEmpty(Input.Name))
            {
                var name = String.Empty;

                if (!String.IsNullOrEmpty(Input.Value))
                    name = Input.Value + ".";

                dataSet.Append(name + "x", "0", Input.Type);
                dataSet.Append(name + "y", "0", Input.Type);
            }
        }
コード例 #18
0
        FormDataSet ConstructDataSet(IHtmlElement submitter)
        {
            var formDataSet = new FormDataSet();

            foreach (var field in Elements)
            {
                if (field.ParentElement is IHtmlDataListElement == false && field.IsDisabled == false)
                {
                    field.ConstructDataSet(formDataSet, submitter);
                }
            }

            return(formDataSet);
        }
コード例 #19
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (Input.IsChecked)
            {
                var value = Keywords.On;

                if (!String.IsNullOrEmpty(Input.Value))
                {
                    value = Input.Value;
                }

                dataSet.Append(Input.Name, value, Input.Type);
            }
        }
コード例 #20
0
        /// <summary>
        /// Constucts the data set (called from a form).
        /// </summary>
        /// <param name="dataSet">The dataset to construct.</param>
        /// <param name="submitter">The given submitter.</param>
        internal override void ConstructDataSet(FormDataSet dataSet, HtmlElement submitter)
        {
            if (this == submitter)
            {
                return;
            }

            var type = Type.ToEnum(ButtonType.Submit);

            if (type == ButtonType.Submit || type == ButtonType.Reset)
            {
                dataSet.Append(Name, Value, Type.ToString());
            }
        }
コード例 #21
0
        private FormDataSet ConstructDataSet(IHtmlElement submitter)
        {
            var formDataSet = new FormDataSet();
            var fields      = this.GetNodes <HtmlFormControlElement>();

            foreach (var field in fields)
            {
                if (!field.IsDisabled && field.ParentElement is IHtmlDataListElement == false && Object.ReferenceEquals(field.Form, this))
                {
                    field.ConstructDataSet(formDataSet, submitter);
                }
            }

            return(formDataSet);
        }
コード例 #22
0
ファイル: ImageInputType.cs プロジェクト: mganss/AngleSharp
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (!String.IsNullOrEmpty(Input.Name))
            {
                var name = String.Empty;

                if (!String.IsNullOrEmpty(Input.Value))
                {
                    name = Input.Value + ".";
                }

                dataSet.Append(name + "x", "0", Input.Type);
                dataSet.Append(name + "y", "0", Input.Type);
            }
        }
コード例 #23
0
        /// <summary>
        /// Creates a POST request for the given target with the fields being
        /// used to generate the body and encoding type plaintext.
        /// </summary>
        /// <param name="target">The target to use.</param>
        /// <param name="fields">The fields to send.</param>
        /// <returns>The new document request.</returns>
        public static DocumentRequest PostAsPlaintext(Url target, IDictionary <String, String> fields)
        {
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }

            var fds = new FormDataSet();

            foreach (var field in fields)
            {
                fds.Append(field.Key, field.Value, InputTypeNames.Text);
            }

            return(Post(target, fds.AsPlaintext(), MimeTypes.Plain));
        }
コード例 #24
0
        public static ResponseCollection ClearItemDataResponse(
            Context context, SiteSettings ss, long id)
        {
            var formDataSet = new FormDataSet(
                context: context,
                ss: ss);
            var res = new ResponseCollection().ClearFormData("Id");

            formDataSet
            .Where(o => !o.Suffix.IsNullOrEmpty())
            .Where(o => o.Id == id)
            .ForEach(formData =>
                     formData.Data.Keys.ForEach(controlId =>
                                                res.ClearFormData(controlId + formData.Suffix)));
            return(res);
        }
コード例 #25
0
        public static Stream Encode(FormDataSet formDataSet, Encoding[] supportedEncodings, string acceptCharset, Encoding documentEncoding)
        {
            var result = new StringBuilder();

            var selectedEncoding = SelectEncoding(formDataSet, supportedEncodings, acceptCharset, documentEncoding);

            var charset = GetPreferredMimeName(selectedEncoding);

            var entryIndex = -1;

            foreach (var entry in formDataSet)
            {
                SubSteps(entry, entryIndex++, selectedEncoding, ref result);
            }

            return(new MemoryStream(Encoding.ASCII.GetBytes(result.ToString())));
        }
コード例 #26
0
        static Stream CreateBody(String enctype, Encoding encoding, FormDataSet formDataSet)
        {
            if (enctype.Equals(MimeTypes.UrlencodedForm, StringComparison.OrdinalIgnoreCase))
            {
                return(formDataSet.AsUrlEncoded(encoding));
            }
            else if (enctype.Equals(MimeTypes.MultipartForm, StringComparison.OrdinalIgnoreCase))
            {
                return(formDataSet.AsMultipart(encoding));
            }
            else if (enctype.Equals(MimeTypes.Plain, StringComparison.OrdinalIgnoreCase))
            {
                return(formDataSet.AsPlaintext(encoding));
            }

            return(MemoryStream.Null);
        }
コード例 #27
0
        public override void ConstructDataSet(FormDataSet dataSet)
        {
            if (!String.IsNullOrEmpty(Input.Name))
            {
                var name = String.Empty;

                if (!String.IsNullOrEmpty(Input.Value))
                {
                    name = Input.Value + ".";
                }

                var namex = name + "x";
                var namey = name + "y";

                //TODO get x and y of submitter and save those
                dataSet.Append(namex, "0", Input.Type);
                dataSet.Append(namey, "0", Input.Type);
            }
        }
コード例 #28
0
        /// <summary>
        /// Constructs the form data set with the given submitter.
        /// </summary>
        /// <param name="submitter">[Optional] The submitter to use.</param>
        /// <returns>The constructed form data set.</returns>
        FormDataSet ConstructDataSet(HtmlElement submitter = null)
        {
            var formDataSet = new FormDataSet();

            foreach (var field in Elements)
            {
                if (field.ParentElement is IHtmlDataListElement)
                {
                    continue;
                }
                else if (field.IsDisabled)
                {
                    continue;
                }

                field.ConstructDataSet(formDataSet, submitter);
            }

            return(formDataSet);
        }
コード例 #29
0
        public static Stream CreateBody(this FormDataSet formDataSet, String enctype, Encoding encoding)
        {
            if (enctype.Isi(MimeTypeNames.UrlencodedForm))
            {
                return(formDataSet.AsUrlEncoded(encoding));
            }
            else if (enctype.Isi(MimeTypeNames.MultipartForm))
            {
                return(formDataSet.AsMultipart(encoding));
            }
            else if (enctype.Isi(MimeTypeNames.Plain))
            {
                return(formDataSet.AsPlaintext(encoding));
            }
            else if (enctype.Isi(MimeTypeNames.ApplicationJson))
            {
                return(formDataSet.AsJson());
            }

            return(MemoryStream.Null);
        }
コード例 #30
0
        private static Encoding SelectEncoding(FormDataSet formDataSet, IEnumerable <Encoding> supportedEncodings, string acceptCharset, Encoding documentEncoding)
        {
            if (acceptCharset != null)
            {
                string[] tokens = Html5Utility.SplitStringOnSpaces(acceptCharset);

                var encodings = tokens.Select(Encoding.GetEncoding)
                                .Where(e => e != null)
                                .Where(e => supportedEncodings == null || supportedEncodings.Any(se => e.GetType() == se.GetType()))
                                .Where(IsAsciiCompatible);

                return(encodings.FirstOrDefault() ?? Encoding.UTF8);
            }
            else if (IsAsciiCompatible(documentEncoding))
            {
                return(documentEncoding);
            }
            else
            {
                return(Encoding.UTF8);
            }
        }
コード例 #31
0
 public static HtmlBuilder GridRows(
     this HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     List <Column> columns,
     EnumerableRowCollection <DataRow> dataRows,
     FormDataSet formDataSet = null,
     bool editRow            = false,
     bool checkRow           = true)
 {
     dataRows.ForEach(dataRow =>
                      hb.Tr(
                          context: context,
                          ss: ss,
                          columns: columns,
                          dataRow: dataRow,
                          recordSelector: new RecordSelector(context),
                          editRow: editRow,
                          checkRow: checkRow,
                          idColumn: Rds.IdColumn(ss.ReferenceType),
                          formDataSet: formDataSet));
     return(hb);
 }
コード例 #32
0
        FormDataSet ConstructDataSet(IHtmlElement submitter)
        {
            var formDataSet = new FormDataSet();
            var fields = this.GetElements<HtmlFormControlElement>();

            foreach (var field in fields)
            {
                if (!field.IsDisabled && field.ParentElement is IHtmlDataListElement == false && Object.ReferenceEquals(field.Form, this))
                {
                    field.ConstructDataSet(formDataSet, submitter);
                }
            }

            return formDataSet;
        }
コード例 #33
0
 /// <summary>
 /// Constucts the data set (called from a form).
 /// </summary>
 /// <param name="dataSet">The dataset to construct.</param>
 /// <param name="submitter">The given submitter.</param>
 internal override void ConstructDataSet(FormDataSet dataSet, HtmlElement submitter)
 {
     ConstructDataSet(dataSet, Type);
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: Suchiman/JsonFormPrototype
 static void Example5()
 {
     FormDataSet set = new FormDataSet();
     set.Append("pet[0][species]", "Dahut", "text");
     set.Append("pet[0][name]", "Hypatia", "text");
     set.Append("pet[1][species]", "Felis Stultus", "text");
     set.Append("pet[1][name]", "Billie", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"pet\":[{\"species\":\"Dahut\",\"name\":\"Hypatia\"},{\"species\":\"Felis Stultus\",\"name\":\"Billie\"}]}" == result);
 }
コード例 #35
0
        public static Stream CreateBody(this FormDataSet formDataSet, String enctype, String charset)
        {
            var encoding = TextEncoding.Resolve(charset);

            return(formDataSet.CreateBody(enctype, encoding));
        }
コード例 #36
0
ファイル: HTMLSelectElement.cs プロジェクト: rrsc/AngleSharp
        internal override void ConstructDataSet(FormDataSet dataSet, HTMLElement submitter)
        {
            var options = _options.Elements;

            foreach (var option in options)
            {
                if (option.Selected && !option.Disabled)
                    dataSet.Append(Name, option.Value, Multiple ? "select-one" : "select-multiple");
            }
        }
コード例 #37
0
ファイル: Program.cs プロジェクト: Suchiman/JsonFormPrototype
 static void Example8()
 {
     FormDataSet set = new FormDataSet();
     set.Append("highlander[]", "one", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"highlander\":[\"one\"]}" == result);
 }
コード例 #38
0
        protected void ConstructDataSet(FormDataSet dataSet, String type)
        {
            dataSet.Append(Name, Value, type);
            var dirname = this.GetOwnAttribute(AttributeNames.DirName);

            if (!String.IsNullOrEmpty(dirname))
                dataSet.Append(dirname, Direction.ToString().ToLowerInvariant(), "Direction");
        }
コード例 #39
0
ファイル: HtmlFormElement.cs プロジェクト: kk9599/AngleSharp
        static Stream CreateBody(String enctype, Encoding encoding, FormDataSet formDataSet)
        {
            if (enctype.Equals(MimeTypes.UrlencodedForm, StringComparison.OrdinalIgnoreCase))
                return formDataSet.AsUrlEncoded(encoding);
            else if (enctype.Equals(MimeTypes.MultipartForm, StringComparison.OrdinalIgnoreCase))
                return formDataSet.AsMultipart(encoding);
            else if (enctype.Equals(MimeTypes.Plain, StringComparison.OrdinalIgnoreCase))
                return formDataSet.AsPlaintext(encoding);
            else if (enctype.Equals(MimeTypes.ApplicationJson, StringComparison.OrdinalIgnoreCase))
                return formDataSet.AsJson();

            return MemoryStream.Null;
        }
コード例 #40
0
        public static Stream CreateBody(this FormDataSet formDataSet, String enctype, String?charset, IHtmlEncoder?htmlEncoder)
        {
            var encoding = TextEncoding.Resolve(charset);

            return(formDataSet.CreateBody(enctype, encoding, htmlEncoder ?? new DefaultHtmlEncoder()));
        }
コード例 #41
0
ファイル: DocumentRequest.cs プロジェクト: tsu1980/AngleSharp
        /// <summary>
        /// Creates a POST request for the given target with the fields being
        /// used to generate the body and encoding type multipart.
        /// </summary>
        /// <param name="target">The target to use.</param>
        /// <param name="fields">The fields to send.</param>
        /// <returns>The new document request.</returns>
        public static DocumentRequest PostAsMultipart(Url target, IDictionary<String, object> fields)
        {
            if (fields == null)
                throw new ArgumentNullException("fields");

            var fds = new FormDataSet();

            foreach (var field in fields)
            {
                if (field.Value is AngleSharp.Dom.Io.IFile)
                    fds.Append(field.Key, (AngleSharp.Dom.Io.IFile)field.Value, InputTypeNames.File);
                else
                    fds.Append(field.Key, (String)field.Value, InputTypeNames.Text);
            }

            var enctype = String.Concat(MimeTypes.MultipartForm, "; boundary=", fds.Boundary);
            return Post(target, fds.AsMultipart(), enctype);
        }
コード例 #42
0
 /// <summary>
 /// Constucts the data set (called from a form).
 /// </summary>
 /// <param name="dataSet">The dataset to construct.</param>
 /// <param name="submitter">The given submitter.</param>
 internal virtual void ConstructDataSet(FormDataSet dataSet, HtmlElement submitter)
 {
 }
コード例 #43
0
ファイル: HtmlInputElement.cs プロジェクト: Wojdav/AngleSharp
 internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
 {
     if (_type.IsAppendingData(submitter))
     {
         _type.ConstructDataSet(dataSet);
     }
 }
コード例 #44
0
ファイル: HtmlSelectElement.cs プロジェクト: howej/AngleSharp
        internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
        {
            var options = Options;

            for (int i = 0; i < options.Length; i++)
            {
                var option = options.GetOptionAt(i);

                if (option.IsSelected && !option.IsDisabled)
                    dataSet.Append(Name, option.Value, Type);
            }
        }
コード例 #45
0
ファイル: HTMLInputElement.cs プロジェクト: rrsc/AngleSharp
        /// <summary>
        /// Constucts the data set (called from a form).
        /// </summary>
        /// <param name="dataSet">The dataset to construct.</param>
        /// <param name="submitter">The given submitter.</param>
        internal override void ConstructDataSet(FormDataSet dataSet, HTMLElement submitter)
        {
            switch (Type)
            {
                case InputType.Radio:
                case InputType.Checkbox:
                {
                    if (Checked)
                    {
                        var value = "on";

                        if (!String.IsNullOrEmpty(Value))
                            value = Value;

                        dataSet.Append(Name, value, Type.ToString());
                    }

                    break;
                }
                case InputType.Image:
                {
                    if (!String.IsNullOrEmpty(Name))
                    {
                        var name = String.Empty;

                        if (!String.IsNullOrEmpty(Value))
                            name = Value + ".";

                        var namex = name + "x";
                        var namey = name + "y";

                        //TODO get x and y of submitter and save those
                        dataSet.Append(namex, "0", Type.ToString());
                        dataSet.Append(namey, "0", Type.ToString());
                    }

                    break;
                }
                case InputType.File:
                {
                    if(_files.Length == 0)
                        dataSet.Append(Name, String.Empty, "application/octet-stream");

                    foreach (var file in _files)
                        dataSet.Append(Name, file, Type.ToString());

                    break;
                }
                case InputType.Text:
                case InputType.Search:
                {
                    dataSet.Append(Name, Value, Type.ToString());

                    if (_attributes[AttributeNames.DIRNAME] != null)
                    {
                        var dirname = _attributes[AttributeNames.DIRNAME].Value;

                        if (String.IsNullOrEmpty(dirname))
                            break;

                        dataSet.Append(dirname, Dir.ToString().ToLower(), "Direction");
                    }

                    break;
                }
                default:
                {
                    dataSet.Append(Name, Value, Type.ToString());
                    break;
                }
            }
        }
コード例 #46
0
        static Stream CreateBody(String enctype, Encoding encoding, FormDataSet formDataSet)
        {
            if (enctype.Isi(MimeTypeNames.UrlencodedForm))
            {
                return formDataSet.AsUrlEncoded(encoding);
            }
            else if (enctype.Isi(MimeTypeNames.MultipartForm))
            {
                return formDataSet.AsMultipart(encoding);
            }
            else if (enctype.Isi(MimeTypeNames.Plain))
            {
                return formDataSet.AsPlaintext(encoding);
            }
            else if (enctype.Isi(MimeTypeNames.ApplicationJson))
            {
                return formDataSet.AsJson();
            }

            return MemoryStream.Null;
        }
コード例 #47
0
        /// <summary>
        /// Constucts the data set (called from a form).
        /// </summary>
        /// <param name="dataSet">The dataset to construct.</param>
        /// <param name="submitter">The given submitter.</param>
        internal override void ConstructDataSet(FormDataSet dataSet, HTMLElement submitter)
        {
            dataSet.Append(Name, Value, Type.ToString());

            if (_attributes[AttributeNames.DIRNAME] != null)
            {
                var dirname = _attributes[AttributeNames.DIRNAME].Value;

                if (String.IsNullOrEmpty(dirname))
                    return;

                dataSet.Append(dirname, Dir.ToString().ToLower(), "Direction");
            }
        }
コード例 #48
0
 /// <summary>
 /// Constucts the data set (called from a form).
 /// </summary>
 /// <param name="dataSet">The dataset to construct.</param>
 /// <param name="submitter">The given submitter.</param>
 internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
 {
     ConstructDataSet(dataSet, Type);
 }
コード例 #49
0
ファイル: HTMLFormElement.cs プロジェクト: rrsc/AngleSharp
        FormDataSet ConstructDataSet(HTMLElement submitter = null)
        {
            var formDataSet = new FormDataSet();
            var fields = _elements.Elements;

            foreach (var field in fields)
            {
                if (field.ParentElement is HTMLDataListElement)
                    continue;
                else if (field.Disabled)
                    continue;

                field.ConstructDataSet(formDataSet, submitter);
            }

            return formDataSet;
        }
コード例 #50
0
ファイル: HTMLButtonElement.cs プロジェクト: rrsc/AngleSharp
 /// <summary>
 /// Constucts the data set (called from a form).
 /// </summary>
 /// <param name="dataSet">The dataset to construct.</param>
 /// <param name="submitter">The given submitter.</param>
 internal override void ConstructDataSet(FormDataSet dataSet, HTMLElement submitter)
 {
     if (this == submitter)
         return;
     else if (Type == ButtonType.Submit || Type == ButtonType.Reset)
         dataSet.Append(Name, Value, Type.ToString());
 }
コード例 #51
0
ファイル: Program.cs プロジェクト: Suchiman/JsonFormPrototype
 static void Example7()
 {
     FormDataSet set = new FormDataSet();
     set.Append("mix", "scalar", "text");
     set.Append("mix[0]", "array 1", "text");
     set.Append("mix[2]", "array 2", "text");
     set.Append("mix[key]", "key key", "text");
     set.Append("mix[car]", "car key", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"mix\":{\"\":\"scalar\",\"0\":\"array 1\",\"2\":\"array 2\",\"key\":\"key key\",\"car\":\"car key\"}}" == result);
 }
コード例 #52
0
ファイル: Program.cs プロジェクト: Suchiman/JsonFormPrototype
 static void Example6()
 {
     FormDataSet set = new FormDataSet();
     set.Append("wow[such][deep][3][much][power][!]", "Amaze", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"wow\":{\"such\":{\"deep\":[null,null,null,{\"much\":{\"power\":{\"!\":\"Amaze\"}}}]}}}" == result);
 }
コード例 #53
0
ファイル: DocumentRequest.cs プロジェクト: Wojdav/AngleSharp
        /// <summary>
        /// Creates a POST request for the given target with the fields being
        /// used to generate the body and encoding type plaintext.
        /// </summary>
        /// <param name="target">The target to use.</param>
        /// <param name="fields">The fields to send.</param>
        /// <returns>The new document request.</returns>
        public static DocumentRequest PostAsPlaintext(Url target, IDictionary<String, String> fields)
        {
            if (fields == null)
                throw new ArgumentNullException(nameof(fields));

            var fds = new FormDataSet();

            foreach (var field in fields)
            {
                fds.Append(field.Key, field.Value, InputTypeNames.Text);
            }

            return Post(target, fds.AsPlaintext(), MimeTypeNames.Plain);
        }
コード例 #54
0
 public virtual void ConstructDataSet(FormDataSet dataSet)
 {
     dataSet.Append(_input.Name, _input.Value, _input.Type);
 }
コード例 #55
0
ファイル: DocumentRequest.cs プロジェクト: sparra/AngleSharp
        /// <summary>
        /// Creates a POST request for the given target with the fields being
        /// used to generate the body and encoding type url encoded.
        /// </summary>
        /// <param name="target">The target to use.</param>
        /// <param name="fields">The fields to send.</param>
        /// <returns>The new document request.</returns>
        public static DocumentRequest PostAsUrlencoded(Url target, IDictionary<String, String> fields)
        {
            if (fields == null)
                throw new ArgumentNullException("fields");

            var fds = new FormDataSet();

            foreach (var field in fields)
                fds.Append(field.Key, field.Value, InputTypeNames.Text);

            return Post(target, fds.AsUrlEncoded(), MimeTypes.UrlencodedForm);
        }
コード例 #56
0
ファイル: BaseInputType.cs プロジェクト: zzc000/AngleSharp
 public virtual void ConstructDataSet(FormDataSet dataSet)
 {
     dataSet.Append(_input.Name, _input.Value, _input.Type);
 }
コード例 #57
0
 internal virtual void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
 { }
コード例 #58
0
        public static HtmlBuilder Tr(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            DataRow dataRow,
            IEnumerable <Column> columns,
            bool editRow,
            bool checkRow,
            string idColumn,
            RecordSelector recordSelector = null,
            FormDataSet formDataSet       = null)
        {
            var dataId      = dataRow.Long(idColumn);
            var dataVersion = dataRow.Int("Ver");
            var isHistory   = dataRow.Bool("IsHistory");
            var EditColumns = !isHistory
                ? columns.ToDictionary(
                column => column.ColumnName,
                column => EditColumn(
                    context: context,
                    column: column))
                : new Dictionary <string, bool>();

            BaseItemModel rowModel = null;

            switch (ss.ReferenceType)
            {
            case "Issues":
                var issueModel = new IssueModel(
                    context: context,
                    ss: ss,
                    dataRow: dataRow,
                    formData: editRow
                            ? formDataSet?.FirstOrDefault(o =>
                                                          o.Id == dataRow.Long("IssueId"))?.Data
                            : null);
                ss.SetColumnAccessControls(
                    context: context,
                    mine: issueModel.Mine(context: context));
                rowModel = issueModel;
                break;

            case "Results":
                var resultModel = new ResultModel(
                    context: context,
                    ss: ss,
                    dataRow: dataRow,
                    formData: editRow
                            ? formDataSet?.FirstOrDefault(o =>
                                                          o.Id == dataRow.Long("ResultId"))?.Data
                            : null);
                ss.SetColumnAccessControls(
                    context: context,
                    mine: resultModel.Mine(context: context));
                rowModel = resultModel;
                break;
            }
            ;
            var serverScriptRowValues = rowModel?.SetByBeforeOpeningPageServerScript(
                context: context,
                ss: ss);
            var extendedRowCss = serverScriptRowValues?.ExtendedRowCss;

            extendedRowCss = extendedRowCss.IsNullOrEmpty() ? string.Empty : " " + extendedRowCss;
            return(hb.Tr(
                       attributes: new HtmlAttributes()
                       .Class("grid-row" + extendedRowCss)
                       .DataId(dataId.ToString())
                       .DataVer(dataVersion)
                       .DataLatest(1, _using: !isHistory)
                       .Add(name: "data-history", value: "1", _using: isHistory)
                       .Add(name: "data-locked", value: "1", _using: dataRow.Bool("Locked")),
                       action: () =>
            {
                if (editRow)
                {
                    hb.Td(action: () => hb
                          .Button(
                              title: Displays.Reload(context: context),
                              controlCss: "button-icon",
                              onClick: $"$p.getData($(this)).Id={dataId};$p.send($(this));",
                              icon: "ui-icon-refresh",
                              action: "ReloadRow",
                              method: "post",
                              _using: !isHistory)
                          .Button(
                              title: Displays.Copy(context: context),
                              controlCss: "button-icon",
                              onClick: $"$p.getData($(this)).OriginalId={dataId};$p.send($(this));",
                              icon: "ui-icon-copy",
                              action: "CopyRow",
                              method: "post",
                              _using: !isHistory && context.CanCreate(ss: ss))
                          .Hidden(
                              controlId: $"{ss.ReferenceType}_Timestamp_{ss.SiteId}_{dataId}",
                              css: "timestamp",
                              value: dataRow
                              .Field <DateTime>("UpdatedTime")
                              .ToString("yyyy/M/d H:m:s.fff")));
                }
                else if (checkRow)
                {
                    hb.Td(action: () => hb
                          .CheckBox(
                              controlCss: "grid-check",
                              _checked: recordSelector.Checked(dataId),
                              dataId: dataId.ToString(),
                              _using: !isHistory));
                }
                var depts = new Dictionary <string, DeptModel>();
                var groups = new Dictionary <string, GroupModel>();
                var registrations = new Dictionary <string, RegistrationModel>();
                var users = new Dictionary <string, UserModel>();
                var sites = new Dictionary <string, SiteModel>();
                var issues = new Dictionary <string, IssueModel>();
                var results = new Dictionary <string, ResultModel>();
                ServerScriptModelRow serverScriptValues = null;
                columns.ForEach(column =>
                {
                    var key = column.TableName();
                    switch (column.SiteSettings?.ReferenceType)
                    {
                    case "Depts":
                        var deptModel = depts.Get(key);
                        if (deptModel == null)
                        {
                            deptModel = new DeptModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                tableAlias: column.TableAlias);
                            depts.Add(key, deptModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: deptModel.Mine(context: context));
                            serverScriptValues = deptModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        hb.TdValue(
                            context: context,
                            ss: column.SiteSettings,
                            column: column,
                            deptModel: deptModel);
                        break;

                    case "Groups":
                        var groupModel = groups.Get(key);
                        if (groupModel == null)
                        {
                            groupModel = new GroupModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                tableAlias: column.TableAlias);
                            groups.Add(key, groupModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: groupModel.Mine(context: context));
                            serverScriptValues = groupModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        hb.TdValue(
                            context: context,
                            ss: column.SiteSettings,
                            column: column,
                            groupModel: groupModel);
                        break;

                    case "Registrations":
                        var registrationModel = registrations.Get(key);
                        if (registrationModel == null)
                        {
                            registrationModel = new RegistrationModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                tableAlias: column.TableAlias);
                            registrations.Add(key, registrationModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: registrationModel.Mine(context: context));
                            serverScriptValues = registrationModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        hb.TdValue(
                            context: context,
                            ss: column.SiteSettings,
                            column: column,
                            registrationModel: registrationModel);
                        break;

                    case "Users":
                        var userModel = users.Get(key);
                        if (userModel == null)
                        {
                            userModel = new UserModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                tableAlias: column.TableAlias);
                            users.Add(key, userModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: userModel.Mine(context: context));
                            serverScriptValues = userModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        hb.TdValue(
                            context: context,
                            ss: column.SiteSettings,
                            column: column,
                            userModel: userModel);
                        break;

                    case "Sites":
                        var siteModel = sites.Get(key);
                        if (siteModel == null)
                        {
                            siteModel = new SiteModel(
                                context: context,
                                dataRow: dataRow,
                                formData: editRow
                                            ? formDataSet?.FirstOrDefault(o =>
                                                                          o.Id == dataRow.Long("SiteId"))?.Data
                                            : null,
                                tableAlias: column.TableAlias);
                            sites.Add(key, siteModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: siteModel.Mine(context: context));
                            serverScriptValues = siteModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        hb.TdValue(
                            context: context,
                            ss: column.SiteSettings,
                            column: column,
                            siteModel: siteModel);
                        break;

                    case "Issues":
                        var issueModel = issues.Get(key);
                        if (issueModel == null)
                        {
                            issueModel = new IssueModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                formData: editRow
                                            ? formDataSet?.FirstOrDefault(o =>
                                                                          o.Id == dataRow.Long("IssueId"))?.Data
                                            : null,
                                tableAlias: column.TableAlias);
                            issues.Add(key, issueModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: issueModel.Mine(context: context));
                            serverScriptValues = issueModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        if (!issueModel.Locked && EditColumns.Get(column.ColumnName) && column.CanUpdate(baseModel: issueModel))
                        {
                            hb.Td(
                                css: column.TextAlign == SiteSettings.TextAlignTypes.Right
                                            ? " right-align"
                                            : string.Empty,
                                action: () => hb.Field(
                                    context: context,
                                    column: column,
                                    issueModel: issueModel,
                                    ss: column.SiteSettings,
                                    controlOnly: true,
                                    idSuffix: issueModel.IdSuffix()));
                        }
                        else
                        {
                            hb.TdValue(
                                context: context,
                                ss: column.SiteSettings,
                                column: column,
                                issueModel: issueModel,
                                serverScriptValues: serverScriptValues
                                ?.Columns
                                ?.Get(column?.ColumnName));
                        }
                        break;

                    case "Results":
                        var resultModel = results.Get(key);
                        if (resultModel == null)
                        {
                            resultModel = new ResultModel(
                                context: context,
                                ss: column.SiteSettings,
                                dataRow: dataRow,
                                formData: editRow
                                            ? formDataSet?.FirstOrDefault(o =>
                                                                          o.Id == dataRow.Long("ResultId"))?.Data
                                            : null,
                                tableAlias: column.TableAlias);
                            results.Add(key, resultModel);
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: resultModel.Mine(context: context));
                            serverScriptValues = resultModel.SetByBeforeOpeningPageServerScript(
                                context: context,
                                ss: ss);
                        }
                        if (!resultModel.Locked && EditColumns.Get(column.ColumnName) && column.CanUpdate(baseModel: resultModel))
                        {
                            hb.Td(
                                css: column.TextAlign == SiteSettings.TextAlignTypes.Right
                                            ? " right-align"
                                            : string.Empty,
                                action: () => hb.Field(
                                    context: context,
                                    column: column,
                                    resultModel: resultModel,
                                    ss: column.SiteSettings,
                                    controlOnly: true,
                                    idSuffix: resultModel.IdSuffix()));
                        }
                        else
                        {
                            hb.TdValue(
                                context: context,
                                ss: column.SiteSettings,
                                column: column,
                                resultModel: resultModel,
                                serverScriptValues: serverScriptValues
                                ?.Columns
                                ?.Get(column?.ColumnName));
                        }
                        break;
                    }
                });
            }));
        }
コード例 #59
0
ファイル: HtmlButtonElement.cs プロジェクト: howej/AngleSharp
        /// <summary>
        /// Constucts the data set (called from a form).
        /// </summary>
        /// <param name="dataSet">The dataset to construct.</param>
        /// <param name="submitter">The given submitter.</param>
        internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter)
        {
            var type = Type;

            if (Object.ReferenceEquals(this, submitter) && type.IsOneOf(InputTypeNames.Submit, InputTypeNames.Reset))
                dataSet.Append(Name, Value, type);
        }