Skip to content

Commit 90a4c87

Browse files
committed
чистка wrapped перечислений
1 parent 99e2ca3 commit 90a4c87

18 files changed

+100
-411
lines changed

src/OneScript.StandardLibrary/XMLSchema/Collections/XSComplexFinalUnion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class XSComplexFinalUnion : AutoContext<XSComplexFinalUnion>
2222

2323
private bool Contains(XmlSchemaDerivationMethod value)
2424
{
25-
XSComplexFinal enumValue = XSComplexFinal.FromNativeValue(value);
25+
var enumValue = EnumerationXSComplexFinal.FromNativeValue(value);
2626
IValue idx = _values.Find(enumValue);
2727
return idx.SystemType == BasicTypes.Number;
2828
}

src/OneScript.StandardLibrary/XMLSchema/Collections/XSProhibitedSubstitutionsUnion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class XsProhibitedSubstitutionsUnion : AutoContext<XsProhibitedSub
2222

2323
private bool Contains(XmlSchemaDerivationMethod value)
2424
{
25-
XSProhibitedSubstitutions enumValue = XSProhibitedSubstitutions.FromNativeValue(value);
25+
var enumValue = EnumerationXSProhibitedSubstitutions.FromNativeValue(value);
2626
IValue idx = _values.Find(enumValue);
2727
return (idx.SystemType != BasicTypes.Undefined);
2828
}

src/OneScript.StandardLibrary/XMLSchema/Collections/XSSubstitutionGroupExclusionsUnion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public sealed class XsSubstitutionGroupExclusionsUnion : AutoContext<XsSubstitut
2121
private readonly ArrayImpl _values;
2222
private bool Contains(XmlSchemaDerivationMethod value)
2323
{
24-
XSSubstitutionGroupExclusions enumValue = EnumerationXSSubstitutionGroupExclusions.FromNativeValue(value);
24+
var enumValue = EnumerationXSSubstitutionGroupExclusions.FromNativeValue(value);
2525
IValue idx = _values.Find(enumValue);
2626
return (idx.SystemType != BasicTypes.Undefined);
2727
}

src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,27 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8-
using System.Collections.Generic;
98
using System.Xml.Schema;
109
using OneScript.Contexts.Enums;
1110
using OneScript.Types;
12-
using ScriptEngine.Machine;
1311
using ScriptEngine.Machine.Contexts;
1412

1513
namespace OneScript.StandardLibrary.XMLSchema.Enumerations
1614
{
17-
public sealed class XSComplexFinal : EnumerationValue
18-
{
19-
private readonly XmlSchemaDerivationMethod _derivationMethod;
20-
public XSComplexFinal(EnumerationContext owner, XmlSchemaDerivationMethod derivationMethod)
21-
: base(owner) => _derivationMethod = derivationMethod;
22-
23-
public static XSComplexFinal FromNativeValue(XmlSchemaDerivationMethod native)
24-
=> EnumerationXSComplexFinal.FromNativeValue(native);
25-
26-
public static XmlSchemaDerivationMethod ToNativeValue(XSComplexFinal wrapper)
27-
=> wrapper._derivationMethod;
28-
}
29-
3015
[SystemEnum("ЗавершенностьСоставногоТипаXS", "XSComplexFinal")]
31-
public sealed class EnumerationXSComplexFinal : EnumerationContext
16+
public sealed class EnumerationXSComplexFinal : ClrEnumWrapperCached<XmlSchemaDerivationMethod>
3217
{
33-
private readonly Dictionary<XmlSchemaDerivationMethod, XSComplexFinal> _valuesCache;
34-
3518
private EnumerationXSComplexFinal(TypeDescriptor typeRepresentation, TypeDescriptor valuesType)
3619
: base(typeRepresentation, valuesType)
3720
{
38-
_valuesCache = new Dictionary<XmlSchemaDerivationMethod, XSComplexFinal>
39-
{
40-
{ XmlSchemaDerivationMethod.All, new XSComplexFinal(this, XmlSchemaDerivationMethod.All) },
41-
{ XmlSchemaDerivationMethod.Restriction, new XSComplexFinal(this, XmlSchemaDerivationMethod.Restriction) },
42-
{ XmlSchemaDerivationMethod.Extension, new XSComplexFinal(this, XmlSchemaDerivationMethod.Extension) }
43-
};
44-
}
45-
internal static XSComplexFinal FromNativeValue(XmlSchemaDerivationMethod native)
46-
{
47-
EnumerationXSComplexFinal enumeration = GlobalsHelper.GetEnum<EnumerationXSComplexFinal>();
48-
enumeration._valuesCache.TryGetValue(native, out XSComplexFinal value);
49-
return value;
21+
MakeValue("Все", "All", XmlSchemaDerivationMethod.All);
22+
MakeValue("Ограничение", "Restriction", XmlSchemaDerivationMethod.Restriction);
23+
MakeValue("Список", "List", XmlSchemaDerivationMethod.List);
5024
}
5125

5226
public static EnumerationXSComplexFinal CreateInstance(ITypeManager typeManager)
5327
{
54-
var type = typeManager.RegisterType(
55-
"ПеречислениеЗавершенностьСоставногоТипаXS",
56-
"EnumerationXSComplexFinal",
57-
typeof(EnumerationXSComplexFinal));
58-
59-
var enumValueType = typeManager.RegisterType(
60-
"ЗавершенностьСоставногоТипаXS",
61-
"XSComplexFinal",
62-
typeof(XSComplexFinal));
63-
64-
EnumerationXSComplexFinal instance = new EnumerationXSComplexFinal(type, enumValueType);
65-
instance.AddValue("Все", "All", new XSComplexFinal(instance, XmlSchemaDerivationMethod.All));
66-
instance.AddValue("Ограничение", "Restriction", new XSComplexFinal(instance, XmlSchemaDerivationMethod.Restriction));
67-
instance.AddValue("Расширение", "Extension", new XSComplexFinal(instance, XmlSchemaDerivationMethod.Extension));
68-
69-
return instance;
28+
return CreateInstance(typeManager, (t,v) => new EnumerationXSComplexFinal(t,v));
7029
}
7130
}
72-
7331
}

src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,86 +5,28 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8-
using System.Collections.Generic;
98
using System.Xml.Schema;
109
using OneScript.Contexts.Enums;
1110
using OneScript.Types;
12-
using ScriptEngine.Machine;
1311
using ScriptEngine.Machine.Contexts;
1412

1513
namespace OneScript.StandardLibrary.XMLSchema.Enumerations
1614
{
17-
public sealed class XSDisallowedSubstitutions : ClrEnumValueWrapper<XmlSchemaDerivationMethod>
18-
{
19-
internal XSDisallowedSubstitutions(EnumerationXSDisallowedSubstitutions instance, XmlSchemaDerivationMethod realValue)
20-
: base(instance, realValue)
21-
{
22-
}
23-
24-
public static XSDisallowedSubstitutions FromNativeValue(XmlSchemaDerivationMethod native)
25-
=> EnumerationXSDisallowedSubstitutions.FromNativeValue(native);
26-
27-
public static XmlSchemaDerivationMethod ToNativeValue(XSDisallowedSubstitutions wrapper)
28-
=> wrapper.UnderlyingValue;
29-
}
30-
3115
[SystemEnum("НедопустимыеПодстановкиXS", "XSDisallowedSubstitutions")]
32-
public sealed class EnumerationXSDisallowedSubstitutions : EnumerationContext
16+
public sealed class EnumerationXSDisallowedSubstitutions : ClrEnumWrapperCached<XmlSchemaDerivationMethod>
3317
{
34-
35-
private readonly Dictionary<XmlSchemaDerivationMethod, XSDisallowedSubstitutions> _valuesCache;
36-
3718
private EnumerationXSDisallowedSubstitutions(TypeDescriptor typeRepresentation, TypeDescriptor valuesType)
3819
: base(typeRepresentation, valuesType)
3920
{
40-
_valuesCache = new Dictionary<XmlSchemaDerivationMethod, XSDisallowedSubstitutions>
41-
{
42-
{ XmlSchemaDerivationMethod.All, new XSDisallowedSubstitutions(this, XmlSchemaDerivationMethod.All) },
43-
{ XmlSchemaDerivationMethod.Restriction, new XSDisallowedSubstitutions(this, XmlSchemaDerivationMethod.Restriction) },
44-
{ XmlSchemaDerivationMethod.Substitution, new XSDisallowedSubstitutions(this, XmlSchemaDerivationMethod.Substitution) },
45-
{ XmlSchemaDerivationMethod.Extension, new XSDisallowedSubstitutions(this, XmlSchemaDerivationMethod.Extension) }
46-
};
47-
}
48-
49-
internal static XSDisallowedSubstitutions FromNativeValue(XmlSchemaDerivationMethod native)
50-
{
51-
52-
switch (native)
53-
{
54-
case XmlSchemaDerivationMethod.All:
55-
case XmlSchemaDerivationMethod.Restriction:
56-
case XmlSchemaDerivationMethod.Substitution:
57-
case XmlSchemaDerivationMethod.Extension:
58-
59-
EnumerationXSDisallowedSubstitutions enumeration = GlobalsHelper.GetEnum<EnumerationXSDisallowedSubstitutions>();
60-
return enumeration._valuesCache[native];
61-
62-
default:
63-
return null;
64-
}
21+
MakeValue("Все", "All", XmlSchemaDerivationMethod.All);
22+
MakeValue("Ограничение", "Restriction", XmlSchemaDerivationMethod.Restriction);
23+
MakeValue("Подстановка", "Substitution", XmlSchemaDerivationMethod.Substitution);
24+
MakeValue("Расширение", "Extension", XmlSchemaDerivationMethod.Extension);
6525
}
6626

6727
public static EnumerationXSDisallowedSubstitutions CreateInstance(ITypeManager typeManager)
6828
{
69-
70-
var type = typeManager.RegisterType(
71-
"ПеречислениеНедопустимыеПодстановкиXS",
72-
"EnumerationXSDisallowedSubstitutions",
73-
typeof(EnumerationXSDisallowedSubstitutions));
74-
75-
var enumValueType = typeManager.RegisterType(
76-
"НедопустимыеПодстановкиXS",
77-
"XSDisallowedSubstitutions",
78-
typeof(XSDisallowedSubstitutions));
79-
80-
EnumerationXSDisallowedSubstitutions instance = new EnumerationXSDisallowedSubstitutions(type, enumValueType);
81-
82-
instance.AddValue("Все", "All", instance._valuesCache[XmlSchemaDerivationMethod.All]);
83-
instance.AddValue("Ограничение", "Restriction", instance._valuesCache[XmlSchemaDerivationMethod.Restriction]);
84-
instance.AddValue("Подстановка", "Substitution", instance._valuesCache[XmlSchemaDerivationMethod.Substitution]);
85-
instance.AddValue("Расширение", "Extension", instance._valuesCache[XmlSchemaDerivationMethod.Extension]);
86-
87-
return instance;
29+
return CreateInstance(typeManager, (t,v) => new EnumerationXSDisallowedSubstitutions(t, v));
8830
}
8931
}
9032
}

src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSForm.cs

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,27 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8-
using System.Collections.Generic;
98
using System.Xml.Schema;
109
using OneScript.Contexts.Enums;
1110
using OneScript.Types;
12-
using ScriptEngine.Machine;
1311
using ScriptEngine.Machine.Contexts;
1412

13+
1514
namespace OneScript.StandardLibrary.XMLSchema.Enumerations
1615
{
17-
public sealed class XSForm : ClrEnumValueWrapper<XmlSchemaForm>
18-
{
19-
internal XSForm(EnumerationXSForm instance, XmlSchemaForm realValue) : base(instance, realValue )
20-
{
21-
}
22-
23-
public static XSForm FromNativeValue(XmlSchemaForm native) => EnumerationXSForm.FromNativeValue(native);
24-
25-
public static XmlSchemaForm ToNativeValue(XSForm wrapper) => wrapper.UnderlyingValue;
26-
}
27-
2816
[SystemEnum("ФормаПредставленияXS", "XSForm")]
29-
public sealed class EnumerationXSForm : EnumerationContext
17+
public sealed class EnumerationXSForm : ClrEnumWrapperCached<XmlSchemaForm>
3018
{
31-
private readonly Dictionary<XmlSchemaForm, XSForm> _valuesCache;
32-
3319
private EnumerationXSForm(TypeDescriptor typeRepresentation, TypeDescriptor valuesType)
3420
: base(typeRepresentation, valuesType)
3521
{
36-
_valuesCache = new Dictionary<XmlSchemaForm, XSForm>
37-
{
38-
{ XmlSchemaForm.Qualified, new XSForm(this, XmlSchemaForm.Qualified) },
39-
{ XmlSchemaForm.Unqualified, new XSForm(this, XmlSchemaForm.Unqualified) }
40-
};
41-
}
42-
43-
internal static XSForm FromNativeValue(XmlSchemaForm native)
44-
{
45-
switch (native)
46-
{
47-
case XmlSchemaForm.Qualified:
48-
case XmlSchemaForm.Unqualified:
49-
50-
EnumerationXSForm enumeration = GlobalsHelper.GetEnum<EnumerationXSForm>();
51-
return enumeration._valuesCache[native];
52-
53-
default:
54-
return null;
55-
}
22+
MakeValue("Квалифицированная", "Qualified", XmlSchemaForm.Qualified);
23+
MakeValue("Неквалифицированная", "Unqualified", XmlSchemaForm.Unqualified);
5624
}
5725

5826
public static EnumerationXSForm CreateInstance(ITypeManager typeManager)
5927
{
60-
61-
var type = typeManager.RegisterType(
62-
"ПеречислениеФормаПредставленияXS",
63-
"EnumerationXSForm", typeof(EnumerationXSForm));
64-
65-
var enumValueType = typeManager.RegisterType(
66-
"ФормаПредставленияXS",
67-
"XSForm", typeof(XSForm));
68-
69-
EnumerationXSForm instance = new EnumerationXSForm(type, enumValueType);
70-
71-
instance.AddValue("Квалифицированная", "Qualified", instance._valuesCache[XmlSchemaForm.Qualified]);
72-
instance.AddValue("Неквалифицированная", "Unqualified", instance._valuesCache[XmlSchemaForm.Unqualified]);
73-
74-
return instance;
28+
return CreateInstance(typeManager, (t,v) => new EnumerationXSForm(t,v));
7529
}
7630
}
7731
}

src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,27 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8-
using System.Collections.Generic;
98
using System.Xml.Schema;
109
using OneScript.Contexts.Enums;
1110
using OneScript.Types;
12-
using ScriptEngine.Machine;
1311
using ScriptEngine.Machine.Contexts;
1412

1513
namespace OneScript.StandardLibrary.XMLSchema.Enumerations
1614
{
17-
public sealed class XSProhibitedSubstitutions : ClrEnumValueWrapper<XmlSchemaDerivationMethod>
15+
[SystemEnum("ЗапрещенныеПодстановкиXS", "XSProhibitedSubstitutions")]
16+
public sealed class EnumerationXSProhibitedSubstitutions : ClrEnumWrapperCached<XmlSchemaDerivationMethod>
1817
{
19-
internal XSProhibitedSubstitutions(EnumerationXSProhibitedSubstitutions instance, XmlSchemaDerivationMethod realValue)
20-
: base(instance, realValue)
21-
{
22-
}
23-
24-
public static XSProhibitedSubstitutions FromNativeValue(XmlSchemaDerivationMethod native)
25-
=> EnumerationXSProhibitedSubstitutions.FromNativeValue(native);
26-
27-
public static XmlSchemaDerivationMethod ToNativeValue(XSProhibitedSubstitutions wrapper)
28-
=> wrapper.UnderlyingValue;
29-
}
30-
31-
[SystemEnum("ЗапрещенныеПодстановкиXS", "EnumerationXSProhibitedSubstitutions")]
32-
public sealed class EnumerationXSProhibitedSubstitutions : EnumerationContext
33-
{
34-
35-
private readonly Dictionary<XmlSchemaDerivationMethod, XSProhibitedSubstitutions> _valuesCache;
36-
3718
private EnumerationXSProhibitedSubstitutions(TypeDescriptor typeRepresentation, TypeDescriptor valuesType)
3819
: base(typeRepresentation, valuesType)
3920
{
40-
_valuesCache = new Dictionary<XmlSchemaDerivationMethod, XSProhibitedSubstitutions>
41-
{
42-
{ XmlSchemaDerivationMethod.All, new XSProhibitedSubstitutions(this, XmlSchemaDerivationMethod.All) },
43-
{ XmlSchemaDerivationMethod.Restriction, new XSProhibitedSubstitutions(this, XmlSchemaDerivationMethod.Restriction) },
44-
{ XmlSchemaDerivationMethod.Extension, new XSProhibitedSubstitutions(this, XmlSchemaDerivationMethod.Extension) }
45-
};
46-
}
47-
48-
internal static XSProhibitedSubstitutions FromNativeValue(XmlSchemaDerivationMethod native)
49-
{
50-
51-
switch (native)
52-
{
53-
case XmlSchemaDerivationMethod.All:
54-
case XmlSchemaDerivationMethod.Restriction:
55-
case XmlSchemaDerivationMethod.Extension:
56-
57-
EnumerationXSProhibitedSubstitutions enumeration = GlobalsHelper.GetEnum<EnumerationXSProhibitedSubstitutions>();
58-
return enumeration._valuesCache[native];
59-
60-
default:
61-
return null;
62-
}
21+
MakeValue("Все", "All", XmlSchemaDerivationMethod.All);
22+
MakeValue("Ограничение", "Restriction", XmlSchemaDerivationMethod.Restriction);
23+
MakeValue("Расширение", "Extension", XmlSchemaDerivationMethod.Extension);
6324
}
6425

6526
public static EnumerationXSProhibitedSubstitutions CreateInstance(ITypeManager typeManager)
6627
{
67-
var instance = EnumContextHelper.CreateClrEnumInstance<EnumerationXSProhibitedSubstitutions, XmlSchemaDerivationMethod>(
68-
typeManager,
69-
(t,v) => new EnumerationXSProhibitedSubstitutions(t, v));
70-
71-
instance.AddValue("Все", "All", instance._valuesCache[XmlSchemaDerivationMethod.All]);
72-
instance.AddValue("Ограничение", "Restriction", instance._valuesCache[XmlSchemaDerivationMethod.Restriction]);
73-
instance.AddValue("Расширение", "Extension", instance._valuesCache[XmlSchemaDerivationMethod.Extension]);
74-
75-
return instance;
28+
return CreateInstance(typeManager, (t, v) => new EnumerationXSProhibitedSubstitutions(t, v));
7629
}
7730
}
7831
}

0 commit comments

Comments
 (0)