/[RomCheater]/trunk/RomCheater/TypeBinder.cs
ViewVC logotype

Annotation of /trunk/RomCheater/TypeBinder.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 315 - (hide annotations) (download)
Tue Jun 5 15:24:43 2012 UTC (8 years, 4 months ago) by william
File size: 1268 byte(s)

1 william 313 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5    
6     namespace RomCheater
7     {
8     /// <summary>
9     /// A class that allows the binding of an object to another type
10     /// </summary>
11 william 315 public class TypeBinder
12 william 313 {
13 william 314 ///// <summary>
14     ///// Binds an object to a specific type
15     ///// </summary>
16     ///// <typeparam name="T">The destination object type</typeparam>
17     ///// <param name="source">The source object type (object)</param>
18     ///// <returns>A bound type</returns>
19     //public static void Bind<T>(object source, out T destination) where T : class { Bind<object, T>(source, out destination); }
20 william 313 /// <summary>
21     /// Bind an object of a specific type to another specific type
22     /// </summary>
23     /// <typeparam name="S">The source object type</typeparam>
24     /// <typeparam name="T">The destination object type</typeparam>
25     /// <param name="source">An instance of the source type</param>
26     /// <returns>A bound typ</returns>
27     public static void Bind<S, T>(S source, out T destination) where T : class { destination= (source as T) == null ? (T)Convert.ChangeType(source, typeof(T)) : (source as T); }
28     }
29     }

  ViewVC Help
Powered by ViewVC 1.1.22