New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of generics
C#
 
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
by Hadi Eskandari   July 19, 2010 @ 8:45am
Tags: Generics
14 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
 
namespace Orxxx.Data 
{
    public interface IRepository<T> 
    {
        void Create(T entity);
by darek156   May 07, 2010 @ 1:54am
Tags: generics
28 Views
no comments
 
C#
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
by darek156   April 02, 2010 @ 1:21am
63 Views
no comments
 
C#
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;
    }
by darek156   April 01, 2010 @ 1:47am
Tags: generics
35 Views
no comments
 
C#
/// <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>();
117 Views
no comments
 
    <Serializable()> _
    Public MustInherit Class ViewModelBase(Of T, U)
        Inherits Models.PropBase
 
        Private _ItemsCollection As T
        <DisplayName("Items Collection"), Category("Data"), Description("Collection of items"), _
        [ReadOnly](False), Browsable(True), EditorBrowsable(EditorBrowsableState.Always)> _
        Public Property ItemsCollection() As T
            Get
                Return _ItemsCollection
January 18, 2010 @ 4:56am
134 Views
no comments
 
C#
[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) { }
by Athens Springer   December 17, 2009 @ 10:34pm
Tags: Generics
84 Views
no comments
 
C#
GenericSorter<surveystateformatdata> gs = new GenericSorter<surveystateformatdata >();
SurveyStateFormatItems = gs.Sort(SurveyStateFormatItems.AsQueryable, 
                                 sortExpression, sortDirection).ToArray();
by Athens Springer   October 29, 2009 @ 9:12am
Tags: C#, Generics
65 Views
no comments
 
C#
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)
    {
by Athens Springer   October 29, 2009 @ 9:11am
Tags: C#, Generics
73 Views
no comments
 
C#
/// <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). 
by Al Gonzalez   July 14, 2009 @ 4:31pm
80 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