Format:
Recent snippets matching tags of generics
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
14 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);
28 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
63 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; }
35 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>();
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
134 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) { }
84 Views
no comments
GenericSorter<surveystateformatdata> gs = new GenericSorter<surveystateformatdata >();
SurveyStateFormatItems = gs.Sort(SurveyStateFormatItems.AsQueryable,
sortExpression, sortDirection).ToArray();
65 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) {
73 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).
80 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
