CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: Robert.Eberhart
# SetVersion.ps1
#
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
#
# usage:  
#  from cmd.exe: 
#     powershell.exe SetVersion.ps1  2.8.3.0
# 
#  from powershell.exe prompt: 
#     .\SetVersion.ps1  2.8.3.0
by Robert.Eberhart   March 30, 2011 @ 5:22pm
Tags:
152 Views
no comments
 
C#
public static void AddDomainUserToLocalGroup(String domain, String userName, String groupName)
        {
            String groupPath = String.Format("WinNT://{0}/{1},group", Environment.MachineName, groupName);
            DirectoryEntry theGroup = new DirectoryEntry(groupPath);
            if (theGroup.SchemaClassName != "Group")
            {
                throw new ArgumentException("The local group specified doesn't exist.");
            }
 
            String userPath = String.Format("WinNT://{0}/{1},user", domain, userName);
by Robert.Eberhart   March 18, 2011 @ 9:59am
Tags:
64 Views
no comments
 
C#
public IList MergeSort(IList list)
{
    if (list.Count <= 1)
        return list;
 
    int mid = list.Count / 2;
 
    IList left = new ArrayList();
    IList right = new ArrayList();
by Robert.Eberhart   December 20, 2010 @ 10:30am
270 Views
no comments
 
C#
private static ISessionFactory CreateSessionFactory()
{
    var cfg = new Configuration().Configure("nhibernate.config");
    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionStringName, 
System.Configuration.ConfigurationManager.ConnectionStrings[System.Environment.MachineName].ConnectionString));
    return cfg.BuildSessionFactory();
}
by Robert.Eberhart   December 20, 2010 @ 8:33am
Tags: C#, NHibernate
183 Views
no comments
 
C#
public abstract class EntityBase {
    private object key;
    
    protected EntityBase() : this(null) {
    }
    
    protected EntityBase(object key) {
        this.key = key;
    }
    
by Robert.Eberhart   December 20, 2010 @ 7:35am
Tags: C#, DDD
139 Views
no comments
 
C#
/// <summary>
/// This is a trivial class that is used to make sure that Equals and GetHashCode
/// are properly overloaded with the correct semantics. This is exteremely important
/// if you are going to deal with objects outside the current Unit of Work.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TKey"></typeparam>
public abstract class EqualityAndHashCodeProvider<T, TKey>
    where T : EqualityAndHashCodeProvider<T, TKey>
{
by Robert.Eberhart   December 20, 2010 @ 7:14am
Tags:
85 Views
no comments
 
C#
namespace Northwind
{
    /// <summary>
    /// A base class for all entities that implements identity equality.
    /// </summary>
    /// <typeparam name="TId">The type of the ID.</typeparam>
    /// <typeparam name="T">The type of the derived class (required for equality)</typeparam>
    public abstract class EntityBase<TId, T> where T : EntityBase<TId, T>
    {
        private TId _id;
by Robert.Eberhart   December 20, 2010 @ 7:11am
Tags: NHibernate, C#, DDD
223 Views
no comments
 
C#
private static char[] base26Chars =  "abcdefghijklmnopqrstuvwxyz".ToCharArray();
 
public static string Base26Encode(Int64 value) {
    string returnValue = null;
    do {
        returnValue = base26Chars[value % 26] + returnValue;
        value /= 26;
    } while (value-- != 0);
 
    return returnValue;
by Robert.Eberhart   December 20, 2010 @ 6:57am
Tags: C#, Encoding
196 Views
no comments
 
C#
private LinkedList<Element>MergeSort(LinkedList<Element> linkedList, string sortType) {
    if (linkedList.Count <= 1){
        return linkedList;
    }
 
    LinkedList<Element> left, right, result;
 
    int middle = linkedList.Count / 2;
 
    left = ReturnLinkedListSegment(0, middle, linkedList);
by Robert.Eberhart   December 20, 2010 @ 6:53am
161 Views
no comments
 
$newVirtualDirectory = $args[0]
$physicalPath = $args[1]
 
# gets the IIS root object
$iis = [ADSI]"IIS://localhost/w3svc/1/root"
 
$vdir = $iis.psbase.children | where {$_.AppRoot -eq ('/LM/W3SVC/1/Root/' + $newVirtualDirectory)}
 
# Check to see if the virtual directory exists
if (!$vdir) {
by Robert.Eberhart   December 20, 2010 @ 6:52am
237 Views
no comments
 
$(function() {
    $('input [id$btnSort]').click(
        function(e) {
            e.preventDefault();
            var sortedDdl = $.makeArray($('select[id$=DDL]option'))
                .sort(function() {
                    return #(0).text() < $(n).text ? -1 : 1;
                }
            );
            
by Robert.Eberhart   December 20, 2010 @ 6:46am
Tags:
183 Views
no comments
 
C#
public static bool operator ==(Region r1, Region r2)
{
    if (object.ReferenceEquals( r1, r2)) {
        // handles if both are null as well as object identity
        return true;
    }
 
    if ((object)r1 == null || (object)r2 == null)
    {
       return false;
by Robert.Eberhart   December 20, 2010 @ 6:37am
Tags:
82 Views
1 comments
 
C#
public static bool IsNullOrWhiteSpace(string value)
 
{
 
    if (value != null)
 
    {
 
        for (int i = 0; i < value.Length; i++)
by Robert.Eberhart   March 15, 2010 @ 7:44am
Tags:
116 Views
1 comments
 
SQL
SELECT Distinct MenuItemParentID
    FROM ( select * from MenuItem A where a.MenuItemParentId is not null ) TestTable
WHERE not exists( select * from MenuItem TestItems where testItems.MenuItemId = TestTable.MenuItemParentId )
by Robert.Eberhart   January 08, 2010 @ 7:55am
Tags:
158 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate