Check out my new blog at

Monday, February 04, 2008

Windows Live Writer Plugin : Insert Code

I found a plugin for Windows Live Writer for inserting code into a post.  Very cool, however, it doesn't work correctly with Blogspot unless you add the plugin's stylesheet output to the Posts style sheet.  So, if you are a Blogspot user, take the CSS below, go to Customize\Template\Edit HTML and locate the Blogs CSS section.  Paste it in and you are good to go FOR C# ONLY.  Get the plugin here.
.csharpcode, .csharpcode pre
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
.csharpcode .lnum { color: #606060; }
 Here is a sample.
     public Dictionary<string, SPTS20User> GetUserList(string site)
                if (_rsspUserGroupWebService == null)
                    _rsspUserGroupWebService = new MsSpUserGroupWebService.UserGroup();
                    _rsspUserGroupWebService.Url = _serverURL.ToString() + site + _UsersServicePath;
                    _rsspUserGroupWebService.Credentials = _credentials;

                XmlNode usersXml = _rsspUserGroupWebService.GetUserCollectionFromSite();
                Dictionary<string, SPTS20User> users = new Dictionary<string, SPTS20User>();

                foreach (XmlNode userNode in usersXml.FirstChild.ChildNodes)
                    SPTS20User user = new SPTS20User();

                    user.Email = userNode.Attributes["Email"].Value;

                    if (users.ContainsKey(user.Email) == false)
                        user.Account = userNode.Attributes["LoginName"].Value;

                        user.IsDomainGroup = Convert.ToBoolean(userNode.Attributes["IsDomainGroup"].Value);
                        user.IsSiteAdmin = Convert.ToBoolean(userNode.Attributes["IsSiteAdmin"].Value);
                        user.SID = userNode.Attributes["Sid"].Value;
                        user.Notes = userNode.Attributes["Notes"].Value;

                        user.Email = user.Email.ToLower();

                        users.Add(user.Email, user);

                return users;
            catch (System.Exception e)

No comments :


Content on this site is provided "AS IS" with no warranties and confers no rights. Additionally, all content on this site is my own personal opinion and does not represent my employer's view in any way.