本文整理汇总了C#中Blog类的典型用法代码示例。如果您正苦于以下问题:C# Blog类的具体用法?C# Blog怎么用?C# Blog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Blog类属于命名空间,在下文中一共展示了Blog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlogForm
public BlogForm(Blog blog) : this()
{
currentBlog = blog;
nameText.Text = currentBlog.Name;
authorText.Text = currentBlog.Author;
}
示例2: TestMethod1
public void TestMethod1()
{
BlogMapper m = new BlogMapper();
Blog b = new Blog();
m.Insert(b);
b = m.Get(1);
}
示例3: BlogEntry_is_Added_to_Blog
public void BlogEntry_is_Added_to_Blog()
{
var blogEntry = new BlogEntry(string.Empty);
var blog = new Blog();
blog.Add(blogEntry);
Assert.AreEqual(1, blog.Entries.Count());
}
示例4: SimpleOperations
public void SimpleOperations()
{
ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog));
Recreate();
Post.DeleteAll();
Blog.DeleteAll();
var blogs = from b in Blog.Queryable select b;
Assert.IsNotNull(blogs);
Assert.AreEqual(0, blogs.Count());
var blog = new Blog
{
Name = "hammett's blog",
Author = "hamilton verissimo"
};
blog.Save();
blogs = from b in Blog.Queryable select b;
Assert.IsNotNull(blogs);
Assert.AreEqual(1, blogs.Count());
var retrieved = Blog.Queryable.First();
Assert.IsNotNull(retrieved);
Assert.AreEqual(blog.Name, retrieved.Name);
Assert.AreEqual(blog.Author, retrieved.Author);
}
示例5: BlogRelatedViewModel
public BlogRelatedViewModel(string title)
{
using (var context = new DataContext())
{
// Try permalink first
TheBlog = context.Blogs.FirstOrDefault(x => x.PermaLink == title);
MaxBlogCount = BlogListModel.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad;
// If no go then try title as a final back up
if (TheBlog == null)
{
title = title.Replace(Utils.ContentGlobals.BLOGDELIMMETER, " ");
TheBlog = context.Blogs.FirstOrDefault(x => x.Title == title);
}
if (TheBlog != null && TheBlog.Tags != null)
{
List<string> tags = TheBlog.Tags.Split(',').ToList();
RelatedPosts = context.Blogs.Where(x => x.BlogId != TheBlog.BlogId && tags.Contains(x.Tags) && x.MainCategory == TheBlog.MainCategory)
.OrderByDescending(blog => blog.Date)
.Take(MaxBlogCount)
.ToList();
if (RelatedPosts.Count > 0)
{
LastBlogId = RelatedPosts.LastOrDefault().BlogId;
}
}
}
}
示例6: dummy
void dummy()
{
BlogMapper m = new BlogMapper();
Blog b = new Blog();
m.Insert(b);
b = m.Get(1);
}
示例7: Main
static void Main(string[] args)
{
Author author = new Author();
author.FullName = "Gang of Four";
author.Age = 22;
Blog blog = new Blog();
blog.Id = 1;
blog.Name = "Design Patterns";
blog.Comments.Add("Visitor pattern");
blog.Comments.Add("Abstract factory pattern");
blog.Comments.Add("Composite pattern");
blog.Author = author;
ISerializerFactory serializerFactory = new UnicodeXmlSerializerFactory();
var service = new BlogDataExchangeService();
service.SerializerFactory = serializerFactory;
System.Console.WriteLine("{0}:\n{1}\n", "Full as Unicode XML Document", service.GetFull(blog));
System.Console.WriteLine("{0}:\n{1}\n", "Header as Unicode XML Document", service.GetHeader(blog));
System.Console.WriteLine("{0}:\n{1}\n", "Exchange as Unicode XML Document", service.GetFullForExchange(blog));
System.Console.WriteLine();
serializerFactory = new JsonSerializerFactory();
service.SerializerFactory = serializerFactory;
System.Console.WriteLine("{0}:\n{1}\n", "Full as JSON Document", service.GetFull(blog));
System.Console.WriteLine("{0}:\n{1}\n", "Header as JSON Document", service.GetHeader(blog));
System.Console.WriteLine("{0}:\n{1}\n", "Exchange as JSON Document", service.GetFullForExchange(blog));
System.Console.WriteLine("Execution finished. Press a key to exit.");
System.Console.ReadLine();
}
示例8: GivenANewBlog_ThenItsLastUpdatedDateIsNow
public void GivenANewBlog_ThenItsLastUpdatedDateIsNow()
{
var blog = new Blog();
Assert.That(blog.LastUpdated, Is.LessThanOrEqualTo(DateTime.Now));
}
示例9: CanPerformDynamicQueryAndGetValidResults
public void CanPerformDynamicQueryAndGetValidResults()
{
var blogOne = new Blog
{
Title = "one",
Category = "Ravens"
};
var blogTwo = new Blog
{
Title = "two",
Category = "Rhinos"
};
var blogThree = new Blog
{
Title = "three",
Category = "Rhinos"
};
db.Documents.Put("blogOne", null, RavenJObject.FromObject(blogOne), new RavenJObject(), null);
db.Documents.Put("blogTwo", null, RavenJObject.FromObject(blogTwo), new RavenJObject(), null);
db.Documents.Put("blogThree", null, RavenJObject.FromObject(blogThree), new RavenJObject(), null);
var results = db.ExecuteDynamicQuery(null,new IndexQuery()
{
PageSize = 128,
Start = 0,
Cutoff = SystemTime.UtcNow,
Query = "Title.Length:3 AND Category:Rhinos"
}, CancellationToken.None);
Assert.Equal(1, results.Results.Count);
Assert.Equal("two", results.Results[0].Value<string>("Title"));
Assert.Equal("Rhinos", results.Results[0].Value<string>("Category"));
}
示例10: PostViewModel
public PostViewModel(Blog blog, Blogger blogger, Post post, List<Post> posts)
{
Post = post;
Blogger = blogger;
Blog = blog;
Posts = posts;
}
示例11: BelongTo
public static void BelongTo(this IList<Post> posts, Blog blog)
{
foreach (Post postItem in posts)
{
postItem.Blog = blog;
}
}
示例12: SimpleOperations
public void SimpleOperations()
{
Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer);
Blog[] blogs = Blog.FindAll();
Assert.IsNotNull(blogs);
Assert.AreEqual(0, blogs.Length);
Blog blog = new Blog();
blog.Name = "hammett's blog";
blog.Author = "hamilton verissimo";
blog.Save();
blogs = Blog.FindAll();
Assert.IsNotNull(blogs);
Assert.AreEqual(1, blogs.Length);
Blog retrieved = blogs[0];
Assert.IsNotNull(retrieved);
Assert.AreEqual(blog.Name, retrieved.Name);
Assert.AreEqual(blog.Author, retrieved.Author);
}
示例13: CreateBlog
private static void CreateBlog()
{
var blog = new Blog {BloggerName = "Julie", Title = "EF41 Blog", DateCreated=DateTime.Now};
//var blog = new Blog() { Title = "This is a blog with a really long blog title" };
var db = new Context();
db.Blogs.Add(blog);
try
{
db.SaveChanges();
}
catch (DbEntityValidationException ex)
{
foreach (var entityError in ex.EntityValidationErrors)
{
Console.WriteLine(entityError.Entry.Entity.GetType().Name);
foreach (var error in entityError.ValidationErrors)
{
Console.WriteLine("{0}: {1}", error.PropertyName, error.ErrorMessage);
}
}
Console.ReadKey();
}
}
示例14: FetchEnum_Join_on_a_HasMany_property_should_not_return_duplicate_records
public void FetchEnum_Join_on_a_HasMany_property_should_not_return_duplicate_records()
{
Blog[] blogs = Blog.FindAll();
Assert.IsNotNull(blogs);
Assert.AreEqual(0, blogs.Length);
var blog = new Blog() { Name = "Test blog", Author = "Eric Bowen" };
blog.Save();
var post = new Post(blog, "Post1", "Content1", "Category1");
post.Save();
blog.Posts.Add(post);
var post2 = new Post(blog, "Post2", "Content2", "Category2");
post2.Save();
blog.Posts.Add(post2);
blog.Save();
blogs = Blog.FindAll();
Assert.IsNotNull(blogs);
Assert.AreEqual(1, blogs.Length);
}
示例15: EditBlogViewModel
public EditBlogViewModel(string blogId)
{
BlogId = Int32.Parse(blogId);
_memUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath() + "blog/";
using (var context = new DataContext())
{
ThisBlog = context.Blogs.FirstOrDefault(x => x.BlogId == BlogId);
// Make sure we have a permalink set
if (String.IsNullOrEmpty(ThisBlog.PermaLink))
{
ThisBlog.PermaLink = ContentUtils.GetFormattedUrl(ThisBlog.Title);
context.SaveChanges();
}
// Get the list of Authors for the drop down select
BlogUsers = context.BlogUsers.Where(x => x.IsActive == true).OrderBy(x => x.DisplayName).ToList();
Categories = context.BlogCategories.Where(x => x.IsActive == true).ToList();
UsersSelectedCategories = new List<string>();
_thisUser = context.Users.FirstOrDefault(x => x.Username == _memUser.UserName);
}
// Get the admin modules that will be displayed to the user in each column
getAdminModules();
}