Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/24/10 06:53:43 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB/HeuristicLab.Services.OKB/3.3/Convert.cs

    r4467 r4481  
    2828    #region Platform
    2929    public static DT.Platform ToDto(DA.Platform source) {
     30      if (source == null) return null;
    3031      return new DT.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
    3132    }
    3233    public static DA.Platform ToEntity(DT.Platform source) {
     34      if (source == null) return null;
    3335      return new DA.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
    3436    }
    3537    public static void ToEntity(DT.Platform source, DA.Platform target) {
    36       target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
     38      if ((source != null) && (target != null))
     39        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
     40    }
     41    #endregion
     42
     43    #region DataType
     44    public static DT.DataType ToDto(DA.DataType source) {
     45      if (source == null) return null;
     46      return new DT.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
     47    }
     48    public static DA.DataType ToEntity(DT.DataType source) {
     49      if (source == null) return null;
     50      return new DA.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
     51    }
     52    public static void ToEntity(DT.DataType source, DA.DataType target) {
     53      if ((source != null) && (target != null))
     54        target.Id = source.Id; target.Name = source.Name; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId;
    3755    }
    3856    #endregion
     
    4058    #region AlgorithmClass
    4159    public static DT.AlgorithmClass ToDto(DA.AlgorithmClass source) {
     60      if (source == null) return null;
    4261      return new DT.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
    4362    }
    4463    public static DA.AlgorithmClass ToEntity(DT.AlgorithmClass source) {
     64      if (source == null) return null;
    4565      return new DA.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
    4666    }
    4767    public static void ToEntity(DT.AlgorithmClass source, DA.AlgorithmClass target) {
    48       target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
     68      if ((source != null) && (target != null))
     69        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
    4970    }
    5071    #endregion
     
    5273    #region Algorithm
    5374    public static DT.Algorithm ToDto(DA.Algorithm source) {
     75      if (source == null) return null;
    5476      return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };
    5577    }
    5678    public static DA.Algorithm ToEntity(DT.Algorithm source) {
     79      if (source == null) return null;
    5780      return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };
    5881    }
    5982    public static void ToEntity(DT.Algorithm source, DA.Algorithm target) {
    60       target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId;
     83      if ((source != null) && (target != null))
     84        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId;
    6185    }
    6286    #endregion
     
    6488    #region AlgorithmData
    6589    public static DT.AlgorithmData ToDto(DA.AlgorithmData source) {
     90      if (source == null) return null;
    6691      return new DT.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() };
    6792    }
    6893    public static DA.AlgorithmData ToEntity(DT.AlgorithmData source) {
     94      if (source == null) return null;
    6995      return new DA.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) };
    7096    }
    7197    public static void ToEntity(DT.AlgorithmData source, DA.AlgorithmData target) {
    72       target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data);
     98      if ((source != null) && (target != null))
     99        target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data);
    73100    }
    74101    #endregion
    75102
    76     #region DataType
    77     public static DT.DataType ToDto(DA.DataType source) {
    78       return new DT.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
     103    #region ProblemClass
     104    public static DT.ProblemClass ToDto(DA.ProblemClass source) {
     105      if (source == null) return null;
     106      return new DT.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
    79107    }
    80     public static DA.DataType ToEntity(DT.DataType source) {
    81       return new DA.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
     108    public static DA.ProblemClass ToEntity(DT.ProblemClass source) {
     109      if (source == null) return null;
     110      return new DA.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
    82111    }
    83     public static void ToEntity(DT.DataType source, DA.DataType target) {
    84       target.Id = source.Id; target.Name = source.Name; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId;
     112    public static void ToEntity(DT.ProblemClass source, DA.ProblemClass target) {
     113      if ((source != null) && (target != null))
     114        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
     115    }
     116    #endregion
     117
     118    #region Algorithm
     119    public static DT.Problem ToDto(DA.Problem source) {
     120      if (source == null) return null;
     121      return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };
     122    }
     123    public static DA.Problem ToEntity(DT.Problem source) {
     124      if (source == null) return null;
     125      return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };
     126    }
     127    public static void ToEntity(DT.Problem source, DA.Problem target) {
     128      if ((source != null) && (target != null))
     129        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId;
     130    }
     131    #endregion
     132
     133    #region ProblemData
     134    public static DT.ProblemData ToDto(DA.ProblemData source) {
     135      if (source == null) return null;
     136      return new DT.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() };
     137    }
     138    public static DA.ProblemData ToEntity(DT.ProblemData source) {
     139      if (source == null) return null;
     140      return new DA.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) };
     141    }
     142    public static void ToEntity(DT.ProblemData source, DA.ProblemData target) {
     143      if ((source != null) && (target != null))
     144        target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data);
    85145    }
    86146    #endregion
Note: See TracChangeset for help on using the changeset viewer.