Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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");
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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);
     }
 }
Exemplo n.º 11
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");
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
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");
            }
        }
Exemplo n.º 15
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);
                }
            }
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
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());
            }
        }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
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));
        }
Exemplo n.º 20
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(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);
        }
        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");
        }
Exemplo n.º 22
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");
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Constructs 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)
        {
            var type = Type.ToEnum(InputType.Text);

            switch (type)
            {
                case InputType.Radio:
                case InputType.Checkbox:
                {
                    if (IsChecked)
                    {
                        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.Count == 0)
                        dataSet.Append(Name, String.Empty, MimeTypes.Binary);

                    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 (HasAttribute(AttributeNames.DirName))
                    {
                        var dirname = GetAttribute(AttributeNames.DirName);

                        if (String.IsNullOrEmpty(dirname))
                            break;

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

                    break;
                }
                default:
                {
                    dataSet.Append(Name, Value, Type.ToString());
                    break;
                }
            }
        }
Exemplo n.º 24
0
 static void Example1()
 {
     FormDataSet set = new FormDataSet();
     set.Append("name", "Bender", "text");
     set.Append("hind", "Bitable", "checkbox");
     set.Append("shiny", "true", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"name\":\"Bender\",\"hind\":\"Bitable\",\"shiny\":\"true\"}" == result);
 }
Exemplo n.º 25
0
        /// <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);
        }
Exemplo n.º 26
0
 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);
 }
Exemplo n.º 27
0
        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);
            }
        }
Exemplo n.º 28
0
 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);
 }
Exemplo n.º 29
0
 public virtual void ConstructDataSet(FormDataSet dataSet)
 {
     dataSet.Append(_input.Name, _input.Value, _input.Type);
 }
Exemplo n.º 30
0
 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);
 }
Exemplo n.º 31
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)
        {
            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;
                }
            }
        }
Exemplo n.º 32
0
 static void Example2()
 {
     FormDataSet set = new FormDataSet();
     set.Append("bottle-on-wall", "1", "number");
     set.Append("bottle-on-wall", "2", "number");
     set.Append("bottle-on-wall", "3", "number");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"bottle-on-wall\":[1,2,3]}" == result);
 }
Exemplo n.º 33
0
 static void Example10()
 {
     FormDataSet set = new FormDataSet();
     set.Append("error[good]", "BOOM!", "text");
     set.Append("error[bad", "BOOM BOOM!", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"error\":{\"good\":\"BOOM!\"},\"error[bad\":\"BOOM BOOM!\"}" == result);
 }
Exemplo n.º 34
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)
        {
            var type = Type;

            if (Object.ReferenceEquals(this, submitter) && type.IsOneOf(InputTypeNames.Submit, InputTypeNames.Reset))
                dataSet.Append(Name, Value, type);
        }
Exemplo n.º 35
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 (HasAttribute(AttributeNames.DirName))
            {
                var dirname = GetAttribute(AttributeNames.DirName);

                if (String.IsNullOrEmpty(dirname))
                    return;

                dataSet.Append(dirname, Direction.ToString().ToLower(), "Direction");
            }
        }
Exemplo n.º 36
0
 static void Example4()
 {
     FormDataSet set = new FormDataSet();
     set.Append("hearbeat[0]", "thunk", "text");
     set.Append("hearbeat[2]", "thunk", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"hearbeat\":[\"thunk\",null,\"thunk\"]}" == result);
 }
Exemplo n.º 37
0
 static void Example3()
 {
     FormDataSet set = new FormDataSet();
     set.Append("pet[species]", "Dahut", "text");
     set.Append("pet[name]", "Hypatia", "text");
     set.Append("kids[1]", "Thelma", "text");
     set.Append("kids[0]", "Ashley", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"pet\":{\"species\":\"Dahut\",\"name\":\"Hypatia\"},\"kids\":[\"Ashley\",\"Thelma\"]}" == result);
 }
Exemplo n.º 38
0
 static void Example8()
 {
     FormDataSet set = new FormDataSet();
     set.Append("highlander[]", "one", "text");
     var result = Encoding.UTF8.GetString(ApplicationJsonEncode(set));
     Debug.Assert("{\"highlander\":[\"one\"]}" == result);
 }
Exemplo n.º 39
0
 public virtual void ConstructDataSet(FormDataSet dataSet)
 {
     dataSet.Append(_input.Name, _input.Value, _input.Type);
 }
Exemplo n.º 40
0
        /// <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);
        }
Exemplo n.º 41
0
        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");
            }
        }
Exemplo n.º 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 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());
 }