Format:
Recent snippets for: Jeff Handley
[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;
164 Views
no comments
[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)]
126 Views
no comments
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 {
186 Views
no comments
<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" />
172 Views
2 comments
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); }
191 Views
no comments
[ExportDomainServiceProxyGenerator(typeof(MyRiaServicesCodeGenerator), "C#", "VB")] public class MyRiaServicesCodeGenerator : IDomainServiceClientProxyCodeGenerator { ... } [ExportDomainServiceProxyGenerator("MyOtherRiaServicesCodeGenerator", "C#", "VB")] public class MyOtherRiaServicesCodeGenerator : IDomainServiceClientProxyCodeGenerator {
274 Views
no comments
[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);
169 Views
no comments
[TestClass] public class MemberTests { [TestMethod] public void CanGetInt64Member() { Patron patron = null; var member = Member.Of(() => patron.Id); Assert.IsNotNull(member);
192 Views
no comments
/// <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.
986 Views
no comments
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>(); }
227 Views
no comments
[TestClass] public class MemberTests { [TestMethod] public void CanGetInt64Member() { Patron patron = null; var member = Member.Of(() => patron.Id); Assert.IsNotNull(member);
731 Views
no comments
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>
205 Views
no comments
/// <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)
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
279 Views
no comments
[TestMethod] [Description("Nullable decimal")] public void NullableDecimal() { var attr = new RangeAttribute(0, 100); decimal? value = null; Assert.IsTrue(attr.IsValid(value)); }
284 Views
no comments
using System; using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DuckTyping.Test { [TestClass] public class DuckTests { #region No Members
286 Views
no comments
/// <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.
249 Views
no comments
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);
379 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
