當前位置: 首頁>>代碼示例>>C#>>正文


C# BlogRollItem類代碼示例

本文整理匯總了C#中BlogRollItem的典型用法代碼示例。如果您正苦於以下問題:C# BlogRollItem類的具體用法?C# BlogRollItem怎麽用?C# BlogRollItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlogRollItem類屬於命名空間,在下文中一共展示了BlogRollItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeleteBlogRollItem

        /// <summary>
        /// Deletes a BlogRoll from the database
        /// </summary>
        /// <param name="blogRoll">BlogRoll to be removed</param>
        public override void DeleteBlogRollItem(BlogRollItem blogRollItem)
        {
            List<BlogRollItem> blogRolls = BlogRollItem.BlogRolls;
            blogRolls.Remove(blogRollItem);
            blogRolls.Add(blogRollItem);

            string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString;
            string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName;
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);

            using (DbConnection conn = provider.CreateConnection())
            {
                conn.ConnectionString = connString;
                conn.Open();
                using (DbCommand cmd = conn.CreateCommand())
                {
                    string sqlQuery = "DELETE FROM " + tablePrefix + "BlogRollItems " +
                                      "WHERE BlogRollId = " + parmPrefix + "BlogRollId";
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    DbParameter dpID = provider.CreateParameter();
                    dpID.ParameterName = parmPrefix + "BlogRollId";
                    dpID.Value = blogRollItem.Id.ToString();
                    cmd.Parameters.Add(dpID);

                    cmd.ExecuteNonQuery();
                }
            }
        }
開發者ID:rajgit31,項目名稱:RajBlog,代碼行數:34,代碼來源:DbBlogProvider.cs

示例2: InsertBlogRollItem

        /// <summary>
        /// Inserts a BlogRoll
        /// </summary>
        /// <param name="blogRollItem">
        /// The blog Roll Item.
        /// </param>
        public override void InsertBlogRollItem(BlogRollItem blogRollItem)
        {
            var blogRolls = FillBlogRoll();
            if(blogRolls == null)
            {
                blogRolls = new List<BlogRollItem>();
            }

            blogRolls.Add(blogRollItem);
            WriteBlogRollFile(blogRolls);
        }
開發者ID:guilhermesuzuki,項目名稱:BlogEngine.NET,代碼行數:17,代碼來源:BlogRoll.cs

示例3: Add

        /// <summary>
        /// Add blogroll
        /// </summary>
        /// <param name="form">submitted form</param>
        public void Add(NameValueCollection form)
        {
            if (!Security.IsAdministrator)
                throw new UnauthorizedAccessException();

            var br = new BlogRollItem();
            br.Title = form["txtTitle"];
            br.Description = form["txtDesc"];
            br.BlogUrl = new Uri(form["txtWebsite"]);
            br.FeedUrl = new Uri(form["txtUrl"]);
            br.Xfn = GetXfn(form);

            if (string.IsNullOrEmpty(br.Xfn))
                br.Xfn = "contact";

            Providers.BlogService.InsertBlogRoll(br);
        }
開發者ID:CharlesZHENG,項目名稱:BlogEngine.NET,代碼行數:21,代碼來源:BlogRollVM.cs

示例4: DeleteBlogRollItem

        /// <summary>
        /// Deletes a BlogRoll from the database
        /// </summary>
        /// <param name="blogRollItem">
        /// The blog Roll Item.
        /// </param>
        public override void DeleteBlogRollItem(BlogRollItem blogRollItem)
        {
            var blogRolls = BlogRollItem.BlogRolls;
            blogRolls.Remove(blogRollItem);
            blogRolls.Add(blogRollItem);

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("DELETE FROM {0}BlogRollItems WHERE BlogRollId = {1}BlogRollId", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogRollId"), blogRollItem.Id.ToString()));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
開發者ID:RajneeshVerma,項目名稱:blogengine.net-mvc,代碼行數:27,代碼來源:DbBlogProvider.cs

示例5: DeleteBlogRollItem

        /// <summary>
        /// Deletes a BlogRoll from the database
        /// </summary>
        /// <param name="blogRollItem">
        /// The blog Roll Item.
        /// </param>
        public override void DeleteBlogRollItem(BlogRollItem blogRollItem)
        {
            var blogRolls = BlogRollItem.BlogRolls;
            blogRolls.Remove(blogRollItem);
            blogRolls.Add(blogRollItem);

            var connString = ConfigurationManager.ConnectionStrings[this.connStringName].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[this.connStringName].ProviderName;
            var provider = DbProviderFactories.GetFactory(providerName);

            using (var conn = provider.CreateConnection())
            {
                if (conn == null)
                {
                    return;
                }

                conn.ConnectionString = connString;
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    var sqlQuery = string.Format("DELETE FROM {0}BlogRollItems WHERE BlogRollId = {1}BlogRollId", this.tablePrefix, this.parmPrefix);
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    var parameter = provider.CreateParameter();
                    if (parameter != null)
                    {
                        parameter.ParameterName = string.Format("{0}BlogRollId", this.parmPrefix);
                        parameter.Value = blogRollItem.Id.ToString();
                        cmd.Parameters.Add(parameter);
                    }

                    cmd.ExecuteNonQuery();
                }
            }
        }
開發者ID:karanbhasin,項目名稱:blogEngine.Common,代碼行數:43,代碼來源:DbBlogProvider.cs

示例6: UpdateBlogRollItem

 /// <summary>
 /// Updates a BlogRoll
 /// </summary>
 /// <param name="blogRollItem">
 /// The blog Roll Item.
 /// </param>
 public override void UpdateBlogRollItem(BlogRollItem blogRollItem)
 {
     var blogRolls = BlogRollItem.BlogRolls;
     blogRolls.Remove(blogRollItem);
     blogRolls.Add(blogRollItem);
     this.WriteBlogRollFile(blogRolls);
 }
開發者ID:RajneeshVerma,項目名稱:blogengine.net-mvc,代碼行數:13,代碼來源:BlogRoll.cs

示例7: DeleteBlogRoll

 /// <summary>
 /// Deletes the specified BlogRoll from the current provider.
 /// </summary>
 /// <param name="blogRoll">
 /// The blog Roll.
 /// </param>
 public static void DeleteBlogRoll(BlogRollItem blogRoll)
 {
     Provider.DeleteBlogRollItem(blogRoll);
 }
開發者ID:raul-aguirre-flexit,項目名稱:Carnaval-Radio,代碼行數:10,代碼來源:BlogService.cs

示例8: UpdateBlogRoll

 /// <summary>
 /// Updates an exsiting BlogRoll.
 /// </summary>
 /// <param name="blogRoll">
 /// The blog Roll.
 /// </param>
 public static void UpdateBlogRoll(BlogRollItem blogRoll)
 {
     Provider.UpdateBlogRollItem(blogRoll);
 }
開發者ID:raul-aguirre-flexit,項目名稱:Carnaval-Radio,代碼行數:10,代碼來源:BlogService.cs

示例9: InsertBlogRoll

 /// <summary>
 /// Persists a new BlogRoll in the current provider.
 /// </summary>
 /// <param name="blogRoll">
 /// The blog Roll.
 /// </param>
 public static void InsertBlogRoll(BlogRollItem blogRoll)
 {
     Provider.InsertBlogRollItem(blogRoll);
 }
開發者ID:raul-aguirre-flexit,項目名稱:Carnaval-Radio,代碼行數:10,代碼來源:BlogService.cs

示例10: FillBlogRoll

        /// <summary>
        /// Gets all BlogRolls in database
        /// </summary>
        /// <returns>
        /// List of BlogRolls
        /// </returns>
        public override List<BlogRollItem> FillBlogRoll()
        {
            var blogRoll = new List<BlogRollItem>();

            var connString = ConfigurationManager.ConnectionStrings[this.connStringName].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[this.connStringName].ProviderName;
            var provider = DbProviderFactories.GetFactory(providerName);

            using (var conn = provider.CreateConnection())
            {
                if (conn != null)
                {
                    conn.ConnectionString = connString;
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        var sqlQuery = string.Format("SELECT BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex FROM {0}BlogRollItems ", this.tablePrefix);
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        using (var rdr = cmd.ExecuteReader())
                        {
                            if (rdr.HasRows)
                            {
                                while (rdr.Read())
                                {
                                    var br = new BlogRollItem
                                        {
                                            Id = rdr.GetGuid(0),
                                            Title = rdr.GetString(1),
                                            Description = rdr.IsDBNull(2) ? string.Empty : rdr.GetString(2),
                                            BlogUrl = rdr.IsDBNull(3) ? null : new Uri(rdr.GetString(3)),
                                            FeedUrl = rdr.IsDBNull(4) ? null : new Uri(rdr.GetString(4)),
                                            Xfn = rdr.IsDBNull(5) ? string.Empty : rdr.GetString(5),
                                            SortIndex = rdr.GetInt32(6)
                                        };

                                    blogRoll.Add(br);
                                    br.MarkOld();
                                }
                            }
                        }
                    }
                }
            }

            return blogRoll;
        }
開發者ID:karanbhasin,項目名稱:blogEngine.Common,代碼行數:54,代碼來源:DbBlogProvider.cs

示例11: addBlogRollParametersToCommand

        private void addBlogRollParametersToCommand(BlogRollItem blogRollItem, DbProviderFactory provider, DbCommand cmd)
        {
            DbParameter dpID = provider.CreateParameter();
            dpID.ParameterName = parmPrefix + "BlogRollId";
            dpID.Value = blogRollItem.Id.ToString();
            cmd.Parameters.Add(dpID);

            DbParameter dpTitle = provider.CreateParameter();
            dpTitle.ParameterName = parmPrefix + "Title";
            dpTitle.Value = blogRollItem.Title;
            cmd.Parameters.Add(dpTitle);

            DbParameter dpDesc = provider.CreateParameter();
            dpDesc.ParameterName = parmPrefix + "Description";
            dpDesc.Value = blogRollItem.Description;
            cmd.Parameters.Add(dpDesc);

            DbParameter dpBlogUrl = provider.CreateParameter();
            dpBlogUrl.ParameterName = "BlogUrl";
            dpBlogUrl.Value = blogRollItem.BlogUrl != null ? (object)blogRollItem.BlogUrl.ToString() : DBNull.Value;
            cmd.Parameters.Add(dpBlogUrl);

            DbParameter dpFeedUrl = provider.CreateParameter();
            dpFeedUrl.ParameterName = "FeedUrl";
            dpFeedUrl.Value = blogRollItem.FeedUrl != null ? (object)blogRollItem.FeedUrl.ToString() : DBNull.Value;
            cmd.Parameters.Add(dpFeedUrl);

            DbParameter dpXfn = provider.CreateParameter();
            dpXfn.ParameterName = "Xfn";
            dpXfn.Value = blogRollItem.Xfn;
            cmd.Parameters.Add(dpXfn);

            DbParameter dpSortIndex = provider.CreateParameter();
            dpSortIndex.ParameterName = "SortIndex";
            dpSortIndex.Value = blogRollItem.SortIndex;
            cmd.Parameters.Add(dpSortIndex);
        }
開發者ID:rajgit31,項目名稱:RajBlog,代碼行數:37,代碼來源:DbBlogProvider.cs

示例12: FillBlogRoll

        /// <summary>
        /// Gets all BlogRolls in database
        /// </summary>
        /// <returns>
        /// List of BlogRolls
        /// </returns>
        public override List<BlogRollItem> FillBlogRoll()
        {
            var blogRoll = new List<BlogRollItem>();

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    using (var cmd = conn.CreateTextCommand(string.Format("SELECT BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex FROM {0}BlogRollItems WHERE BlogId = {1}blogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));

                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var br = new BlogRollItem
                                    {
                                        Id = rdr.GetGuid(0),
                                        Title = rdr.GetString(1),
                                        Description = rdr.IsDBNull(2) ? string.Empty : rdr.GetString(2),
                                        BlogUrl = rdr.IsDBNull(3) ? null : new Uri(rdr.GetString(3)),
                                        FeedUrl = rdr.IsDBNull(4) ? null : new Uri(rdr.GetString(4)),
                                        Xfn = rdr.IsDBNull(5) ? string.Empty : rdr.GetString(5),
                                        SortIndex = rdr.GetInt32(6)
                                    };

                                blogRoll.Add(br);
                                br.MarkOld();
                            }
                        }
                    }
                }
            }

            return blogRoll;
        }
開發者ID:mukhtiarlander,項目名稱:git_demo_torit,代碼行數:43,代碼來源:DbBlogProvider.cs

示例13: SelectBlogRollItem

 /// <summary>
 /// Gets a BlogRoll based on a Guid.
 /// </summary>
 /// <param name="id">The BlogRoll's Guid.</param>
 /// <returns>A matching BlogRoll</returns>
 public override BlogRollItem SelectBlogRollItem(Guid id)
 {
     BlogRollItem blogRoll = BlogRollItem.BlogRolls.Find(br => br.Id == id);
     if (blogRoll == null)
     {
         blogRoll = new BlogRollItem();
     }
     blogRoll.MarkOld();
     return blogRoll;
 }
開發者ID:rajgit31,項目名稱:RajBlog,代碼行數:15,代碼來源:DbBlogProvider.cs

示例14: InsertBlogRollItem

        /// <summary>
        /// Inserts a BlogRoll
        /// </summary>
        /// <param name="blogRollItem">
        /// The blog Roll Item.
        /// </param>
        public override void InsertBlogRollItem(BlogRollItem blogRollItem)
        {
            var blogRolls = BlogRollItem.BlogRolls;
            blogRolls.Add(blogRollItem);

            this.WriteBlogRollFile(blogRolls);
        }
開發者ID:RajneeshVerma,項目名稱:blogengine.net-mvc,代碼行數:13,代碼來源:BlogRoll.cs

示例15: UpdateBlogRollItem

        /// <summary>
        /// Saves an existing BlogRoll to the database
        /// </summary>
        /// <param name="blogRollItem">
        /// BlogRoll to be saved
        /// </param>
        public override void UpdateBlogRollItem(BlogRollItem blogRollItem)
        {
            var blogRolls = BlogRollItem.BlogRolls;
            blogRolls.Remove(blogRollItem);
            blogRolls.Add(blogRollItem);

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("UPDATE {0}BlogRollItems SET Title = {1}Title, Description = {1}Description, BlogUrl = {1}BlogUrl, FeedUrl = {1}FeedUrl, Xfn = {1}Xfn, SortIndex = {1}SortIndex WHERE BlogId = {1}BlogId AND BlogRollId = {1}BlogRollId", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        this.AddBlogRollParametersToCommand(blogRollItem, conn, cmd);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
開發者ID:mukhtiarlander,項目名稱:git_demo_torit,代碼行數:26,代碼來源:DbBlogProvider.cs


注:本文中的BlogRollItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。