当前位置: 首页>>代码示例>>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;未经允许,请勿转载。