Format:
Recent snippets matching tags of Generics
public static IList<T> ToList<T>(this System.Data.SqlClient.SqlDataReader dr) where T : new() { Type type = typeof(T); if(System.Web.HttpContext.Current.Cache[type.Name + "_properties"] == null) { System.Web.HttpContext.Current.Cache.Insert(type.Name + "_properties", type.GetProperties().ToList()); } IList<PropertyInfo> properties = (IList<PropertyInfo>)System.Web.HttpContext.Current.Cache[type.Name + "_properties"]; IList<T> result = new List<T>(); while(dr.Read())
82 Views
no comments
public static decimal Accumulate(IEnumerable e) { decimal sum = 0; foreach (Account a in e) sum += a.Balance; return sum; }
129 Views
no comments
var realHandler = GetHandler<SomeType>(); var message = GetMessage(); //Returns derived type of SomeType var handlerType = typeof(IHandler<>); var genericType = message.GetType(); var genericHandler = handlerType.MakeGenericType(genericType); return realHandler --> as genericHandler would not work
181 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; namespace Orxxx.Data { public interface IRepository<T> { void Create(T entity);
171 Views
no comments
public interface IRepository<T> { T GetById(Guid id); T GetByQuery(Query query); void Add(T item); void Remove(T item); void Update(T item); } //mozliwe jest rozszezenie generycznego interfejsu o metody specyfikczne
303 Views
no comments
public class AnonymousComparer<T> : IComparer<T> { private Comparison<T> comparison; public AnonymousComparer(Comparison<T> comparison) { if (comparison == null) throw new ArgumentNullException("comparison"); this.comparison = comparison; }
158 Views
no comments
/// <summary> /// Return all properties from a type up to a specified base type in the inheritance hierarchy /// </summary> /// <param name="type">Type that will be examined</param> /// <param name="baseType">Where to stop in the inheritance hierarchy. Must be a type that first parameter inherits from /// </param> /// <returns>A list of all found properties</returns> public static List<PropertyInfo> GetAllProperties(Type type, Type baseType) { List<PropertyInfo> properties = new List<PropertyInfo>();
438 Views
no comments
[XmlRoot("dictionary")] public class XmlSerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable { #region Constructors public XmlSerializableDictionary() : base() { } public XmlSerializableDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary) { } public XmlSerializableDictionary(IEqualityComparer<TKey> comparer) : base(comparer) { }
319 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using LinqExtender.Configuration.Serialization; namespace LinqExtender.Configuration { /// <summary>
185 Views
no comments
GenericSorter<surveystateformatdata> gs = new GenericSorter<surveystateformatdata >();
SurveyStateFormatItems = gs.Sort(SurveyStateFormatItems.AsQueryable,
sortExpression, sortDirection).ToArray();
204 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; public class GenericSorter<T> { public IEnumerable<T> Sort(IEnumerable<T> source, string sortBy, string sortDirection) {
305 Views
no comments
/// <summary> /// Writes the text (expression body) of the function being called, followed by its output. /// </summary> /// <typeparam name="T">The return type of expression/function.</typeparam> /// <param name="expression"> /// The expression/function to be evaluated and whose output will be displayed. /// </param> /// <remarks> /// Useful in seeing the results of function calls while debugging or /// working on spike solutions (see http://www.extremeprogramming.org/rules/spike.html).
228 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
