Skip to content

Instantly share code, notes, and snippets.

View KevM's full-sized avatar

Kevin Miller KevM

View GitHub Profile
[Test]
public void Structure_map_should_use_the_last_in_configuration_for_a_type()
{
var container = new Container(config => config.ForRequestedType<ILogger>().TheDefaultIsConcreteType<NullLogger>());
container.GetInstance<UsesLogging>().Logger.ShouldBeOfType<NullLogger>();
container.Configure(config => config.ForRequestedType<ILogger>().TheDefault.Is.ConstructedBy(s=>new Log4NetLogger(s.ParentType)));
container.GetInstance<UsesLogging>().Logger.ShouldBeOfType<Log4NetLogger>();
//Here is some code that assumes you have references to the Dovetail SDK assemblies.
//First off here is what needs to be in the app settings part of the web.config file.
<appSettings>
<!-- Settings from the Configuring fcSDK documentation -->
<add key="fchoice.connectionstring" value="connectionstring"/>
<add key="fchoice.dbtype" value="mssql"/>
<add key="fchoice.disableloginfromfcapp" value="false"/>
<add key="fchoice.nocachefile" value="true"/>
public class SolutionMap : DataMap<Solution>
{
protected override void MapDefinition()
{
FromTable("probdesc")
.Assign(d => d.ID).FromIdentifyingField("id_number")
.Assign(d => d.Title).FromField("title")
.Assign(d => d.Created).FromField("creation_time")
.Assign(d => d.DatabaseIdentifier).FromField("objid")
.Assign(d => d.MultiField).FromFields("objid", "title")
public class SolutionMap : DataMap<Solution>
{
protected override void MapDefinition()
{
FromTable("probdesc")
.Assign(d => d.ID).FromIdentifyingField("id_number")
.Assign(d => d.Title).FromField("title")
.Assign(d => d.Created).FromField("creation_time")
.Assign(d => d.DatabaseIdentifier).FromField("objid")
.Assign(d => d.MultiField).FromFields("objid", "title")
try
{
using (var pop3 = CreatePop3Connection(account))
{
_logger.LogDebug("Mailbox has {0} new messages.", pop3.InboxMessageCount);
foreach (MailMessage mailMessage in pop3.DownloadEntireMessages())
{
_logger.LogDebug("Email received from {0} with id {1}", mailMessage.From.Email, mailMessage.MessageID);
@KevM
KevM / gist:157469
Created July 28, 2009 15:53
Extension class for turning JSON strings into objects
using System.Web.Script.Serialization;
// ^^^ for this namespace ^^^ add a reference to System.Web.Extensions
public static class StringExtentensions
{
public static string ToJson(this object objectToSerialize)
{
return new JavaScriptSerializer().Serialize(objectToSerialize);
}
Dear Winner!
We are pleased to notify you that your email address won the sum of GBP£1.5M (One Million Five Hundred Thousand British Pounds) from our monthly MSN/AOL Online Sweepstake Promotion held this year 2009
Wherein your Email Address emerged as one of our online winning cash award of GBP£1.5M (One Million Five Hundred Thousand British Pounds) and your file falls within our European Claim Office in London.
You are advised to contact the processing officer immediately upon the receipt of this message for more information concerning the claim, processing and eventual payment of the above prize to you.
Contact Mr. John More of Trust Delivery Service for further details:
public abstract class RetryingConsumerOfAll<TMessage> : Consumes<TMessage>.All where TMessage : class
{
protected RetryingConsumerOfAll(Scheduler scheduler)
{
Scheduler = scheduler;
}
private int _maximumNumberOfRetries = 5;
public int MaximumNumberOfRetries
var concreteIRuleOfMessageType = container.Model.InstancesOf(typeof(IRule<MESSAGE>)).FirstOrDefault().ConcreteType;
var concreteIRuleSetOfMessageType = container.Model.InstancesOf(typeof(IRuleSet<MESSAGE>)).FirstOrDefault().ConcreteType;
var ruleInstances = new SmartInstance<IRule<MESSAGE>[]>().TheArrayOf<IRule<MESSAGE>>("rules")
.Contains(rule =>
{
foreach (var ruleExpresion in ruleSetExpression.Rules)
{
var localRuleExpression = ruleExpresion;
rule.Instance(
public abstract class Context<T> where T : class
{
[SetUp]
public void Setup()
{
_services = new RhinoAutoMocker<T>(MockMode.AAA);
OverrideMocks();
_cut = _services.ClassUnderTest;