This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class ServiceControllerFactory : IServiceControllerFactory | |
{ | |
public IServiceController CreateController() | |
{ | |
if (Process.GetCurrentProcess().GetParent().ProcessName == "services") | |
return new ScmServiceController(); | |
return new AsynchronousServiceController(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ProcessExtensions | |
{ | |
public static Process GetParent(this Process child) | |
{ | |
int parentPid = 0; | |
IntPtr hnd = Kernel32.CreateToolhelp32Snapshot(Kernel32.TH32CS_SNAPPROCESS, 0); | |
if (hnd == IntPtr.Zero) | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# robocopy.rb | |
class Robocopy | |
attr_accessor :source, :target, :excludeDirs, :includeFiles, :logPath | |
def run() | |
robocopy = "robocopy.exe " \ | |
"\"#{@source}\" " \ | |
"\"#{@target}\" " \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rake/gempackagetask' | |
task :default => [:package] | |
spec = Gem::Specification.new do |spec| | |
spec.platform = Gem::Platform::RUBY | |
spec.summary = "NoRM - A MongoDB driver for .Net" | |
spec.name = "norm" | |
spec.version = "0.9.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rake/gempackagetask' | |
task :default => [:package] | |
spec = Gem::Specification.new do |spec| | |
spec.platform = Gem::Platform::RUBY | |
spec.summary = "A MongoDB driver for .Net" | |
spec.name = "norm" | |
spec.version = "0.9.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringExtensions | |
{ | |
public static string Hash(this string value, string salt) | |
{ | |
return SHA1.Create(). | |
ComputeHash(Encoding.UTF8.GetBytes(salt + value)). | |
Select(x => x.ToString("x2")). | |
Aggregate((a, x) => a + x); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Security.Cryptography; | |
using System.Text; | |
using Norm; | |
using System.Linq; | |
namespace MongoSandbox | |
{ | |
class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var mongo = Mongo.Create("mongodb://user:password@localhost/Test")) | |
{ | |
// Some strongly typed filter, I want a document with a number of 2 | |
Expression<Func<User, bool>> filterExpression = u => u.Number == 2; | |
// A NoRM specific object, not important | |
var filter = new Expando(); | |
// I need to pull the name "Number" and the value 2 | |
// and programatically pass it to the NoRM expando object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoDbSandbox | |
{ | |
public static void Main() | |
{ | |
var repo = new MongoDbObjectRepository("mongodb://user:password@localhost/Test"); | |
var model = new Model {Number = 2}; | |
var user = repo.Fetch<User>(u => u.Number == model.GetNumber(45)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IEnumerableExtensions | |
{ | |
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action) | |
{ | |
foreach (var item in items) action(item); | |
} | |
} |
OlderNewer