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: Mikael Henriksson
C#
public class Crypt
{
  public static string OpenSslSign(string privateKeyFile, string content)
  {
    var pkey = new PrivateKey();
    pkey.LoadPemFile(privateKeyFile);
    string pkeyXml = pkey.GetXml();
    var rsa = new Rsa();
    bool success = rsa.UnlockComponent("30-day trial");
    if (success != true) {
by Mikael Henriksson   August 31, 2010 @ 11:31pm
179 Views
no comments
 
param(
  [Parameter(Position=0,Mandatory=0)]
  [string]$buildFile = 'default.ps1',
  [Parameter(Position=1,Mandatory=0)]
  [string[]]$taskList = @(),
  [Parameter(Position=2,Mandatory=0)]
  [string]$framework = '3.5',
  [Parameter(Position=3,Mandatory=0)]
  [switch]$docs = $false,
  [Parameter(Position=4,Mandatory=0)]
by Mikael Henriksson   July 05, 2010 @ 2:01am
Tags: Psake
220 Views
no comments
 
C#
public static class TinyUrl
    {
        private static readonly Random Random = new Random();
 
        public static string Get()
        {
            int random = Random.Next();
            return Base62ToString(uint.MaxValue);
        }
by Mikael Henriksson   April 30, 2010 @ 5:18am
Tags: TinyUrl, C#
255 Views
no comments
 
XML
<target name="buildnumber">
   <if test="${property::exists('build.number')}">
      <property name="project.fullversion" value="${build.number}" />
   </if>
   <asminfo output="${solution.dir}/AssemblyInfo.cs" language="CSharp">
      <imports>
         <import namespace="System" />
         <import namespace="System.Reflection" />
         <import namespace="System.Runtime.InteropServices" />
      </imports>
by Mikael Henriksson   March 24, 2010 @ 3:17am
Tags: TeamCity, NAnt
184 Views
no comments
 
XML
<UnicastBusConfig>
  <MessageEndpointMappings>
    <add Messages="Messages.Persistence" Endpoint="PersisterInputQueue" />
  </MessageEndpointMappings>
</UnicastBusConfig>
by Mikael Henriksson   January 19, 2010 @ 6:34am
382 Views
no comments
 
C#
For<IUnitOfWork>()
    .LifecycleIs(new UniquePerRequestLifecycle())
    .Use(x => new UnitOfWork(x.GetInstance<ISessionFactory>(Keys.SessionFactoryName)));
by Mikael Henriksson   January 13, 2010 @ 3:43am
767 Views
no comments
 
C#
public class WrappedFileInfo : WrappedFileSystemInfo {
        public WrappedFileInfo(string baseDir, string path, bool flatten) : base(baseDir, path, new FileInfo(path), flatten) {
        }
 
        public override void CopyToDirectory(string path) {
            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }
 
            if (Flatten) {
by Mikael Henriksson   January 12, 2010 @ 4:10am
Tags: Phantom
148 Views
no comments
 
C#
protected void Application_Start(object sender, EventArgs e)
 {
     try
     {
         Bus = Configure.WithWeb()
             .SpringBuilder()
             .XmlSerializer()
             .MsmqTransport()
                 .IsTransactional(false)
                 .PurgeOnStartup(false)
by Mikael Henriksson   December 16, 2009 @ 3:24am
241 Views
no comments
 
function vCardTohCard(io) {
    var testStr = io.value.replace(/\n/gm, "");
    if (testStr.match(/BEGIN:VCARD.*END:VCARD/im)) {
        var vCardArr = io.value.match(/^(.*)$/gm);
        var vCardTmp = {};
        for (var prop in vCardArr) {
            if (vCardArr[prop] != null) {
                var arr = vCardArr[prop].match(/(.*?):(.*)/);
                if ((arr) && (arr.length = 3)) {
                    if (vCardArr[prop].match(/URL/i)) {
by Mikael Henriksson   December 02, 2009 @ 9:39am
Tags: vcard
210 Views
no comments
 
C#
public bool OnPreInsert(PreInsertEvent @event)
{
    var entity = @event.Entity as ParentVersion;
    if (entity == null)
    {
        return false;
    }
 
    var currentMaxVersion = @event.Session.CreateCriteria<ParentVersion>("pv")
        .Add(Restrictions.Eq("pv.Parent.Id", entity.Parent.Id))
by Mikael Henriksson   November 19, 2009 @ 1:09pm
187 Views
no comments
 
C#
public class ParentMap : ClassMap<Parent>
{
    public ParentMap()
    {
        Table("parent_def");      
        Id(x => x.Id,"parent_id");
        Map(x => x.UID, "parent_uid").CustomSqlType("varchar").Length(40);
        Map(x => x.DeletedAt ,"dte_deleted").Nullable();
        Map(x => x.ModifiedAt, "dte_modified").Nullable();
        Map(x => x.CreatedAt, "dte_created").Nullable();
by Mikael Henriksson   November 19, 2009 @ 5:42am
234 Views
no comments
 
C#
.Mappings(m => { 
                 m.FluentMappings.AddFromAssemblyOf<SomeMap>();
         m.AutoMappings.AddFromAssemblyOf<SomeOtherMap>();
            });
by Mikael Henriksson   November 12, 2009 @ 9:36am
337 Views
no comments
 
XML
<many-to-one cascade="all" update="false" insert="true" class="Data" foreign-key="backup_id" name="Data">
    <column name="backup_id" />
</many-to-one>
by Mikael Henriksson   November 11, 2009 @ 6:11am
191 Views
no comments
 
C#
public static Configure CustomSagaPersister(this Configure config, ISessionFactory sessionFactory)
{
    if (sessionFactory == null)
    {
        throw new InvalidOperationException("Session factory is needed for saga persistence.");
    }
 
    config.Configurer.RegisterSingleton<ISessionFactory>(sessionFactory);
    config.Configurer
        .ConfigureComponent<FluentSagaPersister>(ComponentCallModelEnum.Singlecall)
by Mikael Henriksson   November 08, 2009 @ 9:40am
204 Views
no comments
 
C#
public class SagaFinder : IFindSagas<MySagaData>.Using<MyMessage>
{
    public MySagaData FindBy(MyMessage message)
    {
        
    }
}
by Mikael Henriksson   November 07, 2009 @ 5:53am
361 Views
no comments
 
C#
Configuration config = Fluently.Configure()
    .Database(MsSqlConfiguration.MsSql2008.ConnectionString(
                  c => c.FromConnectionStringWithKey("ConnectionString"))
                  .Cache(c =>
                         c.UseQueryCache()
                             .QueryCacheFactory<StandardQueryCacheFactory>()
                             .ProviderClass<HashtableCacheProvider>()
                             .UseMinimalPuts()
                  )
                  .UseReflectionOptimizer()
by Mikael Henriksson   October 25, 2009 @ 2:45am
228 Views
no comments
 
C#
new PersistenceSpecification<Component>(session, new ComponentEqualityComparer())
 
public class ComponentEqualityComparer : IEqualityComparer
{
    #region IEqualityComparer Members
 
    public bool Equals(object x, object y)
    {
        if (x == null || y == null)
        {
by Mikael Henriksson   October 13, 2009 @ 3:15am
193 Views
no comments
 
C#
<%=Html.DropDownList("ContactHistory", ViewData["ContactHistory"], new { onchange = "doSomeJavaScript()" })%>
by Mikael Henriksson   October 08, 2009 @ 4:05am
Tags: MVC
406 Views
no comments
 
C#
private static ISessionFactory CreateSessionFactory()
       {
           return Fluently.Configure()
               .Database(MsSqlConfiguration.MsSql2008
                   .ConnectionString(c => c
                        .FromConnectionStringWithKey("MyStore.Properties.Settings.StoreConnectionString"))
                        )
               .Mappings(m =>
                   m.FluentMappings
                       .AddFromAssemblyOf<Program>())
by Mikael Henriksson   October 07, 2009 @ 11:13pm
223 Views
no comments
 
C#
public class XmlType : IUserType
{
    public new bool Equals(object x, object y)
    {
        if (x == null || y == null)
            return false;
 
        var xdoc_x = (XmlDocument)x;
        var xdoc_y = (XmlDocument)y;
        return xdoc_y.OuterXml == xdoc_x.OuterXml;
by Mikael Henriksson   September 23, 2009 @ 1:17pm
500 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