Пример #1
0
 private T DataTableToObject <T>(DataTable result) where T : class
 {
     if (result == null || result.Rows.Count < 1)
     {
         return(null);
     }
     if (typeof(T) == typeof(ApiKey))
     {
         return(ApiKey.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(UserMaster))
     {
         return(UserMaster.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(Permission))
     {
         return(Permission.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(UrlLock))
     {
         return(UrlLock.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(Container))
     {
         return(Container.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ObjectMetadata))
     {
         return(ObjectMetadata.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ContainerKeyValuePair))
     {
         return(ContainerKeyValuePair.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ObjectKeyValuePair))
     {
         return(ObjectKeyValuePair.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(AuditLogEntry))
     {
         return(AuditLogEntry.FromDataRow(result.Rows[0]) as T);
     }
     throw new ArgumentException("Unknown object type: " + typeof(T).Name);
 }