Format:
Recent snippets matching tags of expressions
//Email regex validator Regex regex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); //Website regex validator Regex regex = new Regex(@"^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$"); //Comments on forum regex validator (max 4000 characters) Regex regex = new Regex(@"^[+_%@:,.'!?"\\\^\&\#\$\*\(\)\-\/a-zA-Z0-9\s]{1,4000}$");
11 Views
no comments
protected void Map(Expression<Func<T, object>> property, Func<PropertyDescriptor, string> columnNamer) { MemberInfo memberInfo; if (property.Body is MemberExpression) memberInfo = ((MemberExpression)property.Body).Member; else memberInfo = ((MemberExpression)((UnaryExpression)property.Body).Operand).Member; Map(memberInfo.Name, columnNamer);
184 Views
no comments
using System; using System.Linq.Expressions; public static class Aaa { public class A { public string NameField; }
177 Views
no comments
public static void Copy(string sourceDirName, string destDirName, bool excludeSubdirectories) { // Style #1: fluent Guard.MethodArgument("sourceDirName").IsNotNullOrEmpty(sourceDirName); Guard.MethodArgument("destDirName").IsNotNullOrEmpty(destDirName, "The destination directory is required!"); // Style #2: lambdas and expressions Guard.Argument.IsNotNullOrWhiteSpace(()=>sourceDirName); Guard.Argument.IsNotNullOrWhiteSpace(()=>destDirName, "The destination directory is required!");
310 Views
1 comments
[TestMethod] public void CanGetValueItemfromCollection() { var col = new Collection<string> {"Hello", "World"}; var testItem = col.GetValueItem(c => c.Equals("World")); Assert.AreEqual(testItem, "World"); } [TestMethod] public void CanGetReferenceItemfromCollectionByProperty()
302 Views
no comments
/// <summary> /// Find an object in a value-type collection. /// </summary> /// <typeparam name="T">Type of collection.</typeparam> /// <param name="collection">The collection to search.</param> /// <param name="isMatch">The Predicate to test to find the collection item.</param> /// <returns>The collection item.</returns> public static T GetValueItem<T>(this ICollection<T> collection, Predicate<T> isMatch) { foreach (var item in collection)
280 Views
no comments
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Text.RegularExpressions; using System.Text; using System.IO; using System.Reflection;
329 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
