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: Jeff Handley
C#
[TestMethod]
[Description("When the service provider func throws a null reference exception, the exception is thrown from ValidationContext.GetService")]
public void ValidationContext_InitializeServiceProvider_NullRefFunc() {
    MyServiceProvider serviceProvider = new MyServiceProvider();
    Func<Type, object> serviceProviderFunc = serviceType => serviceProvider.GetService(serviceType);
 
    ValidationContext context = new ValidationContext(new object());
    context.InitializeServiceProvider(serviceProviderFunc);
 
    serviceProvider = null;
by Jeff Handley   May 09, 2011 @ 5:23pm
Tags:
164 Views
no comments
 
C#
[EnableClientAccess()]
public class CustomerService : LinqToEntitiesDomainService<CustomerEntities>
{
    [Query, Insert, Update, Delete]
    public IQueryable<Customer> Customers { get; set; }
 
    [Query, Insert, Update]
    public IQueryable<Order> Orders { get; set; }
 
    [Update(UsingCustomMethod = true)]
by Jeff Handley   May 04, 2011 @ 4:51pm
Tags:
126 Views
no comments
 
C#
public static class NullDotExtension
{
    public static T _<O, T>(this O o, Func<O, T> t) where T : class
    {
        return (o == null ? (T)null : t(o));
    }
}
 
public class NullDotObject
{
by Jeff Handley   September 25, 2010 @ 12:05am
Tags:
186 Views
no comments
 
XML
<Window x:Class="ResizingFun.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" MinHeight="550" MinWidth="450" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition MinHeight="250" Height="*" />
            <RowDefinition Height="Auto" />
by Jeff Handley   September 13, 2010 @ 5:07pm
Tags:
172 Views
2 comments
 
C#
 
public partial class Customer : Entity
{
    protected override ValidationResult FormatValidationResult(ValidationResult result)
    {
        if (result.MemberNames.SingleOrDefault() == "HomeAddress.ZipCode")
        {
            return new ValidationResult(result.ErrorMessage.Replace("Zip Code", "Home Address Zip Code"), result.MemberNames);
        }
by Jeff Handley   August 19, 2010 @ 11:49pm
Tags:
191 Views
no comments
 
C#
[ExportDomainServiceProxyGenerator(typeof(MyRiaServicesCodeGenerator), "C#", "VB")]
public class MyRiaServicesCodeGenerator : IDomainServiceClientProxyCodeGenerator
{
    ...
}
 
 
[ExportDomainServiceProxyGenerator("MyOtherRiaServicesCodeGenerator", "C#", "VB")]
public class MyOtherRiaServicesCodeGenerator : IDomainServiceClientProxyCodeGenerator
{
by Jeff Handley   June 28, 2010 @ 6:22pm
Tags:
274 Views
no comments
 
C#
[TestMethod]
public void DictionaryWithTupleKeysMatchesOnNewTupleInstances()
{
    Dictionary<Tuple<CodeNamespace, Type>, bool> codeTypeReferences = new Dictionary<Tuple<CodeNamespace, Type>, bool>();
 
    CodeNamespace ns = new CodeNamespace("System");
    Type type = ns.GetType();
 
    Tuple<CodeNamespace, Type> t1 = new Tuple<CodeNamespace, Type>(ns, type);
    codeTypeReferences.Add(t1, true);
by Jeff Handley   June 18, 2010 @ 9:54am
Tags:
169 Views
no comments
 
C#
[TestClass]
public class MemberTests
{
    [TestMethod]
    public void CanGetInt64Member()
    {
        Patron patron = null;
        var member = Member.Of(() => patron.Id);
 
        Assert.IsNotNull(member);
by Jeff Handley   April 12, 2010 @ 10:28pm
Tags:
192 Views
no comments
 
C#
/// <summary>
/// Class for easily getting information about a type member,
/// and referencing the member by name, or getting it as a
/// <see cref="MemberInfo"/>, <see cref="PropertyInfo"/>,
/// <see cref="FieldInfo"/>, or <see cref="MethodInfo"/>.
/// </summary>
public class Member
{
    /// <summary>
    /// The <see cref="MemberInfo"/> discovered for the member specified.
by Jeff Handley   April 10, 2010 @ 3:21am
Tags:
986 Views
no comments
 
C#
public IEnumerable<Asset> GetPatronAssets(Patron patron)
{
    using (ISession session = Session.OpenSession())
        return session.CreateCriteria<Asset>()
            .Add(Restrictions.Eq(Member.Of<Asset>(asset => asset.PatronId), patron.Id))
            .List<Asset>();
}
 
by Jeff Handley   April 10, 2010 @ 2:00am
Tags:
227 Views
no comments
 
C#
[TestClass]
public class MemberTests
{
    [TestMethod]
    public void CanGetInt64Member()
    {
        Patron patron = null;
        var member = Member.Of(() => patron.Id);
 
        Assert.IsNotNull(member);
by Jeff Handley   April 10, 2010 @ 1:53am
Tags:
731 Views
no comments
 
C#
using System;
using System.Windows.Controls;
using System.Windows.Data;
 
namespace ContosoSales
{
    /// <summary>
    /// Step down the opacity of something based on the length of the
    /// text entered into the TextBox for which this watermark is used.
    /// </summary>
by Jeff Handley   February 22, 2010 @ 4:24pm
205 Views
no comments
 
C#
/// <summary> 
/// Implementation of <see cref="IEnumerable.GetEnumerator"/>.
/// </summary>
/// <returns><see cref="IEnumerator"/> for the collection.</returns>
public IEnumerator GetEnumerator()
{
    this.VerifyRefreshNotDeferred();
 
    // if we are paging but don't have a page index yet
    if (this.PageSize > 0 && this.PageIndex < 0)
by Jeff Handley   October 22, 2009 @ 11:15pm
Tags:
212 Views
no comments
 
Sub RemoveExclusiveAttributes()
    Dim originalSyntax = DTE.Find.PatternSyntax
    Dim originalWhat = DTE.Find.FindWhat
    Dim originalTarget = DTE.Find.Target
    Dim originalAction = DTE.Find.Action
 
    DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
    DTE.Find.FindWhat = "[Exclusive]"
    DTE.Find.Target = vsFindTarget.vsFindTargetCurrentProject
    DTE.Find.Action = vsFindAction.vsFindActionFind
by Jeff Handley   October 22, 2009 @ 10:49pm
279 Views
no comments
 
C#
[TestMethod]
[Description("Nullable decimal")]
public void NullableDecimal()
{
    var attr = new RangeAttribute(0, 100);
    decimal? value = null;
 
    Assert.IsTrue(attr.IsValid(value));
}
by Jeff Handley   October 12, 2009 @ 4:46pm
Tags:
284 Views
no comments
 
C#
using System;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace DuckTyping.Test
{
    [TestClass]
    public class DuckTests
    {
        #region No Members
by Jeff Handley   October 06, 2009 @ 9:55pm
Tags:
286 Views
no comments
 
C#
/// <summary>
/// Convert a choice number into a reader-friendly string.
/// </summary>
/// <param name="choiceNumber">
/// The choice number.  <c>1</c>-<c>254</c> represent a preferential ordering,
/// and a value of <c>255</c> represents a "Pass" choice.
/// </param>
/// <returns>A string such as <c>"1st Choice"</c> or <c>"Pass"</c>.</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// When a value of <c>0</c> is specified.
by Jeff Handley   August 15, 2009 @ 10:58pm
249 Views
no comments
 
C#
private static PropertyChangedEventArgs CurrentItemChangedEventArgs = new PropertyChangedEventArgs("CurrentItem");
private static PropertyChangedEventArgs CurrentPositionChangedEventArgs = new PropertyChangedEventArgs("CurrentPosition");
private static PropertyChangedEventArgs IsCurrentBeforeFirstChangedEventArgs = new PropertyChangedEventArgs("IsCurrentBeforeFirst");
 
...
 
this.PropertyChanged(this, CurrentItemChangedEventArgs);
this.PropertyChanged(this, CurrentPositionChangedEventArgs);
this.PropertyChanged(this, IsCurrentBeforeFirstChangedEventArgs);
by Jeff Handley   August 14, 2009 @ 12:15am
379 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