Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. namespace MultiPostExtension.Blogs
  2. {
  3.  
  4.     #region using
  5.  
  6.     using System;
  7.     using System.IO;
  8.     using System.Web;
  9.     using System.Net;
  10.     using System.Text;
  11.     using BlogEngine.Core;
  12.     using BlogEngine.Core.Web.Controls;
  13.     using System.Threading;
  14.     using BlogsAPI;
  15.  
  16.     #endregion
  17.  
  18. /// <summary>
  19. /// Design a post to somewhere
  20. /// </summary>
  21.     public class LiveInternet : BlogHosting, IBlogHosting
  22.     {
  23.         /// <summary>
  24.         /// NameOf
  25.         /// </summary>
  26.         public String Name
  27.         {
  28.             get
  29.             {
  30.                 return "LiveInternet";
  31.             }
  32.         }
  33.  
  34.         /// <summary>
  35.         /// Defs
  36.         /// </summary>
  37.         /// <returns></returns>
  38.         public SettingsCollection Defaults()
  39.         {
  40.             SettingsCollection sc = new SettingsCollection();
  41.             sc.Add("true");
  42.             sc.Add(" ");
  43.             sc.Add(this.Name);
  44.             sc.Add("flashr");
  45.             sc.Add("");
  46.             sc.Add("noneed");
  47.             sc.Add("1");
  48.             sc.Add(PostType.Public.ToString());
  49.             return sc;
  50.         }
  51.  
  52.         /// <summary>
  53.         /// Constructor with params
  54.         /// </summary>
  55.         /// <param name="sets"></param>
  56.         public LiveInternet(SettingsCollection settings)
  57.         {
  58.             this.Hostname = "liveinternet.ru";
  59.             this.blogSettings = settings;
  60.         }
  61.  
  62.         /// <summary>
  63.         /// Making it published
  64.         /// </summary>
  65.         /// <param name="post">Object of Post</param>
  66.         public Boolean PublishItem(IPublishable post)
  67.         {
  68.             Boolean bRet = false;
  69.             if (this.AttemptsCount++ < this.blogSettings.Attempts)
  70.             {
  71.                 if (this.MakePost(post))
  72.                 {
  73.                     bRet = true;
  74.                 }
  75.             }
  76.             else
  77.             {
  78.                 throw new NotSupportedException("Too many fails for " + post.Title);
  79.             }
  80.             return bRet;
  81.         }
  82.  
  83.         /// <summary>
  84.         /// Hidden actions 
  85.         /// </summary>
  86.         /// <param name="post">Published content</param>
  87.         /// <returns></returns>
  88.         private Boolean MakePost(IPublishable post)
  89.         {
  90.             BlogPost blogPost = new BlogPost(){
  91.                  Subject = post.Title,
  92.                  Body = post.Content,
  93.                  type = post.IsPublished?PostType.Public:PostType.Private
  94.             };
  95.             //adding tags
  96.             blogPost.Attributes.Add(new PostAttribute(PostParams.Tags.ToString(),GetTags(post.Categories)));
  97.  
  98.             BlogsAPI.Sites.Liveinternet liru = new BlogsAPI.Sites.Liveinternet();
  99.             return liru.MakePost(new UserAccaunt(
  100.                 this.blogSettings.Login,
  101.                 this.blogSettings.Password
  102.                 ), blogPost
  103.                 ).Success;
  104.         }
  105.     }
  106. }




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2012