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

Annotation of /trunk/RomCheater/ObjectBinder.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 313 - (hide annotations) (download)
Tue Jun 5 15:03:03 2012 UTC (8 years, 11 months ago) by william
File size: 1256 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     public class ObjectBinder
12     {
13     /// <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     /// <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