This file contains hidden or 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 HtmlHelpers | |
| { | |
| public static IHtmlString ArrayCheckBoxFor<TModel, TArray>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TArray[]>> expression, TArray value) | |
| { | |
| ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData); | |
| var tagBuilder = new TagBuilder("input"); | |
| tagBuilder.Attributes.Add("type", "checkbox"); | |
| tagBuilder.Attributes.Add("name", metadata.PropertyName); | |
| tagBuilder.Attributes.Add("value", value.ToString()); |
This file contains hidden or 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 interface IWhateverDataTableProvider | |
| { | |
| DataTable GetData(); | |
| } | |
| public class WhateverDataTableProvider : IWhateverDataTableProvider | |
| { | |
| public DataTable GetData() | |
| { | |
| // put all that hard-coded, hard to test stuff here... |
This file contains hidden or 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
| // An example of how to work with an array in a non-blocking | |
| // loop. | |
| // This will store our results. | |
| var result = { | |
| count: 0, | |
| sum: 0, | |
| toString: function () { | |
| return "Count: " + result.count + ", Sum: " + result.sum; | |
| } |
This file contains hidden or 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
| module A | |
| def do_something | |
| puts "In A" | |
| end | |
| end | |
| module B | |
| def do_something_else | |
| puts "In B" | |
| end |
This file contains hidden or 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
| class X | |
| def do_something | |
| '**PUBLIC**' | |
| end | |
| private | |
| def do_something_privately | |
| '--private--' | |
| end |
This file contains hidden or 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 abstract class HttpSession : IHttpSession | |
| { | |
| protected IKeyValueStore storage; | |
| public virtual int UserId | |
| { | |
| get { return Get<int>("user_id"); } | |
| set { storage["user_id"] = value; } | |
| } | |
This file contains hidden or 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
| // There are three times when I will openly use static methods in C#. | |
| // 1. Providers | |
| // 2. State Machines (variation on provider, really) | |
| // 3. Any time where there *really* is *one* of something. | |
| /// <summary> | |
| /// 1. Providers give you a way to create new objects without using a constructor. Ideally, you would always | |
| /// use Dependency Injection and Inversion of Control. However, these techniques do not work in all situations, | |
| /// so we need a testable fallback. Providers fill this need. |
This file contains hidden or 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 NHibernateSessionManager | |
| { | |
| private const string CONNECTION_STRING_NAME = "..."; | |
| private static Configuration configuration; | |
| private static readonly ILog log; | |
| private static ISessionFactory sessionFactory; | |
| static NHibernateSessionManager() | |
| { |
This file contains hidden or 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 DBTest : IDisposable | |
| { | |
| private DataContext dataContext; | |
| public DBTest() | |
| { | |
| dataContext = new DataContext(); | |
| } | |
| public void Dispose() |
This file contains hidden or 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 HttpTest | |
| { | |
| private static HttpContext httpContext; | |
| private static HttpWorkerRequest httpWorkerRequest; | |
| private static StringBuilder outputStringBuilder; | |
| private static TextWriter output; | |
| private static NameValueCollection httpHeaders; | |
| private static HttpCookieCollection requestCookies; | |
| private static HttpCookieCollection responseCookies; |