diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs index eb2d2d115..587179ac3 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("ЗавершенностьСоставногоТипаXS", "XSComplexFinal")] - public sealed class EnumerationXSComplexFinal : ClrEnumWrapperCached + public sealed class EnumerationXSComplexFinal : ClrEnumWrapperCached { private EnumerationXSComplexFinal(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs index db80ce228..e50e313b7 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("НедопустимыеПодстановкиXS", "XSDisallowedSubstitutions")] - public sealed class EnumerationXSDisallowedSubstitutions : ClrEnumWrapperCached + public sealed class EnumerationXSDisallowedSubstitutions : ClrEnumWrapperCached { private EnumerationXSDisallowedSubstitutions(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs index a1e8aca1a..1ce81f277 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("ЗапрещенныеПодстановкиXS", "XSProhibitedSubstitutions")] - public sealed class EnumerationXSProhibitedSubstitutions : ClrEnumWrapperCached + public sealed class EnumerationXSProhibitedSubstitutions : ClrEnumWrapperCached { private EnumerationXSProhibitedSubstitutions(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs index 1490c287b..eaac8b49b 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("ЗавершенностьСхемыXS", "XSSchemaFinal")] - public sealed class EnumerationXSSchemaFinal : ClrEnumWrapperCached + public sealed class EnumerationXSSchemaFinal : ClrEnumWrapperCached { private EnumerationXSSchemaFinal(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs index 09230581b..7ddb91eda 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("ЗавершенностьПростогоТипаXS", "XSSimpleFinal")] - public sealed class EnumerationXSSimpleFinal : ClrEnumWrapperCached + public sealed class EnumerationXSSimpleFinal : ClrEnumWrapperCached { private EnumerationXSSimpleFinal(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs index e84d04226..4dbbd7548 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { [SystemEnum("ИсключенияГруппПодстановкиXS", "XSSubstitutionGroupExclusions")] - public sealed class EnumerationXSSubstitutionGroupExclusions : ClrEnumWrapperCached + public sealed class EnumerationXSSubstitutionGroupExclusions : ClrEnumWrapperCached { private EnumerationXSSubstitutionGroupExclusions(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) diff --git a/src/ScriptEngine/Machine/Contexts/ClrEnumWrapper.cs b/src/ScriptEngine/Machine/Contexts/ClrEnumWrapper.cs index 19143699a..43479f7ac 100644 --- a/src/ScriptEngine/Machine/Contexts/ClrEnumWrapper.cs +++ b/src/ScriptEngine/Machine/Contexts/ClrEnumWrapper.cs @@ -130,12 +130,26 @@ protected static TE CreateInstance(ITypeManager typeManager,EnumCreationDele } } - public abstract class ClrEnumWrapperCached : ClrEnumWrapper where T : struct + public abstract class ClrEnumWrapperCached : ClrEnumWrapperCached, T> where T : struct + { + protected ClrEnumWrapperCached(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) + : base(typeRepresentation, valuesType) + { + } + } + + /// + /// Кэш значений свой у каждого перечисления TSelf: несколько перечислений могут оборачивать + /// одно перечисление Clr (например, XmlSchemaDerivationMethod), и общий кэш по T путал бы их значения + /// + public abstract class ClrEnumWrapperCached : ClrEnumWrapper + where T : struct + where TSelf : ClrEnumWrapperCached { private static readonly Dictionary> _valuesCache = new Dictionary>(); - protected ClrEnumWrapperCached(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) + protected ClrEnumWrapperCached(TypeDescriptor typeRepresentation, TypeDescriptor valuesType) : base(typeRepresentation, valuesType) { _valuesCache.Clear(); diff --git a/tests/XMLSchema/test-XMLSchema.os b/tests/XMLSchema/test-XMLSchema.os index 904fef56e..3efdd5946 100644 --- a/tests/XMLSchema/test-XMLSchema.os +++ b/tests/XMLSchema/test-XMLSchema.os @@ -12,6 +12,8 @@ СписокТестов.Добавить("ТестУстановитьПространствоИмен"); СписокТестов.Добавить("ТестФормаАтрибутовПоУмолчанию"); СписокТестов.Добавить("ТестФормаЭлементовПоУмолчанию"); + СписокТестов.Добавить("ТестЗавершенностьПоУмолчанию"); + СписокТестов.Добавить("ТестБлокировкаПоУмолчанию"); СписокТестов.Добавить("ТестОписаниеЭлемента"); СписокТестов.Добавить("ТестОпределениеПростогоТипа"); СписокТестов.Добавить("ТестОпределениеСоставногоТипа"); @@ -112,6 +114,28 @@ EndProcedure КонецПроцедуры +Процедура ТестЗавершенностьПоУмолчанию() Экспорт + + СхемаXML = Новый СхемаXML; + + СхемаXML.ЗавершенностьПоУмолчанию.Значения().Добавить(ЗавершенностьСхемыXS.Ограничение); + + ЮнитТест.ПроверитьИстину(СхемаXML.ЗавершенностьПоУмолчанию.Ограничение); + ЮнитТест.ПроверитьЛожь(СхемаXML.ЗавершенностьПоУмолчанию.Расширение); + +КонецПроцедуры + +Процедура ТестБлокировкаПоУмолчанию() Экспорт + + СхемаXML = Новый СхемаXML; + + СхемаXML.БлокировкаПоУмолчанию.Значения().Добавить(НедопустимыеПодстановкиXS.Ограничение); + + ЮнитТест.ПроверитьИстину(СхемаXML.БлокировкаПоУмолчанию.Ограничение); + ЮнитТест.ПроверитьЛожь(СхемаXML.БлокировкаПоУмолчанию.Расширение); + +КонецПроцедуры + Процедура ТестОписаниеЭлемента() Экспорт СхемаXML = Новый СхемаXML;