Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Tag     html  = new HtmlTag();
            Tag     body  = new BodyTag();
            Tag     head  = new HeadTag();
            Tag     title = new TitleTag();
            Tag     div   = new DivTag();
            Element elem1 = new Element();
            Element elem2 = new Element();
            Element elem3 = new Element();
            Tag     brr   = new BrTag();

            Tag h1 = new H1Tag();

            elem1.SetContent("titlu");
            elem2.SetContent("giele");
            elem3.SetContent("gielesss");
            html.AddTag(head);
            html.AddTag(body);
            head.AddElement(elem1);
            head.AddTag(brr);
            head.AddTag(title);
            head.AddElement(elem2);
            head.AddTag(title);
            head.AddElement(elem3);
            body.AddTag(div);
            div.AddTag(h1);
            div.AddAttribute("color", "blue");
            div.AddAttribute("color1", "red");
            //title.SetContent("Gigi 4 the WIN!!");
            //head.SetContent("gigel");
            //html.Render();
            Parser.ParseFile("index.html");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Select values from TitleTag by primary key(s).
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="titleID"></param>
        /// <param name="tagText"></param>
        /// <returns>Object of type TitleTag.</returns>
        public TitleTag TitleTagSelectAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            int titleID,
            string tagText)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("TitleTagSelectAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("TitleID", SqlDbType.Int, null, false, titleID),
                                                                      CustomSqlHelper.CreateInputParameter("TagText", SqlDbType.NVarChar, 50, false, tagText)))
            {
                using (CustomSqlHelper <TitleTag> helper = new CustomSqlHelper <TitleTag>())
                {
                    CustomGenericList <TitleTag> list = helper.ExecuteReader(command);
                    if (list.Count > 0)
                    {
                        TitleTag o = list[0];
                        list = null;
                        return(o);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Render_UsesHtmlEncoding()
        {
            var titleTag = new TitleTag("My <Title>");

            titleTag.Render(_htmlHelper.Writer);

            var documentText = _htmlHelper.GetDocumentText();

            Assert.That(documentText, Is.StringContaining("My &lt;Title&gt;"));
        }
Exemplo n.º 4
0
        public void Render()
        {
            var titleTag = new TitleTag("My Title");

            titleTag.Render(_htmlHelper.Writer);

            var document     = _htmlHelper.GetResultDocument();
            var titleElement = _htmlHelper.GetAssertedChildElement(document, "title", 0);

            _htmlHelper.AssertTextNode(titleElement, "My Title", 0);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Update values in TitleTag. Returns an object of type TitleTag.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type TitleTag.</param>
 /// <returns>Object of type TitleTag.</returns>
 public TitleTag TitleTagUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     TitleTag value)
 {
     return(TitleTagUpdateAuto(sqlConnection, sqlTransaction,
                               value.TitleID,
                               value.TagText,
                               value.MarcDataFieldTag,
                               value.MarcSubFieldCode));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Manage TitleTag object.
        /// If the object is of type CustomObjectBase,
        /// then either insert values into, delete values from, or update values in TitleTag.
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="value">Object of type TitleTag.</param>
        /// <returns>Object of type CustomDataAccessStatus<TitleTag>.</returns>
        public CustomDataAccessStatus <TitleTag> TitleTagManageAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            TitleTag value)
        {
            if (value.IsNew && !value.IsDeleted)
            {
                TitleTag returnValue = TitleTagInsertAuto(sqlConnection, sqlTransaction,
                                                          value.TitleID,
                                                          value.TagText,
                                                          value.MarcDataFieldTag,
                                                          value.MarcSubFieldCode);

                return(new CustomDataAccessStatus <TitleTag>(
                           CustomDataAccessContext.Insert,
                           true, returnValue));
            }
            else if (!value.IsNew && value.IsDeleted)
            {
                if (TitleTagDeleteAuto(sqlConnection, sqlTransaction,
                                       value.TitleID,
                                       value.TagText))
                {
                    return(new CustomDataAccessStatus <TitleTag>(
                               CustomDataAccessContext.Delete,
                               true, value));
                }
                else
                {
                    return(new CustomDataAccessStatus <TitleTag>(
                               CustomDataAccessContext.Delete,
                               false, value));
                }
            }
            else if (value.IsDirty && !value.IsDeleted)
            {
                TitleTag returnValue = TitleTagUpdateAuto(sqlConnection, sqlTransaction,
                                                          value.TitleID,
                                                          value.TagText,
                                                          value.MarcDataFieldTag,
                                                          value.MarcSubFieldCode);

                return(new CustomDataAccessStatus <TitleTag>(
                           CustomDataAccessContext.Update,
                           true, returnValue));
            }
            else
            {
                return(new CustomDataAccessStatus <TitleTag>(
                           CustomDataAccessContext.NA,
                           false, value));
            }
        }
Exemplo n.º 7
0
        static string GetBlogTitle(string htmlContent)
        {
            string   result    = "";
            Lexer    lexer     = new Lexer(htmlContent);
            Parser   parser    = new Parser(lexer);
            NodeList titleList = parser.Parse(titleFilter);

            if (titleList.Count == 1)
            {
                TitleTag titleTag = (TitleTag)titleList[0];
                result = titleTag.Title;
            }
            else
            {
                Console.WriteLine("获取标题信息出错!");
            }
            return(result);
        }
Exemplo n.º 8
0
 set => Set(TitleTag, value);
        /// <summary>
        ///   Sets the <c>title</c> of the page.
        /// </summary>
        /// <remarks>
        ///   <para>
        ///     All calls to <see cref="SetTitle"/> must be completed before
        ///     <see cref="SetAppended"/> is called. (Typically during the <c>Render</c> phase.)
        ///   </para><para>
        ///     Remove the title tag from the aspx-source.
        ///   </para><para>
        ///     Registeres the title with a default priority of Page.
        ///   </para>
        /// </remarks>
        /// <param name="title"> The stirng to be isnerted as the title. </param>
        public void SetTitle(string title)
        {
            ArgumentUtility.CheckNotNull("title", title);

            _title = new TitleTag(title);
        }