Last change
on this file since 17280 was
17280,
checked in by dpiringe, 5 years ago
|
#3026
- renamed CustomWriter to CustomJsonWriter and extracted it into a separate file
- removed property ParameterizedItems from Component
- added helper methods for path generation in Component
- reverted the single parameter array idea back to the FreeParameters and StaticParameters idea
- now there hidden parameters are also handled
|
File size:
800 bytes
|
Rev | Line | |
---|
[17263] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Threading.Tasks;
|
---|
| 6 | using HeuristicLab.Core;
|
---|
| 7 | using HeuristicLab.Data;
|
---|
| 8 |
|
---|
[17266] | 9 | namespace HeuristicLab.Manufacture {
|
---|
[17263] | 10 | public class EnumTypeTransformer : BaseTransformer {
|
---|
[17271] | 11 | public override void InjectData(IItem item, Component data) =>
|
---|
[17266] | 12 | item.Cast<dynamic>().Value = Enum.Parse(
|
---|
| 13 | item.GetType().GenericTypeArguments.First(),
|
---|
| 14 | CastValue<string>(data.Default));
|
---|
[17263] | 15 |
|
---|
[17271] | 16 | public override Component ExtractData(IItem value) {
|
---|
| 17 | Component data = new Component();
|
---|
[17263] | 18 | object val = ((dynamic)value).Value;
|
---|
| 19 | Type enumType = val.GetType();
|
---|
| 20 | data.Default = Enum.GetName(enumType, val);
|
---|
| 21 | data.Range = Enum.GetNames(enumType);
|
---|
| 22 | return data;
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.