1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.Data.Linq;
|
---|
23 | using HeuristicLab.Services.Authentication.DataTransfer;
|
---|
24 | using DA = HeuristicLab.Services.Authentication.DataAccess;
|
---|
25 | using DT = HeuristicLab.Services.Authentication.DataTransfer;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Services.Authentication
|
---|
28 | {
|
---|
29 | public static class Convert
|
---|
30 | {
|
---|
31 |
|
---|
32 | #region Client
|
---|
33 | public static DT.Client ToDto(DA.Client source)
|
---|
34 | {
|
---|
35 | if (source == null) return null;
|
---|
36 | return new DT.Client
|
---|
37 | {
|
---|
38 | Id = source.Id,
|
---|
39 | Name = source.Name,
|
---|
40 | Description = source.Description,
|
---|
41 | ResourceType = source.ResourceType,
|
---|
42 | ProcessorType = source.ProcessorType,
|
---|
43 | NumberOfProcessors = source.NumberOfProcessors,
|
---|
44 | NumberOfThreads = source.NumberOfThreads,
|
---|
45 | IPAdress = source.IPAdress,
|
---|
46 | MemorySize = source.MemorySize,
|
---|
47 | OperatingSystem = source.OperatingSystem
|
---|
48 | };
|
---|
49 | }
|
---|
50 |
|
---|
51 | public static DA.Client ToEntity(DT.Client source)
|
---|
52 | {
|
---|
53 | if (source == null) return null;
|
---|
54 | return new DA.Client
|
---|
55 | {
|
---|
56 | Id = source.Id,
|
---|
57 | Name = source.Name,
|
---|
58 | Description = source.Description,
|
---|
59 | ResourceType = source.ResourceType,
|
---|
60 | ProcessorType = source.ProcessorType,
|
---|
61 | NumberOfProcessors = source.NumberOfProcessors,
|
---|
62 | NumberOfThreads = source.NumberOfThreads,
|
---|
63 | IPAdress = source.IPAdress,
|
---|
64 | MemorySize = source.MemorySize,
|
---|
65 | OperatingSystem = source.OperatingSystem
|
---|
66 | };
|
---|
67 | }
|
---|
68 |
|
---|
69 | public static DA.Resource ToEntity(DT.Resource source)
|
---|
70 | {
|
---|
71 | if (source == null) return null;
|
---|
72 | if (source is DT.Client)
|
---|
73 | {
|
---|
74 | DT.Client client = (Client) source;
|
---|
75 | return ToEntity(client);
|
---|
76 | }
|
---|
77 | if (source is DT.ResourceGroup)
|
---|
78 | {
|
---|
79 | DT.ResourceGroup resourceGroup = (ResourceGroup) source;
|
---|
80 | return ToEntity(resourceGroup);
|
---|
81 | }
|
---|
82 | return null;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public static void ToEntity(DT.Client source, DA.Client target)
|
---|
86 | {
|
---|
87 | if ((source != null) && (target != null))
|
---|
88 | {
|
---|
89 | target.Id = source.Id;
|
---|
90 | target.Name = source.Name;
|
---|
91 | target.Description = source.Description;
|
---|
92 | target.ResourceType = source.ResourceType;
|
---|
93 | target.ProcessorType = source.ProcessorType;
|
---|
94 | target.NumberOfProcessors = source.NumberOfProcessors;
|
---|
95 | target.NumberOfThreads = source.NumberOfThreads;
|
---|
96 | target.IPAdress = source.IPAdress;
|
---|
97 | target.MemorySize = source.MemorySize;
|
---|
98 | target.OperatingSystem = source.OperatingSystem;
|
---|
99 | }
|
---|
100 | }
|
---|
101 | #endregion // Client
|
---|
102 |
|
---|
103 | #region ResourceGroup
|
---|
104 | public static DT.ResourceGroup ToDto(DA.ResourceGroup source)
|
---|
105 | {
|
---|
106 | if (source == null) return null;
|
---|
107 | return new DT.ResourceGroup
|
---|
108 | {
|
---|
109 | Id = source.Id,
|
---|
110 | Name = source.Name,
|
---|
111 | Description = source.Description,
|
---|
112 | ResourceType = source.ResourceType,
|
---|
113 | };
|
---|
114 | }
|
---|
115 |
|
---|
116 | public static DA.ResourceGroup ToEntity(DT.ResourceGroup source)
|
---|
117 | {
|
---|
118 | if (source == null) return null;
|
---|
119 | return new DA.ResourceGroup
|
---|
120 | {
|
---|
121 | Id = source.Id,
|
---|
122 | Name = source.Name,
|
---|
123 | Description = source.Description,
|
---|
124 | ResourceType = source.ResourceType,
|
---|
125 | };
|
---|
126 | }
|
---|
127 |
|
---|
128 | public static void ToEntity(DT.ResourceGroup source, DA.ResourceGroup target)
|
---|
129 | {
|
---|
130 | if ((source != null) && (target != null))
|
---|
131 | {
|
---|
132 | target.Id = source.Id;
|
---|
133 | target.Name = source.Name;
|
---|
134 | target.Description = source.Description;
|
---|
135 | target.ResourceType = source.ResourceType;
|
---|
136 | }
|
---|
137 | }
|
---|
138 | #endregion // ResourceGroup
|
---|
139 | }
|
---|
140 | } |
---|