Beispiel #1
0
 public Uri CreateUri(Uri uri, Nparams param)
 {
     var schema = Schema;
     if (schema == null)
         throw new NullReferenceException("Schema");
     return schema.CreateUri(this, uri, param);
 }
        public HtmlBuilder o_Table(Nparams args)
        {
            _writeCount++;
            var lastTableState = _tableTag;

            _tableTag = CreateHtmlBuilderTableTag(this, args);
            string caption;

            if (args != null)
            {
                caption = args.Slice <string>("caption");
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                caption = string.Empty;
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cellpadding, "0");
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cellspacing, "0");
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Table);
            if (caption.Length > 0)
            {
                _textWriter.RenderBeginTag(HtmlTextWriterTag.Caption);
                _textWriter.WriteEncodedText(caption);
                _textWriter.RenderEndTag();
            }
            ElementPush(HtmlTag.Table, lastTableState);
            return(this);
        }
Beispiel #3
0
 public string CreateVirtualPath(string virtualPath, Nparams param)
 {
     var schema = Schema;
     if (schema == null)
         throw new NullReferenceException("Schema");
     return schema.CreateVirtualPath(this, virtualPath, param);
 }
 //public void AddAttribute(params string[] args) { AddAttribute(Nparams.Parse(args), null); }
 public void AddAttribute(Nparams args, string[] throwOnAttributes)
 {
     if (args == null)
     {
         throw new ArgumentNullException("args");
     }
     //foreach (string key in attrib.KeyEnum)
     //{
     //    string value = attrib[key];
     //    int htmlAttrib;
     //    if (s_htmlAttribEnumInt32Parser.TryGetValue(key, out htmlAttrib) == true)
     //    {
     //        AddAttribute((HtmlAttrib)htmlAttrib, value);
     //        continue;
     //    }
     //    else if (key.Length > 0)
     //    {
     //        m_writeCount++;
     //        if (key.StartsWith("style", System.StringComparison.InvariantCultureIgnoreCase) == false)
     //        {
     //            m_textWriter.AddAttribute(key, value);
     //            continue;
     //        }
     //        m_textWriter.AddStyleAttribute(key.Substring(5), value);
     //        continue;
     //    }
     //    throw new ArgumentException(string.Format(Local.InvalidHtmlAttribA, key), "attrib");
     //}
 }
        public HtmlBuilder o_Div(Nparams args)
        {
            _writeCount++;
            bool isState;
            HtmlBuilderDivTag lastDivState;

            if (args != null)
            {
                isState = args.Slice <bool>("state");
                if (isState)
                {
                    lastDivState = _divTag;
                    _divTag      = CreateHtmlBuilderDivTag(this, args);
                }
                else
                {
                    lastDivState = null;
                }
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                isState      = false;
                lastDivState = null;
            }
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
            ElementPush(HtmlTag.Div, new DivElementState(isState, lastDivState));
            return(this);
        }
Beispiel #6
0
        public override string Process(string[] texts, Nparams attrib3)
        {
            if (texts.Length < 1)
            {
                throw new InvalidOperationException();
            }
            var attrib     = Nparams.Parse(texts[0].Split(';'));
            var videoBlock = new VideoBlock()
            {
                ID = attrib.Slice("id", "Video" + CoreEx.GetNextID()),
            };

            if (attrib.Exists("uri"))
            {
                videoBlock.Uri = attrib.Slice <string>("uri");
            }
            if (attrib.Exists("width"))
            {
                videoBlock.Width = new Unit(attrib.Slice <string>("width"));
            }
            if (attrib.Exists("height"))
            {
                videoBlock.Height = new Unit(attrib.Slice <string>("height"));
            }
            string responseText;

            HtmlTextWriterEx.RenderControl(videoBlock, out responseText);
            return(responseText);
        }
Beispiel #7
0
        public bool TryParse(string text, Nparams param, out object value)
        {
            TResult parsedValue;
            bool    parsed = _tryParse(text, param.Get <TParseAttrib>(), out parsedValue);

            value = (parsed ? (object)parsedValue : default(TResult));
            return(parsed);
        }
 public HtmlBuilder o_Textarea(string name, Nparams args)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (_formTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     }
     _writeCount++;
     if (args != null)
     {
         // scale
         if (args.ContainsKey("cols"))
         {
             string cols = args.Slice <string>("cols");
             if (cols.EndsWith("px", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, cols);
             }
             else if (!cols.EndsWith("u", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(cols) * 7).ToString() + "px");
             }
             else
             {
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cols, cols.Substring(0, cols.Length - 1));
             }
         }
         if (args.ContainsKey("rows"))
         {
             string rows = args.Slice <string>("rows");
             if (rows.EndsWith("px", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, rows);
             }
             else if (!rows.EndsWith("u", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(rows) * 7).ToString() + "px");
             }
             else
             {
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Rows, rows.Substring(0, rows.Length - 1));
             }
         }
         if (args.HasValue())
         {
             AddAttribute(args, null);
         }
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Textarea);
     ElementPush(HtmlTag.Textarea, null);
     return(this);
 }
        public string CreateVirtualPath(string virtualPath, Nparams param)
        {
            var schema = Schema;

            if (schema == null)
            {
                throw new NullReferenceException("Schema");
            }
            return(schema.CreateVirtualPath(this, virtualPath, param));
        }
        public Uri CreateUri(Uri uri, Nparams param)
        {
            var schema = Schema;

            if (schema == null)
            {
                throw new NullReferenceException("Schema");
            }
            return(schema.CreateUri(this, uri, param));
        }
 public HtmlBuilder o_Button(Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Button);
     ElementPush(HtmlTag.Button, null);
     return(this);
 }
 public HtmlBuilder x_Hr(Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Hr);
     _textWriter.RenderEndTag();
     return(this);
 }
 public HtmlBuilder o_P(Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
     ElementPush(HtmlTag.P, null);
     return(this);
 }
        public HtmlBuilder x_Input(string name, string value, Nparams args)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (_formTag == null)
            {
                throw new InvalidOperationException("Local.UndefinedHtmlForm");
            }
            _writeCount++;
            string type;

            if (args != null)
            {
                type = args.Slice <string>("type", "text");
                // scale
                if (args.ContainsKey("size"))
                {
                    string size = args.Slice <string>("size");
                    if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                    {
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, size);
                    }
                    else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                    {
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(size) * 7).ToString() + "px");
                    }
                    else
                    {
                        _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
                    }
                }
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                type = "text";
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Type, type);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, value);
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Input);
            _textWriter.RenderEndTag();
            return(this);
        }
 public HtmlBuilder o_Li(Nparams args)
 {
     ElementPop(HtmlTag.Li, null, HtmlTag.__OlUl, null);
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Li);
     ElementPush(HtmlTag.Li, null);
     return(this);
 }
 public HtmlBuilder x_Tofu(Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Src, HtmlTextWriterEx.TofuUri);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Img);
     _textWriter.RenderEndTag();
     return(this);
 }
 public HtmlBuilder o_Script(Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Type, "text/javascript");
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Script);
     _textWriter.Write("//<!CDATA[[ <!--\n");
     ElementPush(HtmlTag.Script, null);
     return(this);
 }
 public HtmlBuilder BeginHtmlTag(string tag, Nparams args)
 {
     if (string.IsNullOrEmpty(tag))
     {
         throw new ArgumentNullException("tag");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(tag);
     return(this);
 }
        public static string CreatePath(this HttpContext httpContext, string uri, Nparams args)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            var uriContext = httpContext.Get <UriContextBase>();

            if (uriContext == null)
            {
                throw new NullReferenceException("uriContext");
            }
            return(uriContext.CreatePath(uri, args));
        }
 public HtmlBuilder BeginHtmlTag(HtmlTag tag, Nparams args)
 {
     if ((tag == HtmlTag.Unknown) || (tag >= HtmlTag._FormReference))
     {
         throw new ArgumentException(string.Format("Local.InvalidHtmlTagA", tag.ToString()), "tag");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag((HtmlTextWriterTag)tag);
     return(this);
 }
 public HtmlBuilder o_Th(Nparams args)
 {
     if (_tableTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlTable");
     }
     _tableTag.ColumnIndex++;
     ElementPop(HtmlTag.Th, null, HtmlTag.Tr, null);
     _writeCount++;
     _tableTag.AddAttribute(this, _textWriter, HtmlTag.Th, args);
     _textWriter.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
     ElementPush(HtmlTag.Th, _writeCount);
     return(this);
 }
 public HtmlBuilder x_Col(Nparams args)
 {
     if (_tableTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlTable");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Col);
     _textWriter.RenderEndTag();
     return(this);
 }
Beispiel #23
0
 public override string Process(string[] texts, Nparams attrib3)
 {
     if (texts.Length < 1)
         throw new InvalidOperationException();
     var attrib = Nparams.Parse(texts[0].Split(';'));
     var videoBlock = new VideoBlock() { ID = attrib.Slice("id", "Video" + CoreEx.GetNextID()), };
     if (attrib.Exists("uri"))
         videoBlock.Uri = attrib.Slice<string>("uri");
     if (attrib.Exists("width"))
         videoBlock.Width = new Unit(attrib.Slice<string>("width"));
     if (attrib.Exists("height"))
         videoBlock.Height = new Unit(attrib.Slice<string>("height"));
     string responseText;
     HtmlTextWriterEx.RenderControl(videoBlock, out responseText);
     return responseText;
 }
 public HtmlBuilder x_Iframe(string url, Nparams args)
 {
     if (url == null)
     {
         throw new ArgumentNullException("url");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Src, url);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Iframe);
     _textWriter.RenderEndTag();
     return(this);
 }
        Nparams IClientScriptItemOption.MakeOption()
        {
            var options = Nparams.Create();

            if (UploadCompleteHandler != null)
            {
                options["upload_complete_handler"] = ClientScript.EncodeExpression(UploadCompleteHandler);
            }
            if (UploadStartHandler != null)
            {
                options["upload_start_handler"] = ClientScript.EncodeExpression(UploadStartHandler);
            }
            if (QueueCompleteHandler != null)
            {
                options["queue_complete_handler"] = ClientScript.EncodeExpression(QueueCompleteHandler);
            }
            return(options);
        }
        Nparams IClientScriptItemOption.MakeOption()
        {
            var options = Nparams.Create();

            if (MinimumFlashVersion != null)
            {
                options["minimum_flash_version"] = ClientScript.EncodeText(MinimumFlashVersion);
            }
            if (SwfUploadPreLoadHandler != null)
            {
                options["swfupload_pre_load_handler"] = ClientScript.EncodeExpression(SwfUploadPreLoadHandler);
            }
            if (SwfUploadLoadFailedHandler != null)
            {
                options["swfupload_load_failed_handler"] = ClientScript.EncodeExpression(SwfUploadLoadFailedHandler);
            }
            return(options);
        }
Beispiel #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormClientCommand"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="commandId">The command id.</param>
 /// <param name="commandText">The command text.</param>
 /// <param name="args">The attrib.</param>
 public FormClientCommand(string name, string commandId, string commandText, Nparams args)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw new ArgumentNullException("name");
     }
     if (commandId == null)
     {
         throw new ArgumentNullException("commandId");
     }
     if (commandText == null)
     {
         throw new ArgumentNullException("commandText");
     }
     Name        = name;
     CommandId   = commandId;
     CommandText = commandText;
     Nparams     = args;
 }
 public HtmlBuilder o_Optgroup(string name, Nparams args)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (_formTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.AddAttribute("Label", name);
     _textWriter.RenderBeginTag("Optgroup");
     ElementPush("Optgroup", null);
     return(this);
 }
Beispiel #29
0
 public HtmlBuilder RenderLink(string text, string command, Nparams args)
 {
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     if (!string.IsNullOrEmpty(command))
     {
         _textWriter.AddAttributeIfUndefined((true ? HtmlTextWriterAttribute.Onclick : HtmlTextWriterAttribute.Href), command);
     }
     if (!string.IsNullOrEmpty(text))
     {
         _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Title, text);
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.A);
     _textWriter.Write(text);
     _textWriter.RenderEndTag();
     return(this);
 }
 public HtmlBuilder o_Option(string value, Nparams args)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (_formTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, value);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Option);
     ElementPush(HtmlTag.Option, null);
     return(this);
 }
Beispiel #31
0
 public HtmlBuilder RenderInputButton(string text, string commandEvent, Nparams args)
 {
     if (text == null)
     {
         throw new ArgumentNullException("text");
     }
     _writeCount++;
     if (args != null)
     {
         AddAttribute(args, new[] { "onclick", "value" });
     }
     if (!string.IsNullOrEmpty(commandEvent))
     {
         _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Onclick, commandEvent);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, text);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Input);
     _textWriter.RenderEndTag();
     return(this);
 }
Beispiel #32
0
        public HtmlBuilder RenderImageLink(string url, string alt, string command, Nparams args)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }
            _writeCount++;
            Nparams imageAttrib;

            if (args != null)
            {
                imageAttrib = args.Slice <Nparams>("image");
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                imageAttrib = null;
            }
            if (!string.IsNullOrEmpty(command))
            {
                _textWriter.AddAttributeIfUndefined((true ? HtmlTextWriterAttribute.Onclick : HtmlTextWriterAttribute.Href), command);
            }
            _textWriter.RenderBeginTag(HtmlTextWriterTag.A);
            if (imageAttrib != null)
            {
                AddAttribute(imageAttrib, null);
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Src, url);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Alt, (alt ?? string.Empty));
            if (!string.IsNullOrEmpty(alt))
            {
                _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Title, alt);
            }
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Img);
            _textWriter.RenderEndTag();
            _textWriter.RenderEndTag();
            return(this);
        }
        public HtmlBuilder o_Fieldset(Nparams args)
        {
            if (_formTag == null)
            {
                throw new InvalidOperationException("Local.UndefinedHtmlForm");
            }
            _writeCount++;
            string legend;
            string legendAccessKey;

            if (args != null)
            {
                legend          = args.Slice <string>("legend");
                legendAccessKey = args.Slice <string>("legendaccesskey");
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                legend          = string.Empty;
                legendAccessKey = string.Empty;
            }
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset);
            if ((legend.Length > 0) || (legendAccessKey.Length > 0))
            {
                if (legendAccessKey.Length > 0)
                {
                    _textWriter.AddAttribute(HtmlTextWriterAttribute.Accesskey, legendAccessKey);
                }
                _textWriter.RenderBeginTag(HtmlTextWriterTag.Legend);
                if (legend.Length > 0)
                {
                    _textWriter.Write(legend);
                }
                _textWriter.RenderEndTag();
            }
            ElementPush(HtmlTag.Fieldset, null);
            return(this);
        }
 /// <summary>
 /// Registers the specified manager.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="registrations">The registrations.</param>
 /// <param name="attrib">The attrib.</param>
 public static void Register(IClientScriptManager manager, Registrations registrations, Nparams attrib)
 {
     if (manager == null)
         throw new ArgumentNullException("manager");
     if ((registrations & Registrations.SwfUpload) == Registrations.SwfUpload)
     {
         //string swfUploadVersion;
         var version = SwfUploadVersion; // ((attrib != null) && attrib.TryGetValue("swfUploadVersion", out swfUploadVersion) ? swfUploadVersion : SwfUploadVersion);
         if (string.IsNullOrEmpty(version))
             throw new InvalidOperationException("version");
         var versionFolder = "Contoso.Resource_.SwfUpload" + version.Replace(".", "_");
         // STATE
         HttpContext.Current.Set<ClientScriptRegistrarSwfUploadShape>(new ClientScriptRegistrarSwfUploadShape
         {
             SwfUploadFlashUrl = ClientScriptManagerEx.GetWebResourceUrl(_type, versionFolder + ".swfupload.swf"),
         });
         // INCLUDES
         manager.EnsureItem<HtmlHead>("SwfUpload", () => new IncludeForResourceClientScriptItem(_type, "Contoso.Resource_.SwfUpload" + version + ".js"));
         if ((registrations & Registrations.SwfUploadCookiePlugin) == Registrations.SwfUploadCookiePlugin)
             manager.EnsureItem<HtmlHead>("CookiePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".cookies.js"));
         if ((registrations & Registrations.SwfUploadQueuePlugin) == Registrations.SwfUploadQueuePlugin)
             manager.EnsureItem<HtmlHead>("QueuePlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".queue.js"));
         if ((registrations & Registrations.SwfUploadSpeedPlugin) == Registrations.SwfUploadSpeedPlugin)
             manager.EnsureItem<HtmlHead>("SpeedPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".speed.js"));
         if ((registrations & Registrations.SwfUploadSwfObjectPlugin) == Registrations.SwfUploadSwfObjectPlugin)
             manager.EnsureItem<HtmlHead>("SwfObjectPlugin", () => new IncludeForResourceClientScriptItem(_type, versionFolder + ".swfobject.js"));
     }
 }
 /// <summary>
 /// O_s the A.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_A(string url, Nparams args)
 {
     if (url == null)
         throw new ArgumentNullException("url");
     if (_isInAnchor)
         throw new InvalidOperationException("Local.RedefineHtmlAnchor");
     _isInAnchor = true;
     _writeCount++;
     // todo: add
     //if (attrib.IsExist("alt") == false) {
     //   attrib["alt"] = attrib["title"];
     //}
     string textProcess;
     if (args != null)
     {
         textProcess = args.Slice<string>("textProcess");
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
         textProcess = string.Empty;
     //if (textProcess.Length > 0)
     //    url = KernelFactory.TextProcess[textProcess].Process(url, null);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Href, url);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.A);
     ElementPush(HtmlTag.A, null);
     return this;
 }
Beispiel #36
0
 /// <summary>
 /// Encodes the dictionary.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public static string EncodeDictionary(Nparams args)
 {
     return EncodeDictionary(args.ToDictionary(), false);
 }
Beispiel #37
0
 /// <summary>
 /// Encodes the dictionary.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <param name="includeNewLine">if set to <c>true</c> [include new line].</param>
 /// <returns></returns>
 public static string EncodeDictionary(Nparams args, bool includeNewLine)
 {
     return EncodeDictionary(args.ToDictionary(), includeNewLine);
 }
 /// <summary>
 /// O_s the fieldset.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Fieldset(Nparams args)
 {
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     string legend;
     string legendAccessKey;
     if (args != null)
     {
         legend = args.Slice<string>("legend");
         legendAccessKey = args.Slice<string>("legendaccesskey");
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
     {
         legend = string.Empty;
         legendAccessKey = string.Empty;
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset);
     if (legend.Length > 0 || legendAccessKey.Length > 0)
     {
         if (legendAccessKey.Length > 0)
             _textWriter.AddAttribute(HtmlTextWriterAttribute.Accesskey, legendAccessKey);
         _textWriter.RenderBeginTag(HtmlTextWriterTag.Legend);
         if (legend.Length > 0)
             _textWriter.Write(legend);
         _textWriter.RenderEndTag();
     }
     ElementPush(HtmlTag.Fieldset, null);
     return this;
 }
 /// <summary>
 /// O_s the div.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Div(Nparams args)
 {
     _writeCount++;
     bool isState;
     HtmlBuilderDivTag lastDivState;
     if (args != null)
     {
         isState = args.Slice<bool>("state");
         if (isState)
         {
             lastDivState = _divTag;
             _divTag = CreateHtmlBuilderDivTag(this, args);
         }
         else
             lastDivState = null;
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
     {
         isState = false;
         lastDivState = null;
     }
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
     ElementPush(HtmlTag.Div, new DivElementState(isState, lastDivState));
     return this;
 }
 /// <summary>
 /// O_s the form reference.
 /// </summary>
 /// <param name="commandTargetControl">The command target control.</param>
 /// <param name="formContext">The form context.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_FormReference(Control commandTargetControl, IFormContext formContext, Nparams args)
 {
     if (_formTag != null)
         throw new InvalidOperationException("Local.RedefineHtmlForm");
     _formTag = CreateHtmlBuilderFormTag(this, formContext, args);
     ElementPush(HtmlTag._FormReference, null);
     if (commandTargetControl != null)
         o_CommandTarget(commandTargetControl);
     return this;
 }
Beispiel #41
0
 /// <summary>
 /// Creates the HTML builder div tag.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public virtual HtmlBuilderDivTag CreateHtmlBuilderDivTag(HtmlBuilder b, Nparams args)
 {
     return new HtmlBuilderDivTag(b, args);
 }
 /// <summary>
 /// O_s the form.
 /// </summary>
 /// <param name="commandTargetControl">The command target control.</param>
 /// <param name="formContext">The form context.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Form(Control commandTargetControl, IFormContext formContext, Nparams args)
 {
     if (_formTag != null)
         throw new InvalidOperationException("Local.RedefineHtmlForm");
     _writeCount++;
     _formTag = CreateHtmlBuilderFormTag(this, formContext, args);
     //Http.Instance.EnterForm(this, attrib);
     string method;
     if (args != null)
     {
         _formName = args.Slice("name", "Form");
         method = args.Slice("method", "POST");
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
     {
         _formName = "Form";
         method = "POST";
     }
     if (_formName.Length > 0)
         _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, _formName);
     if (method.Length > 0)
         _textWriter.AddAttribute("method", method.ToUpperInvariant());
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Form);
     ElementPush(HtmlTag.Form, null);
     if (commandTargetControl != null)
         o_CommandTarget(commandTargetControl);
     return this;
 }
        /// <summary>
        /// O_s the select.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public HtmlBuilder o_Select(string name, Nparams args)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (_formTag == null)
                throw new InvalidOperationException("Local.UndefinedHtmlForm");
            _writeCount++;
            if (args != null)
            {
                // scale
                if (args.ContainsKey("size"))
                {
                    var size = args.Slice<string>("size");
                    if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, size);
                    else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))

                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(size) * 7).ToString() + "px");
                    else
                        _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
                }
                if (args.HasValue())
                    AddAttribute(args, null);
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Select);
            ElementPush(HtmlTag.Select, null);
            return this;
        }
 /// <summary>
 /// O_s the tfoot.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Tfoot(Nparams args)
 {
     if (_tableTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlTable");
     if (_tableTag.Stage > HtmlBuilderTableTag.TableStage.TheadTfoot)
         throw new InvalidOperationException(string.Format("Local.InvalidTableStageAB", _tableTag.Stage.ToString(), HtmlBuilderTableTag.TableStage.TheadTfoot.ToString()));
     ElementPop(HtmlTag.Tfoot, null, HtmlTag.Table, null);
     _writeCount++;
     _tableTag.Stage = HtmlBuilderTableTag.TableStage.TheadTfoot;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Tfoot);
     ElementPush(HtmlTag.Tfoot, null);
     return this;
 }
 /// <summary>
 /// O_s the textarea.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Textarea(string name, Nparams args)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     if (args != null)
     {
         // scale
         if (args.ContainsKey("cols"))
         {
             var cols = args.Slice<string>("cols");
             if (cols.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, cols);
             else if (!cols.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(cols) * 7).ToString() + "px");
             else
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cols, cols.Substring(0, cols.Length - 1));
         }
         if (args.ContainsKey("rows"))
         {
             var rows = args.Slice<string>("rows");
             if (rows.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, rows);
             else if (!rows.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(rows) * 7).ToString() + "px");
             else
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Rows, rows.Substring(0, rows.Length - 1));
         }
         if (args.HasValue())
             AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Textarea);
     ElementPush(HtmlTag.Textarea, null);
     return this;
 }
 /// <summary>
 /// O_s the td.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Td(Nparams args)
 {
     if (_tableTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlTable");
     _tableTag.ColumnIndex++;
     ElementPop(HtmlTag.Td, null, HtmlTag.Tr, null);
     _writeCount++;
     _tableTag.AddAttribute(this, _textWriter, HtmlTag.Td, args);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Td);
     ElementPush(HtmlTag.Td, _writeCount);
     return this;
 }
 /// <summary>
 /// O_s the table.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Table(Nparams args)
 {
     _writeCount++;
     var lastTableState = _tableTag;
     _tableTag = CreateHtmlBuilderTableTag(this, args);
     string caption;
     if (args != null)
     {
         caption = args.Slice<string>("caption");
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
         caption = string.Empty;
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cellpadding, "0");
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cellspacing, "0");
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Table);
     if (caption.Length > 0)
     {
         _textWriter.RenderBeginTag(HtmlTextWriterTag.Caption);
         _textWriter.WriteEncodedText(caption);
         _textWriter.RenderEndTag();
     }
     ElementPush(HtmlTag.Table, lastTableState);
     return this;
 }
 /// <summary>
 /// O_s the span.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Span(Nparams args)
 {
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Span);
     ElementPush(HtmlTag.Span, null);
     return this;
 }
 /// <summary>
 /// O_s the optgroup.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Optgroup(string name, Nparams args)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.AddAttribute("Label", name);
     _textWriter.RenderBeginTag("Optgroup");
     ElementPush("Optgroup", null);
     return this;
 }
 /// <summary>
 /// O_s the li.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Li(Nparams args)
 {
     ElementPop(HtmlTag.Li, null, HtmlTag.__OlUl, null);
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Li);
     ElementPush(HtmlTag.Li, null);
     return this;
 }
Beispiel #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlBuilderDivTag"/> class.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="args">The args.</param>
 public HtmlBuilderDivTag(HtmlBuilder b, Nparams args)
 {
 }
Beispiel #52
0
 /// <summary>
 /// Creates the HTML builder form tag.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="formContext">The form context.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public virtual HtmlBuilderFormTag CreateHtmlBuilderFormTag(HtmlBuilder b, IFormContext formContext, Nparams args)
 {
     return new HtmlBuilderFormTag(b, formContext, args);
 }
Beispiel #53
0
        /// <summary>
        /// Ends the smart tag.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public HtmlBuilder EndSmartTag(HtmlTag tag, Nparams args)
        {
            string c;
            string c2;
            switch (tag)
            {
                case HtmlTag._CommandTarget:
                    x_CommandTarget();
                    return this;
                case HtmlTag.Script:
                    x_Script();
                    return this;

                // Container
                case HtmlTag.Div:
                    x_Div();
                    return this;
                case HtmlTag.Iframe:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("url")))
                        throw new ArgumentException("Local.UndefinedAttribUrl", "attrib");
                    x_Iframe(c, args);
                    return this;

                // Content
                case HtmlTag.A:
                    x_A();
                    return this;
                case HtmlTag.Br:
                    x_Br();
                    return this;
                case HtmlTag.H1:
                    x_H1();
                    return this;
                case HtmlTag.H2:
                    x_H2();
                    return this;
                case HtmlTag.H3:
                    x_H3();
                    return this;
                case HtmlTag.Hr:
                    x_Hr(args);
                    return this;
                case HtmlTag.Img:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("url")))
                        throw new ArgumentException("Local.UndefinedAttribUrl", "attrib");
                    if (string.IsNullOrEmpty(c2 = args.Slice<string>("value")))
                        throw new ArgumentException("Local.UndefinedAttribValue", "attrib");
                    x_Img(c, c2, args);
                    return this;
                case HtmlTag.P:
                    x_P();
                    return this;
                case HtmlTag.Span:
                    x_Span();
                    return this;
                //- x_tofu - no match

                // List
                case HtmlTag.Li:
                    x_Li();
                    return this;
                case HtmlTag.Ol:
                    x_Ol();
                    return this;
                case HtmlTag.Ul:
                    x_Ul();
                    return this;

                // Table
                case HtmlTag.Col:
                    x_Col(args);
                    return this;
                case HtmlTag.Colgroup:
                    x_Colgroup();
                    return this;
                case HtmlTag.Table:
                    x_Table();
                    return this;
                case HtmlTag.Tbody:
                    x_Tbody();
                    return this;
                case HtmlTag.Td:
                    x_Td();
                    return this;
                case HtmlTag.Tfoot:
                    x_Tfoot();
                    return this;
                case HtmlTag.Th:
                    x_Th();
                    return this;
                case HtmlTag.Thead:
                    x_Thead();
                    return this;
                case HtmlTag.Tr:
                    x_Tr();
                    return this;

                // Form
                case HtmlTag.Button:
                    x_Button();
                    return this;
                case HtmlTag.Fieldset:
                    x_Fieldset();
                    return this;
                case HtmlTag.Form:
                    x_Form();
                    return this;
                case HtmlTag._FormReference:
                    x_FormReference();
                    return this;
                case HtmlTag.Input:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("name")))
                        throw new ArgumentException("Local.UndefinedAttribName", "attrib");
                    if (string.IsNullOrEmpty(c2 = args.Slice<string>("value")))
                        throw new ArgumentException("Local.UndefinedAttribValue", "attrib");
                    x_Input(c, c2, args);
                    return this;
                case HtmlTag.Label:
                    x_Label();
                    return this;
                // x_optgroup - no match
                case HtmlTag.Option:
                    x_Option();
                    return this;
                case HtmlTag.Select:
                    x_Select();
                    return this;
                case HtmlTag.Textarea:
                    x_Textarea();
                    return this;
            }
            EndHtmlTag();
            return this;
        }
Beispiel #54
0
        /// <summary>
        /// Begins the smart tag.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public HtmlBuilder BeginSmartTag(HtmlTag tag, Nparams args)
        {
            string c;
            switch (tag)
            {
                case HtmlTag._CommandTarget:
                    throw new NotSupportedException();
                case HtmlTag.Script:
                    o_Script(args);
                    return this;

                // Container
                case HtmlTag.Div:
                    o_Div(args);
                    return this;

                // Content
                case HtmlTag.A:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("url")))
                        throw new ArgumentException("Local.UndefinedAttribUrl", "attrib");
                    o_A(c, args);
                    return this;
                case HtmlTag.H1:
                    o_H1(args);
                    return this;
                case HtmlTag.H2:
                    o_H2(args);
                    return this;
                case HtmlTag.H3:
                    o_H3(args);
                    return this;
                case HtmlTag.P:
                    o_P(args);
                    return this;
                case HtmlTag.Span:
                    o_Span(args);
                    return this;

                // List
                case HtmlTag.Li:
                    o_Li(args);
                    return this;
                case HtmlTag.Ol:
                    o_Ol(args);
                    return this;
                case HtmlTag.Ul:
                    o_Ul(args);
                    return this;

                // Table
                case HtmlTag.Colgroup:
                    o_Colgroup(args);
                    return this;
                case HtmlTag.Table:
                    o_Table(args);
                    return this;
                case HtmlTag.Tbody:
                    o_Tbody(args);
                    return this;
                case HtmlTag.Td:
                    o_Td(args);
                    return this;
                case HtmlTag.Tfoot:
                    o_Tfoot(args);
                    return this;
                case HtmlTag.Th:
                    o_Th(args);
                    return this;
                case HtmlTag.Thead:
                    o_Thead(args);
                    return this;
                case HtmlTag.Tr:
                    o_Tr(args);
                    return this;

                // Form
                case HtmlTag.Button:
                    o_Button(args);
                    return this;
                case HtmlTag.Fieldset:
                    o_Fieldset(args);
                    return this;
                case HtmlTag.Form:
                    throw new NotSupportedException();
                case HtmlTag._FormReference:
                    throw new NotSupportedException();
                case HtmlTag.Label:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("forName")))
                        throw new ArgumentException("Local.UndefinedAttribForName", "attrib");
                    o_Label(c, args);
                    return this;
                // o_optgroup - no match
                case HtmlTag.Option:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("value")))
                        throw new ArgumentException("Local.UndefinedAttribValue", "attrib");
                    o_Option(c, args);
                    return this;
                case HtmlTag.Select:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("name")))
                        throw new ArgumentException("Local.UndefinedAttribName", "attrib");
                    o_Select(c, args);
                    return this;
                case HtmlTag.Textarea:
                    if (args == null || string.IsNullOrEmpty(c = args.Slice<string>("name")))
                        throw new ArgumentException("Local.UndefinedAttribName", "attrib");
                    o_Textarea(c, args);
                    return this;
            }
            BeginHtmlTag(tag);
            return this;
        }
 /// <summary>
 /// O_s the option.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Option(string value, Nparams args)
 {
     if (value == null)
         throw new ArgumentNullException("value");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, value);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Option);
     ElementPush(HtmlTag.Option, null);
     return this;
 }
 /// <summary>
 /// O_s the label.
 /// </summary>
 /// <param name="forName">For name.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Label(string forName, Nparams args)
 {
     if (forName == null)
         throw new ArgumentNullException("forName");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.For, forName);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
     ElementPush(HtmlTag.Label, null);
     return this;
 }
Beispiel #57
0
 /// <summary>
 /// Creates the HTML builder table tag.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public virtual HtmlBuilderTableTag CreateHtmlBuilderTableTag(HtmlBuilder b, Nparams args)
 {
     return new HtmlBuilderTableTag(b, args.Get<HtmlBuilderTableTag.TableAttrib>());
 }
 /// <summary>
 /// O_s the P.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_P(Nparams args)
 {
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
     ElementPush(HtmlTag.P, null);
     return this;
 }
Beispiel #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlBuilderFormTag"/> class.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="formContext">The form context.</param>
 /// <param name="args">The args.</param>
 public HtmlBuilderFormTag(HtmlBuilder b, IFormContext formContext, Nparams args)
 {
 }
 /// <summary>
 /// O_s the script.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Script(Nparams args)
 {
     _writeCount++;
     if (args != null)
         AddAttribute(args, null);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Type, "text/javascript");
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Script);
     _textWriter.Write("//<!CDATA[[ <!--\n");
     ElementPush(HtmlTag.Script, null);
     return this;
 }