Beispiel #1
0
 public static IO2HtmlPage submit(this IO2Browser o2Browser, IO2HtmlForm form)
 {
     /*"submiting form:{0}".format(form.name()).info();
      * "          to  :{0}".format(form.action()).debug();
      * "		   with:{0}".format(form.formData()).debug();
      */
     return(o2Browser.POST(form.action(), form.formData()));
 }
Beispiel #2
0
        public static List <string> fieldNamesAndValues(this IO2HtmlForm form)
        {
            var fieldNames = new List <string>();

            foreach (var field in form.FormFields)
            {
                fieldNames.Add("{0} = {1}".format(field.Name, field.Value));
            }
            return(fieldNames);
        }
Beispiel #3
0
        public static List <string> fieldNames(this IO2HtmlForm form)
        {
            var fieldNames = new List <string>();

            foreach (var field in form.FormFields)
            {
                fieldNames.Add(field.Name);
            }
            return(fieldNames);
        }
Beispiel #4
0
        public static Dictionary <string, IO2HtmlFormField> fields(this IO2HtmlForm form)
        {
            var fields = new Dictionary <string, IO2HtmlFormField>();

            foreach (var field in form.FormFields)
            {
                fields.Add(field.Name, field);
            }
            return(fields);
        }
Beispiel #5
0
 public static IO2HtmlFormField formField(this IO2HtmlForm form, string name, string type, string value, bool enabled)
 {
     return(new IE_Form_Field
     {
         Form = form,
         Name = name,
         Type = type,
         Value = value,
         Enabled = enabled
     });
 }
Beispiel #6
0
 public static string name(this IO2HtmlForm form)
 {
     if (form.Name.valid())
     {
         return(form.Name);
     }
     if (form.Id.valid())
     {
         return(form.Id);
     }
     return("");
 }
Beispiel #7
0
        public static string formData(this IO2HtmlForm form)
        {
            var formData = new StringBuilder();

            foreach (var field in form.FormFields)
            {
                formData.Append(string.Format("{0}={1}&", field.Name, WebEncoding.urlEncode(field.Value)));
            }
            formData.removeLastChar();

            return(formData.ToString());
        }
Beispiel #8
0
        public static string action(this IO2HtmlForm form)
        {
            // this is just a first pass at trying to map this value
            // maybe see if I can get IE to resolve this for me
            if (form.Action.starts(form.uri().page()))
            {
                return(form.uri().OriginalString);
            }


            return(form.Action);
        }
Beispiel #9
0
        public static string get(this IO2HtmlForm form, string fieldName)
        {
            var fields = form.fields();

            if (fields.ContainsKey(fieldName))
            {
                return(fields[fieldName].Value);
            }

            PublicDI.log.error("the provided IO2HtmlForm.form did not contain the field: {0}", fieldName);
            return("");
        }
Beispiel #10
0
        public static IO2HtmlForm remove(this IO2HtmlForm form, string name)
        {
            var fields = form.fields();

            if (fields.ContainsKey(name))
            {
                form.FormFields.Remove(fields[name]);
            }
            else
            {
                "in IO2HtmlForm form.remove(), could not find field: {0}".format(name).error();
            }
            return(form);
        }
Beispiel #11
0
 public static IO2HtmlFormField formField(this IO2HtmlForm form, object data)
 {
     /*"form field type: {0}".format(data.comTypeName()).error();
      * foreach(var prop in data.type().properties())
      *  "  p: {0}".format(prop.Name).debug();\*/
     try
     {
         object name     = null;
         object type     = null;
         object value    = null;
         object disabled = null;
         if (data is HTMLSelectElementClass)
         {
             name     = data.prop("name");
             type     = data.prop("type");
             value    = data.prop("value");
             disabled = data.prop("disabled");
         }
         else if (data is DispHTMLInputElement)
         {
             name     = ((DispHTMLInputElement)data).name;
             type     = ((DispHTMLInputElement)data).type;
             value    = ((DispHTMLInputElement)data).value;
             disabled = !((DispHTMLInputElement)data).disabled;
         }
         else
         {
             name     = data.prop("name");
             type     = data.prop("type");
             value    = data.prop("value");
             disabled = data.prop("disabled");
         }
         return(new IE_Form_Field
         {
             Form = form,
             Name = (name != null) ? name.ToString() : "",
             Type = (type != null) ? type.ToString() : "",
             Value = (value != null) ? value.ToString() : "",
             Enabled = (disabled != null) ? !bool.Parse(disabled.ToString()) : false
         });
     }
     catch (Exception ex)
     {
         ex.log("in formField");
         return(null);
     }
 }
Beispiel #12
0
 public static IO2HtmlForm set(this IO2HtmlForm form, string fieldName, string value)
 {
     try
     {
         var fields = form.fields();
         if (fields.ContainsKey(fieldName))
         {
             fields[fieldName].Value = value;
         }
         else
         {
             PublicDI.log.error("the provided IO2HtmlForm.form did not contain the field: {0}", fieldName);
         }
         return(form);
     }
     catch (Exception ex)
     {
         PublicDI.log.ex(ex, "in IO2HtmlForm.set");
         return(null);
     }
 }
 public static IO2HtmlPage submit(this IO2Browser o2Browser, IO2HtmlForm form)
 {
     /*"submiting form:{0}".format(form.name()).info();
     "          to  :{0}".format(form.action()).debug();
     "		   with:{0}".format(form.formData()).debug();        	
     */
     return o2Browser.POST(form.action(), form.formData());
 }
Beispiel #14
0
 public static string formDetails(this IO2HtmlForm form)
 {
     return(form.fieldNamesAndValues().str());
 }
Beispiel #15
0
 public static Uri uri(this IO2HtmlForm form)
 {
     return(form.PageUri);
 }