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
namespace Hagbarddenstore.Mvc | |
{ | |
using System; | |
using System.Web; | |
using System.Web.Routing; | |
/// <summary> | |
/// Defines the GuidConstraint type. | |
/// </summary> | |
public class GuidConstraint : IRouteConstraint |
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.IO; | |
namespace A | |
{ | |
public class B | |
{ | |
private string _configurationFilePath = "config.txt"; | |
private string _recPath = string.Empty; | |
public string ReadConfig() |
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
void Main() | |
{ | |
var dates = new[] | |
{ | |
new DateTime(2000, 1, 1), | |
new DateTime(2005, 1, 1), | |
new DateTime(2010, 1, 1), | |
new DateTime(2015, 1, 1) | |
}; | |
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
/** | |
* Solution | |
* |- Domain | |
* | `- Customers | |
* | |- Customer.cs | |
* | `- ICustomersRepository.cs | |
* |- Infrastructure | |
* | `- Customers | |
* | `- LinqToSqlCustomersRepository.cs | |
* `- Application |
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 LabelExtensions | |
{ | |
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object htmlAttributes) | |
{ | |
return LabelHelper(html, ModelMetadata.FromLambdaExpression(expression, html.ViewData), ExpressionHelper.GetExpressionText(expression), null, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); | |
} | |
internal static MvcHtmlString LabelHelper(HtmlHelper html, ModelMetadata metadata, string htmlFieldName, string labelText = null, IDictionary<string, object> htmlAttributes = null) | |
{ | |
var resolvedLabelText = labelText ?? metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last(); |
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
private IEnumerable<Task> CreateHandlerTasks(IDomainEvent domainEvent) | |
{ | |
if (domainEvent == null) | |
{ | |
return new Task[0]; | |
} | |
Func<IDomainEvent, IEnumerable<Task>> handlerCreator; | |
var type = domainEvent.GetType(); |
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
void Main() | |
{ | |
var testApplication = new TestApplication(); | |
var eventInfo = testApplication.GetType().GetEvents().First(); | |
EventHandlerPusher.AddEventHandler(testApplication, eventInfo, MyEventHandler); | |
EventHandlerPusher.AddEventHandler(testApplication, eventInfo, MyEventHandler); | |
testApplication.FireEvent(); |
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
void Main() | |
{ | |
var testApplication = new TestApplication(); | |
var eventInfo = testApplication.GetType().GetEvents().First(); | |
EventHandlerPusher.AddEventHandler(testApplication, eventInfo, MyEventHandler); | |
testApplication.FireEvent(); | |
} |
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
void Main() | |
{ | |
var testApplication = new TestApplication(); | |
testApplication.SomeEvent += EventHandler; | |
testApplication.FireEvent(); | |
} | |
void EventHandler(object sender, EventArgs e) |
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; | |
static class TimeKeeper | |
{ | |
public static readonly Func<DateTime> DefaultTimeKeeper = () => DateTime.UtcNow; | |
private static readonly object LockObject = new object(); | |
private static Func<DateTime> CurrentTimeKeeper = DefaultTimeKeeper; |