コード例 #1
0
ファイル: Mapper.cs プロジェクト: farazxameer/Assignments
 ///<summary>
 ///This method will map the source parameter to the TDestination object.
 ///</summary>
 public static TDestination Map <TSource, TDestination>(TSource source)
 {
     if (IsMapped <TSource, TDestination>())
     {
         int index = GetIndex <TSource, TDestination>();
         InstanceMapper <TSource, TDestination> obj = (InstanceMapper <TSource, TDestination>)objects[index];
         TDestination destination = obj.Map(source);
         return(destination);
     }
     else
     {
         Console.WriteLine("No Map Exists !!!");
         return(default(TDestination));
     }
 }
コード例 #2
0
ファイル: Mapper.cs プロジェクト: farazxameer/Assignments
 ///<summary>
 ///This method will create a Map with the custom configuration.
 ///</summary>
 public static void Config <TSource, TDestination>(Dictionary <string, string> customMap)
 {
     if (!IsMapped <TSource, TDestination>())
     {
         NewMap <TSource, TDestination>();
         int index = GetIndex <TSource, TDestination>();
         InstanceMapper <TSource, TDestination> obj = (InstanceMapper <TSource, TDestination>)objects[index];
         obj.CustomMap(customMap);
     }
     else
     {
         int index = GetIndex <TSource, TDestination>();
         InstanceMapper <TSource, TDestination> obj = (InstanceMapper <TSource, TDestination>)objects[index];
         obj.CustomMap(customMap);
     }
 }