diff --git a/Build_Core.csproj b/Build_Core.csproj index b9ecbae63..94e4a1c82 100644 --- a/Build_Core.csproj +++ b/Build_Core.csproj @@ -69,7 +69,7 @@ ItemName="BuildVariant"/> - + $(MSBuildProjectDirectory)/src/ScriptEngine.NativeApi/bin/$(Configuration) @@ -105,9 +105,9 @@ - + - + $(MSBuildProjectDirectory)/src/ScriptEngine.NativeApi/bin/$(Configuration) @@ -181,8 +181,8 @@ - - + + @@ -204,7 +204,8 @@ + Condition="'$(SkipLibraryDownload)' == ''" + UseUtf8Encoding="Always"/> @@ -256,6 +257,7 @@ WorkingDirectory="$(TestsRoot)/%(TestAssemblies.Identity)" Command="dotnet test --logger:"junit;LogFilePath=$(MSBuildProjectDirectory)/tests/%(TestAssemblies.Identity).xml"" IgnoreExitCode="true" + UseUtf8Encoding="Always" /> @@ -276,7 +278,8 @@ WorkingDirectory="$(MSBuildProjectDirectory)\tests" Command="dotnet "$(Runner)" "$(MSBuildProjectDirectory)\tests\testrunner.os" -runall . xddReportPath ." IgnoreExitCode="true" - ContinueOnError="true"> + ContinueOnError="true" + UseUtf8Encoding="Always"> @@ -307,7 +310,7 @@ - + @@ -346,7 +349,7 @@ + Command="dotnet nuget push %(NugetAbleProject.Identity).$(ReleaseNumber).nupkg -k $(NugetToken) -s https://api.nuget.org/v3/index.json" UseUtf8Encoding="Always"/> diff --git a/src/OneScript.StandardLibrary/XDTO/XDTOSerializer.cs b/src/OneScript.StandardLibrary/XDTO/XDTOSerializer.cs index 33aa18c94..9655f91ac 100644 --- a/src/OneScript.StandardLibrary/XDTO/XDTOSerializer.cs +++ b/src/OneScript.StandardLibrary/XDTO/XDTOSerializer.cs @@ -20,7 +20,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XDTO { [ContextClass("СериализаторXDTO", "XDTOSerializer")] - public class XDTOSerializer : AutoContext + public sealed class XDTOSerializer : AutoContext { private readonly ITypeManager _typeManager; private readonly XmlGlobalFunctions _xmlGlobalFunctions; @@ -223,7 +223,7 @@ public IValue ReadXML(XmlReaderImpl xmlReader, IValue valueType = null) } else if (xsiNil.SystemType == BasicTypes.String) typeValue = new BslTypeValue(BasicTypes.Undefined); - }; + } if (typeValue == null) throw RuntimeException.InvalidArgumentValue(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XMLSchemaSet.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XMLSchemaSet.cs index a29120f03..78a55450f 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XMLSchemaSet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XMLSchemaSet.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("НаборСхемXML", "XMLSchemaSet")] - public class XMLSchemaSet : AutoCollectionContext + public sealed class XMLSchemaSet : AutoCollectionContext { private readonly XmlSchemaSet _schemaSet; private readonly List _items; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComplexFinalUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComplexFinalUnion.cs index 15a1fe5cf..3ca016b24 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComplexFinalUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComplexFinalUnion.cs @@ -16,7 +16,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеЗавершенностиСоставногоТипаXS", "XSComplexFinalUnion")] - public class XSComplexFinalUnion : AutoContext + public sealed class XSComplexFinalUnion : AutoContext { private readonly ArrayImpl _values; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentFixedList.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentFixedList.cs index 183332a63..962311a1a 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentFixedList.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentFixedList.cs @@ -14,13 +14,15 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ФиксированныйСписокКомпонентXS", "XSComponentFixedList")] - public class XSComponentFixedList : AutoCollectionContext + public sealed class XSComponentFixedList : AutoCollectionContext { private readonly List _items; public XSComponentFixedList() => _items = new List(); + public static XSComponentFixedList EmptyList() => new XSComponentFixedList(); + public void Add(IXSComponent value) => _items.Add(value); public void Remove(IXSComponent value) => _items.Remove(value); public void Clear() => _items.Clear(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentList.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentList.cs index 672f94f97..6041a6f8b 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentList.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSComponentList.cs @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("СписокКомпонентXS", "XSComponentList")] - public class XSComponentList : AutoCollectionContext + public sealed class XSComponentList : AutoCollectionContext { private readonly List _items; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSDisallowedSubstitutionsUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSDisallowedSubstitutionsUnion.cs index 2e7605838..a663f4538 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSDisallowedSubstitutionsUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSDisallowedSubstitutionsUnion.cs @@ -10,20 +10,19 @@ This Source Code Form is subject to the terms of the using OneScript.StandardLibrary.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.Types; -using ScriptEngine.Machine; using ScriptEngine.Machine.Contexts; namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеНедопустимыхПодстановкиXS", "XSDisallowedSubstitutionsUnion")] - public class XsDisallowedSubstitutionsUnion : AutoContext + public sealed class XsDisallowedSubstitutionsUnion : AutoContext { - private ArrayImpl _values; + private readonly ArrayImpl _values; private bool Contains(XmlSchemaDerivationMethod value) { - XSDisallowedSubstitutions enumValue = EnumerationXSDisallowedSubstitutions.FromNativeValue(value); - IValue idx = _values.Find(enumValue); + var enumValue = EnumerationXSDisallowedSubstitutions.FromNativeValue(value); + var idx = _values.Find(enumValue); return (idx.SystemType != BasicTypes.Undefined); } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSNamedComponentMap.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSNamedComponentMap.cs index 99739deb7..49e1ff972 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSNamedComponentMap.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSNamedComponentMap.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("КоллекцияИменованныхКомпонентXS", "XSNamedComponentMap")] - public class XSNamedComponentMap : AutoCollectionContext + public sealed class XSNamedComponentMap : AutoCollectionContext { private readonly List _items; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSProhibitedSubstitutionsUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSProhibitedSubstitutionsUnion.cs index 9763acb30..04e19508b 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSProhibitedSubstitutionsUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSProhibitedSubstitutionsUnion.cs @@ -16,7 +16,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеЗапрещенныхПодстановокXS", "XSProhibitedSubstitutionsUnion")] - public class XsProhibitedSubstitutionsUnion : AutoContext + public sealed class XsProhibitedSubstitutionsUnion : AutoContext { private readonly ArrayImpl _values; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSchemaFinalUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSchemaFinalUnion.cs index d333e0b98..28644c629 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSchemaFinalUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSchemaFinalUnion.cs @@ -10,20 +10,19 @@ This Source Code Form is subject to the terms of the using OneScript.StandardLibrary.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.Types; -using ScriptEngine.Machine; using ScriptEngine.Machine.Contexts; namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеЗавершенностиСхемыXS", "XSSchemaFinalUnion")] - public class XSSchemaFinalUnion : AutoContext + public sealed class XSSchemaFinalUnion : AutoContext { - private ArrayImpl _values; + private readonly ArrayImpl _values; private bool Contains(XmlSchemaDerivationMethod value) { var enumValue = EnumerationXSSchemaFinal.Instance.FromNativeValue(value); - IValue idx = _values.Find(enumValue); + var idx = _values.Find(enumValue); return (idx.SystemType != BasicTypes.Undefined); } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSimpleFinalUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSimpleFinalUnion.cs index 81490fc81..1cd14e6aa 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSimpleFinalUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSimpleFinalUnion.cs @@ -10,20 +10,19 @@ This Source Code Form is subject to the terms of the using OneScript.StandardLibrary.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.Types; -using ScriptEngine.Machine; using ScriptEngine.Machine.Contexts; namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеЗавершенностиПростогоТипаXS", "XSSimpleFinalUnion")] - public class XSSimpleFinalUnion : AutoContext + public sealed class XSSimpleFinalUnion : AutoContext { private ArrayImpl _values; private bool Contains(XmlSchemaDerivationMethod _value) { - XSSimpleFinal enumValue = EnumerationXSSimpleFinal.FromNativeValue(_value); - IValue idx = _values.Find(enumValue); + var enumValue = EnumerationXSSimpleFinal.FromNativeValue(_value); + var idx = _values.Find(enumValue); return idx.SystemType != BasicTypes.Undefined; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSubstitutionGroupExclusionsUnion.cs b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSubstitutionGroupExclusionsUnion.cs index 078f35d4a..489c33adf 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSubstitutionGroupExclusionsUnion.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Collections/XSSubstitutionGroupExclusionsUnion.cs @@ -16,7 +16,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Collections { [ContextClass("ОбъединениеИсключенийГруппПодстановкиXS", "XSSubstitutionGroupExclusionsUnion")] - public class XsSubstitutionGroupExclusionsUnion : AutoContext + public sealed class XsSubstitutionGroupExclusionsUnion : AutoContext { private readonly ArrayImpl _values; private bool Contains(XmlSchemaDerivationMethod value) diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs index 63311e279..dbdab2a8d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSComplexFinal.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSComplexFinal : EnumerationValue + public sealed class XSComplexFinal : EnumerationValue { private readonly XmlSchemaDerivationMethod _derivationMethod; public XSComplexFinal(EnumerationContext owner, XmlSchemaDerivationMethod derivationMethod) @@ -28,7 +28,7 @@ public static XmlSchemaDerivationMethod ToNativeValue(XSComplexFinal wrapper) } [SystemEnum("ЗавершенностьСоставногоТипаXS", "XSComplexFinal")] - public class EnumerationXSComplexFinal : EnumerationContext + public sealed class EnumerationXSComplexFinal : EnumerationContext { private readonly Dictionary _valuesCache; @@ -70,6 +70,4 @@ public static EnumerationXSComplexFinal CreateInstance(ITypeManager typeManager) } } - - -} \ No newline at end of file +} diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSContentModel.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSContentModel.cs index 4ef13998b..1b65c3801 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSContentModel.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSContentModel.cs @@ -18,9 +18,15 @@ public enum XSContentModel [EnumValue("EmptyRef", "ПустаяСсылка")] EmptyRef, + /// + /// Простая модель содержания. + /// [EnumValue("Simple", "Простая")] Simple, + /// + /// Составная модель содержания. + /// [EnumValue("Complex", "Составная")] Complex } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs index 65f06a242..9a52f923c 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSDisallowedSubstitutions.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSDisallowedSubstitutions : ClrEnumValueWrapper + public sealed class XSDisallowedSubstitutions : ClrEnumValueWrapper { internal XSDisallowedSubstitutions(EnumerationXSDisallowedSubstitutions instance, XmlSchemaDerivationMethod realValue) : base(instance, realValue) @@ -29,7 +29,7 @@ public static XmlSchemaDerivationMethod ToNativeValue(XSDisallowedSubstitutions } [SystemEnum("НедопустимыеПодстановкиXS", "XSDisallowedSubstitutions")] - public class EnumerationXSDisallowedSubstitutions : EnumerationContext + public sealed class EnumerationXSDisallowedSubstitutions : EnumerationContext { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSForm.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSForm.cs index 9e9c4b18f..29b8ee707 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSForm.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSForm.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSForm : ClrEnumValueWrapper + public sealed class XSForm : ClrEnumValueWrapper { internal XSForm(EnumerationXSForm instance, XmlSchemaForm realValue) : base(instance, realValue ) { @@ -26,7 +26,7 @@ internal XSForm(EnumerationXSForm instance, XmlSchemaForm realValue) : base(inst } [SystemEnum("ФормаПредставленияXS", "XSForm")] - public class EnumerationXSForm : EnumerationContext + public sealed class EnumerationXSForm : EnumerationContext { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs index 344a85e16..e60bd06a4 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSProhibitedSubstitutions.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSProhibitedSubstitutions : ClrEnumValueWrapper + public sealed class XSProhibitedSubstitutions : ClrEnumValueWrapper { internal XSProhibitedSubstitutions(EnumerationXSProhibitedSubstitutions instance, XmlSchemaDerivationMethod realValue) : base(instance, realValue) @@ -29,7 +29,7 @@ public static XmlSchemaDerivationMethod ToNativeValue(XSProhibitedSubstitutions } [SystemEnum("ЗапрещенныеПодстановкиXS", "EnumerationXSProhibitedSubstitutions")] - public class EnumerationXSProhibitedSubstitutions : EnumerationContext + public sealed class EnumerationXSProhibitedSubstitutions : EnumerationContext { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSchemaFinal.cs index 8d56229db..998213398 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 { - public class XSSchemaFinal : ClrEnumValueWrapper + public sealed class XSSchemaFinal : ClrEnumValueWrapper { internal XSSchemaFinal(EnumerationXSSchemaFinal instance, XmlSchemaDerivationMethod realValue) : base(instance, realValue) @@ -22,7 +22,7 @@ internal XSSchemaFinal(EnumerationXSSchemaFinal instance, XmlSchemaDerivationMet } [SystemEnum("ЗавершенностьСхемыXS", "XSSchemaFinal")] - public class EnumerationXSSchemaFinal : ClrEnumWrapper + public sealed class EnumerationXSSchemaFinal : ClrEnumWrapper { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs index 8010da761..281563283 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSimpleFinal.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSSimpleFinal : ClrEnumValueWrapper + public sealed class XSSimpleFinal : ClrEnumValueWrapper { internal XSSimpleFinal(EnumerationXSSimpleFinal instance, XmlSchemaDerivationMethod realValue) : base(instance, realValue) @@ -29,7 +29,7 @@ public static XmlSchemaDerivationMethod ToNativeValue(XSSimpleFinal wrapper) } [SystemEnum("ЗавершенностьПростогоТипаXS", "XSSimpleFinal")] - public class EnumerationXSSimpleFinal : EnumerationContext + public sealed class EnumerationXSSimpleFinal : EnumerationContext { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs index 333d62ad6..a90644bb3 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Enumerations/XSSubstitutionGroupExclusions.cs @@ -14,7 +14,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Enumerations { - public class XSSubstitutionGroupExclusions : ClrEnumValueWrapper + public sealed class XSSubstitutionGroupExclusions : ClrEnumValueWrapper { internal XSSubstitutionGroupExclusions(EnumerationXSSubstitutionGroupExclusions instance, XmlSchemaDerivationMethod realValue) : base(instance, realValue) @@ -29,7 +29,7 @@ public static XmlSchemaDerivationMethod ToNativeValue(XSSubstitutionGroupExclusi } [SystemEnum("ИсключенияГруппПодстановкиXS", "XSSubstitutionGroupExclusions")] - public class EnumerationXSSubstitutionGroupExclusions : EnumerationContext + public sealed class EnumerationXSSubstitutionGroupExclusions : EnumerationContext { private readonly Dictionary _valuesCache; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Interfaces/IXSType.cs b/src/OneScript.StandardLibrary/XMLSchema/Interfaces/IXSType.cs index b374ee757..8929e2d14 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Interfaces/IXSType.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Interfaces/IXSType.cs @@ -9,5 +9,7 @@ namespace OneScript.StandardLibrary.XMLSchema.Interfaces { public interface IXSType : IXSAnnotated { + string NamespaceURI { get; } + string Name { get; set; } } } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchema.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchema.cs index 3d95f6691..524eaf759 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchema.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchema.cs @@ -25,13 +25,15 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("СхемаXML", "XMLSchema")] - public class XMLSchema : AutoContext, IXSComponent, IXDTOSerializableXML + public sealed class XMLSchema : AutoContext, IXSComponent, IXDTOSerializableXML { private readonly XmlSchema _schema; - private XMLSchema() + private XMLSchema() : this(new XmlSchema()) { } + + public XMLSchema(XmlSchema xmlSchema) { - _schema = new XmlSchema(); + _schema = xmlSchema; Components = new XSComponentFixedList(); Annotations = new XSComponentFixedList(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchemaSerializer.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchemaSerializer.cs index 30d19fbd1..80421b16d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchemaSerializer.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XMLSchemaSerializer.cs @@ -13,7 +13,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { - internal class XMLSchemaSerializer + internal static class XMLSchemaSerializer { internal static IXSComponent CreateInstance(XmlSchemaObject xmlSchemaObject) { @@ -93,7 +93,8 @@ private static IXSComponent CreateIXSAnnotated(XmlSchemaAnnotated xmlAnnotated) else if (xmlAnnotated is XmlSchemaGroup xmlGroup) return new XSModelGroupDefinition(xmlGroup); - + else if (xmlAnnotated is XmlSchemaXPath xmlPath) + return new XSXPathDefinition(xmlPath); else throw RuntimeException.InvalidArgumentType(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAnnotation.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAnnotation.cs index adefd01fc..c063335a3 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAnnotation.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAnnotation.cs @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("АннотацияXS", "XSAnnotation")] - public class XSAnnotation : AutoContext, IXSComponent + public sealed class XSAnnotation : AutoContext, IXSComponent { internal readonly XmlSchemaAnnotation InternalObject; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAppInfo.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAppInfo.cs index 5abfc37bf..a1b64664e 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAppInfo.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAppInfo.cs @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ИнформацияДляПриложенияXS", "XSAppInfo")] - public class XSAppInfo : AutoContext, IXSAnnotationItem + public sealed class XSAppInfo : AutoContext, IXSAnnotationItem { private readonly XmlSchemaAppInfo _appInfo; @@ -34,7 +34,7 @@ public class XSAppInfo : AutoContext, IXSAnnotationItem public XSAnnotation Annotation => null; [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -60,7 +60,7 @@ public string Source #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeDeclaration.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeDeclaration.cs index 85cacaa0b..a548df57d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeDeclaration.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeDeclaration.cs @@ -19,7 +19,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОбъявлениеАтрибутаXS", "XSAttributeDeclaration")] - public class XSAttributeDeclaration : AutoContext, IXSAnnotated, IXSAttribute, IXSNamedComponent + public sealed class XSAttributeDeclaration : AutoContext, IXSAnnotated, IXSAttribute, IXSNamedComponent { private readonly XmlSchemaAttribute _attribute; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeGroupDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeGroupDefinition.cs index 77875b644..578d100c9 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeGroupDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeGroupDefinition.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределениеГруппыАтрибутовXS", "XSAttributeGroupDefinition")] - public class XSAttributeGroupDefinition : AutoContext, IXSAnnotated, IXSNamedComponent + public sealed class XSAttributeGroupDefinition : AutoContext, IXSAnnotated, IXSNamedComponent { private XmlSchemaAnnotated _attributeGroup; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeUse.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeUse.cs index 4777b5c02..9a3d11754 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeUse.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSAttributeUse.cs @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ИспользованиеАтрибутаXS", "XSAttributeUse")] - public class XSAttributeUse : AutoContext, IXSComponent + public sealed class XSAttributeUse : AutoContext, IXSComponent { private IValue _value; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSComplexTypeDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSComplexTypeDefinition.cs index b7a4bcc37..616f09d09 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSComplexTypeDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSComplexTypeDefinition.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.Xml; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; @@ -20,9 +20,11 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределениеСоставногоТипаXS", "XSComplexTypeDefinition")] - public class XSComplexTypeDefinition : AutoContext, IXSType, IXSNamedComponent + public sealed class XSComplexTypeDefinition : AutoContext, IXSType, IXSNamedComponent { private readonly XmlSchemaComplexType _type; + private readonly XSComponentFixedList _components = new XSComponentFixedList(); + private readonly XSComponentList _attributes = new XSComponentList(); private XSAnnotation _annotation; private XSAnnotation _contentModelAnnotation; private XSAnnotation _derivationAnnotation; @@ -32,17 +34,9 @@ public class XSComplexTypeDefinition : AutoContext, IXS private XSDerivationMethod _derivationMethod; private XSContentModel _contentModel; - private XSComplexTypeDefinition() - { - _type = new XmlSchemaComplexType(); - Components = new XSComponentFixedList(); - Attributes = new XSComponentList(); - Attributes.Inserted += Attributes_Inserted; - Attributes.Cleared += Attributes_Cleared; - } + private XSComplexTypeDefinition() : this(new XmlSchemaComplexType()) { } internal XSComplexTypeDefinition(XmlSchemaComplexType complexType) - : this() { _type = complexType; @@ -52,86 +46,99 @@ internal XSComplexTypeDefinition(XmlSchemaComplexType complexType) _annotation.BindToContainer(RootContainer, this); } - if (_type.ContentModel is XmlSchemaSimpleContent simpleContent) - { - _contentModel = XSContentModel.Simple; - if (simpleContent.Content is XmlSchemaSimpleContentExtension contentExtension) - { - _derivationMethod = XSDerivationMethod.Extension; - if (contentExtension.BaseTypeName is XmlQualifiedName qualifiedName) - _baseTypeName = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName); - - if (contentExtension.AnyAttribute is XmlSchemaAnyAttribute anyAttribute) - _attributeWildcard = XMLSchemaSerializer.CreateXSWildcard(anyAttribute); - } - else if (simpleContent.Content is XmlSchemaSimpleContentRestriction contentRestriction) - { - _derivationMethod = XSDerivationMethod.Restriction; - if (contentRestriction.BaseTypeName is XmlQualifiedName qualifiedName) - _baseTypeName = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName); - - if (contentRestriction.AnyAttribute is XmlSchemaAnyAttribute anyAttribute) - _attributeWildcard = XMLSchemaSerializer.CreateXSWildcard(anyAttribute); - } - else - _derivationMethod = XSDerivationMethod.EmptyRef; + InitContentModel(); - if (_type.Particle is XmlSchemaParticle particle) - _content = XMLSchemaSerializer.CreateInstance(particle); + foreach (XmlSchemaObject item in _type.Attributes) + { + IXSComponent component = XMLSchemaSerializer.CreateInstance(item); + component.BindToContainer(RootContainer, this); + _attributes.Add(component); + _components.Add(component); } + _attributes.Inserted += Attributes_Inserted; + _attributes.Cleared += Attributes_Cleared; + } + + private void InitContentModel() + { + if (_type.ContentModel is XmlSchemaSimpleContent simpleContent) + InitSimpleContent(simpleContent); + else if (_type.ContentModel is XmlSchemaComplexContent complexContent) - { - _contentModel = XSContentModel.Complex; - - if (complexContent.Content is XmlSchemaComplexContentExtension contentExtension) - { - _derivationMethod = XSDerivationMethod.Extension; - if (contentExtension.BaseTypeName is XmlQualifiedName qualifiedName) - _baseTypeName = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName); - - if (contentExtension.Particle is XmlSchemaParticle particle) - _content = XMLSchemaSerializer.CreateInstance(particle); - - if (contentExtension.AnyAttribute is XmlSchemaAnyAttribute anyAttribute) - _attributeWildcard = XMLSchemaSerializer.CreateXSWildcard(anyAttribute); - } - else if (complexContent.Content is XmlSchemaComplexContentRestriction contentRestriction) - { - _derivationMethod = XSDerivationMethod.Restriction; - if (contentRestriction.BaseTypeName is XmlQualifiedName qualifiedName) - _baseTypeName = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName); - - if (contentRestriction.Particle is XmlSchemaParticle particle) - _content = XMLSchemaSerializer.CreateInstance(particle); - - if (contentRestriction.AnyAttribute is XmlSchemaAnyAttribute anyAttribute) - _attributeWildcard = XMLSchemaSerializer.CreateXSWildcard(anyAttribute); - } - else - { - _derivationMethod = XSDerivationMethod.EmptyRef; + InitComplexContent(complexContent); + + else + InitEmptyContent(); + } - if (_type.Particle is XmlSchemaParticle particle) - _content = XMLSchemaSerializer.CreateInstance(particle); - } + private void InitSimpleContent(XmlSchemaSimpleContent simpleContent) + { + _contentModel = XSContentModel.Simple; + if (simpleContent.Content is XmlSchemaSimpleContentExtension contentExtension) + { + _derivationMethod = XSDerivationMethod.Extension; + InitBaseTypeName(contentExtension.BaseTypeName); + InitAttributeWildcard(contentExtension.AnyAttribute); + } + else if (simpleContent.Content is XmlSchemaSimpleContentRestriction contentRestriction) + { + _derivationMethod = XSDerivationMethod.Restriction; + InitBaseTypeName(contentRestriction.BaseTypeName); + InitAttributeWildcard(contentRestriction.AnyAttribute); } else { - _contentModel = XSContentModel.EmptyRef; - - if (_type.Particle is XmlSchemaParticle particle) - _content = XMLSchemaSerializer.CreateInstance(particle); + _derivationMethod = XSDerivationMethod.EmptyRef; + InitContent(_type.Particle); } - - Attributes.Inserted -= Attributes_Inserted; - foreach (XmlSchemaObject item in _type.Attributes) + } + + private void InitComplexContent(XmlSchemaComplexContent complexContent) + { + _contentModel = XSContentModel.Complex; + if (complexContent.Content is XmlSchemaComplexContentExtension contentExtension) { - IXSComponent component = XMLSchemaSerializer.CreateInstance(item); - component.BindToContainer(RootContainer, this); - Attributes.Add(component); - Components.Add(component); + _derivationMethod = XSDerivationMethod.Extension; + InitBaseTypeName(contentExtension.BaseTypeName); + InitContent(contentExtension.Particle); + InitAttributeWildcard(contentExtension.AnyAttribute); } - Attributes.Inserted += Attributes_Inserted; + else if (complexContent.Content is XmlSchemaComplexContentRestriction contentRestriction) + { + _derivationMethod = XSDerivationMethod.Restriction; + InitBaseTypeName(contentRestriction.BaseTypeName); + InitContent(contentRestriction.Particle); + InitAttributeWildcard(contentRestriction.AnyAttribute); + } + else + { + _derivationMethod = XSDerivationMethod.EmptyRef; + InitContent(_type.Particle); + } + } + + private void InitEmptyContent() + { + _contentModel = XSContentModel.EmptyRef; + InitContent(_type.Particle); + } + + private void InitBaseTypeName(XmlQualifiedName xmlQualifiedName) + { + if (xmlQualifiedName is XmlQualifiedName qualifiedName) + _baseTypeName = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName); + } + + private void InitAttributeWildcard(XmlSchemaAnyAttribute xmlAnyAttribute) + { + if (xmlAnyAttribute is XmlSchemaAnyAttribute anyAttribute) + _attributeWildcard = XMLSchemaSerializer.CreateXSWildcard(anyAttribute); + } + + private void InitContent(XmlSchemaParticle xmlParticle) + { + if (xmlParticle is XmlSchemaParticle particle) + _content = XMLSchemaSerializer.CreateInstance(particle); } private void OnSetContentModelDerivation() @@ -293,7 +300,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components { get; } + public XSComponentFixedList Components => _components; [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -311,7 +318,7 @@ public XSAnnotation Annotation public IValue DOMElement => ValueFactory.Create(); [ContextProperty("URIПространстваИмен", "NamespaceURI")] - public string URIПространстваИмен => _type.SourceUri; + public string NamespaceURI => _type.SourceUri; [ContextProperty("Имя", "Name")] public string Name @@ -358,7 +365,7 @@ public XSAnnotation DerivationAnnotation } [ContextProperty("Атрибуты", "Attributes")] - public XSComponentList Attributes { get; } + public XSComponentList Attributes => _attributes; [ContextProperty("Блокировка", "Block")] public XsProhibitedSubstitutionsUnion Block { get; } @@ -417,7 +424,7 @@ public XSContentModel ContentModel //ОпределениеБазовогоТипа(BaseTypeDefinition) [ContextProperty("Смешанный", "Mixed")] - public bool Mixed => _type.ContentModel is XmlSchemaComplexContent complexContent ? complexContent.IsMixed : false; + public bool Mixed => _type.ContentModel is XmlSchemaComplexContent complexContent && complexContent.IsMixed; [ContextProperty("Содержимое", "Content")] public IXSComponent Content @@ -438,13 +445,13 @@ public IXSComponent Content #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); [ContextMethod("Содержит", "Contains")] - public bool Contains(IXSComponent component) => Components.Contains(component); + public bool Contains(IXSComponent component) => _components.Contains(component); [ContextMethod("ЭтоОпределениеЗациклено", "IsCircular")] public bool IsCircular() => throw new NotImplementedException(); @@ -481,18 +488,16 @@ public void BindToContainer(IXSComponent rootContainer, IXSComponent container) private void Attributes_Inserted(object sender, XSComponentListEventArgs e) { IXSComponent component = e.Component; - if (!(component is IXSAttribute) && (!(component is XSAttributeGroupDefinition))) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires((component is IXSAttribute) || (component is XSAttributeGroupDefinition)); component.BindToContainer(RootContainer, this); - Components.Add(component); + _components.Add(component); _type.Attributes.Add(component.SchemaObject); } private void Attributes_Cleared(object sender, EventArgs e) { - Components.RemoveAll(x => (x is IXSAttribute)); + _components.RemoveAll(x => (x is IXSAttribute)); _type.Attributes.Clear(); } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSDocumentation.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSDocumentation.cs index 7bc8fe6ae..efbcebb8a 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSDocumentation.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSDocumentation.cs @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ДокументацияXS", "XSDocumentation")] - public class XSDocumentation : AutoContext, IXSAnnotationItem + public sealed class XSDocumentation : AutoContext, IXSAnnotationItem { private readonly XmlSchemaDocumentation _documentation; @@ -34,7 +34,7 @@ public class XSDocumentation : AutoContext, IXSAnnotationItem public XSAnnotation Annotation => null; [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -67,7 +67,7 @@ public string Language #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSElementDeclaration.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSElementDeclaration.cs index 69fe0eb6c..45f1fd7d4 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSElementDeclaration.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSElementDeclaration.cs @@ -19,7 +19,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОбъявлениеЭлементаXS", "XSElementDeclaration")] - public class XSElementDeclaration : AutoContext, IXSFragment, IXSNamedComponent + public sealed class XSElementDeclaration : AutoContext, IXSFragment, IXSNamedComponent { private readonly XmlSchemaElement _element; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSEnumerationFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSEnumerationFacet.cs index 2a8423962..3a299bd23 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSEnumerationFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSEnumerationFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетПеречисленияXS", "XSEnumerationFacet")] - public class XSEnumerationFacet : AutoContext, IXSFacet + public sealed class XSEnumerationFacet : AutoContext, IXSFacet { private readonly XmlSchemaEnumerationFacet _facet; private XSAnnotation _annotation; @@ -55,7 +55,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -106,7 +106,7 @@ public IValue Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -131,9 +131,7 @@ public IValue Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSFractionDigitsFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSFractionDigitsFacet.cs index 5014f40f9..5a7217d0b 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSFractionDigitsFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSFractionDigitsFacet.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетКоличестваРазрядовДробнойЧастиXS", "XSFractionDigitsFacet")] - public class XSFractionDigitsFacet : AutoContext, IXSFacet + public sealed class XSFractionDigitsFacet : AutoContext, IXSFacet { private readonly XmlSchemaFractionDigitsFacet _facet; private XSAnnotation _annotation; @@ -53,7 +53,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -96,7 +96,7 @@ public decimal Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -121,9 +121,7 @@ public decimal Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSIdentityConstraintDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSIdentityConstraintDefinition.cs index d1aaf327a..d14c2c391 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSIdentityConstraintDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSIdentityConstraintDefinition.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределениеОграниченияИдентичностиXS", "XSIdentityConstraintDefinition")] - public class XSIdentityConstraintDefinition : AutoContext, IXSAnnotated, IXSNamedComponent + public sealed class XSIdentityConstraintDefinition : AutoContext, IXSAnnotated, IXSNamedComponent { private XmlSchemaIdentityConstraint _constraint; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSImport.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSImport.cs index f894fc9af..5a62e242d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSImport.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSImport.cs @@ -21,16 +21,17 @@ namespace OneScript.StandardLibrary.XMLSchema.Objects /// /// [ContextClass("ИмпортXS", "XSImport")] - public class XSImport : AutoContext, IXSDirective + public sealed class XSImport : AutoContext, IXSDirective { private readonly XmlSchemaImport _import; + private XMLSchema _resolvedSchema; - private XSImport() => _import = new XmlSchemaImport(); + private XSImport() : this(new XmlSchemaImport()) { } internal XSImport(XmlSchemaImport import) - : this() { _import = import; + _resolvedSchema = new XMLSchema(_import.Schema); } #region OneScript @@ -41,7 +42,7 @@ internal XSImport(XmlSchemaImport import) public XSAnnotation Annotation => null; [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -56,10 +57,13 @@ internal XSImport(XmlSchemaImport import) public XSComponentType ComponentType => XSComponentType.Import; [ContextProperty("РазрешеннаяСхема", "ResolvedSchema")] - public XMLSchema ResolvedSchema - { - get => ResolvedSchema; - set => ResolvedSchema = value; + public XMLSchema ResolvedSchema + { + get => _resolvedSchema; + set { + _resolvedSchema = value; + _import.Schema = _resolvedSchema.SchemaObject; + } } [ContextProperty("РасположениеСхемы", "SchemaLocation")] diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSInclude.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSInclude.cs index 380776fce..b759a6059 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSInclude.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSInclude.cs @@ -16,17 +16,18 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ВключениеXS", "XSInclude")] - public class XSInclude : AutoContext, IXSDirective + public sealed class XSInclude : AutoContext, IXSDirective { private readonly XmlSchemaInclude _include; + private XMLSchema _resolvedSchema; - private XSInclude() => _include = new XmlSchemaInclude(); + private XSInclude() : this(new XmlSchemaInclude()) { } internal XSInclude(XmlSchemaInclude include) - : this() { _include = include; + _resolvedSchema = new XMLSchema(_include.Schema); } #region OneScript @@ -37,7 +38,7 @@ internal XSInclude(XmlSchemaInclude include) public XSAnnotation Annotation => null; [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -54,8 +55,12 @@ internal XSInclude(XmlSchemaInclude include) [ContextProperty("РазрешеннаяСхема", "ResolvedSchema")] public XMLSchema ResolvedSchema { - get => ResolvedSchema; - set => ResolvedSchema = value; + get => _resolvedSchema; + set + { + _resolvedSchema = value; + _include.Schema = _resolvedSchema.SchemaObject; + } } [ContextProperty("РасположениеСхемы", "SchemaLocation")] @@ -70,7 +75,7 @@ public string SchemaLocation #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = false) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSLengthFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSLengthFacet.cs index 7ac5f7595..58d9751de 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSLengthFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSLengthFacet.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетДлиныXS", "XSLengthFacet")] - public class XSLengthFacet : AutoContext, IXSFacet + public sealed class XSLengthFacet : AutoContext, IXSFacet { private readonly XmlSchemaLengthFacet _facet; private XSAnnotation _annotation; @@ -53,7 +53,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -96,7 +96,7 @@ public decimal Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -121,9 +121,7 @@ public decimal Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxExclusiveFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxExclusiveFacet.cs index 7ffbe5dd9..0d89d09b3 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxExclusiveFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxExclusiveFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМаксимальногоИсключающегоЗначенияXS", "XSMaxExclusiveFacet")] - public class XSMaxExclusiveFacet : AutoContext, IXSFacet + public sealed class XSMaxExclusiveFacet : AutoContext, IXSFacet { private readonly XmlSchemaMaxExclusiveFacet _facet; private XSAnnotation _annotation; @@ -55,7 +55,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -112,7 +112,7 @@ public IValue Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -137,9 +137,7 @@ public IValue Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxInclusiveFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxInclusiveFacet.cs index b4efde770..d1aab68db 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxInclusiveFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxInclusiveFacet.cs @@ -6,6 +6,7 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; using OneScript.Exceptions; @@ -18,7 +19,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМаксимальногоВключающегоЗначенияXS", "XSMaxInclusiveFacet")] - public class XSMaxInclusiveFacet : AutoContext, IXSFacet + public sealed class XSMaxInclusiveFacet : AutoContext, IXSFacet { private readonly XmlSchemaMaxInclusiveFacet _facet; private XSAnnotation _annotation; @@ -55,7 +56,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -112,7 +113,7 @@ public IValue Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -137,9 +138,7 @@ public IValue Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxLengthFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxLengthFacet.cs index 47e281f27..397c0344d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxLengthFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMaxLengthFacet.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМаксимальнойДлиныXS", "XSMaxLengthFacet")] - public class XSMaxLengthFacet : AutoContext, IXSFacet + public sealed class XSMaxLengthFacet : AutoContext, IXSFacet { private readonly XmlSchemaMaxLengthFacet _facet; private XSAnnotation _annotation; @@ -53,7 +53,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -96,7 +96,7 @@ public decimal Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -121,9 +121,7 @@ public decimal Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinExclusiveFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinExclusiveFacet.cs index 8bf4ca067..98a5d88b1 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinExclusiveFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinExclusiveFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,13 +18,14 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМинимальногоИсключающегоЗначенияXS", "XSMinExclusiveFacet")] - public class XSMinExclusiveFacet : AutoContext, IXSFacet + public sealed class XSMinExclusiveFacet : AutoContext, IXSFacet { private readonly XmlSchemaMinExclusiveFacet _facet; private XSAnnotation _annotation; private IValue _value; private XSMinExclusiveFacet() => _facet = new XmlSchemaMinExclusiveFacet(); + internal XSMinExclusiveFacet(XmlSchemaMinExclusiveFacet minExclusiveFace) { _facet = minExclusiveFace; @@ -36,6 +37,7 @@ internal XSMinExclusiveFacet(XmlSchemaMinExclusiveFacet minExclusiveFace) _annotation.BindToContainer(RootContainer, this); } } + #region OneScript #region Properties @@ -53,7 +55,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -110,7 +112,7 @@ public IValue Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -135,9 +137,7 @@ public IValue Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinInclusiveFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinInclusiveFacet.cs index f122a0290..d4c83e859 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinInclusiveFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinInclusiveFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,13 +18,14 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМинимальногоВключающегоЗначенияXS", "XSMinInclusiveFacet")] - public class XSMinInclusiveFacet : AutoContext, IXSFacet + public sealed class XSMinInclusiveFacet : AutoContext, IXSFacet { private readonly XmlSchemaMinInclusiveFacet _facet; private XSAnnotation _annotation; private IValue _value; private XSMinInclusiveFacet() => _facet = new XmlSchemaMinInclusiveFacet(); + internal XSMinInclusiveFacet(XmlSchemaMinInclusiveFacet minInclusiveFacet) { _facet = minInclusiveFacet; @@ -54,7 +55,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -111,7 +112,7 @@ public IValue Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -136,9 +137,7 @@ public IValue Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinLengthFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinLengthFacet.cs index 57cea6917..322763457 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinLengthFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSMinLengthFacet.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетМинимальнойДлиныXS", "XSMinLengthFacet")] - public class XSMinLengthFacet : AutoContext, IXSFacet + public sealed class XSMinLengthFacet : AutoContext, IXSFacet { private readonly XmlSchemaMinLengthFacet _facet; private XSAnnotation _annotation; @@ -53,7 +53,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -96,7 +96,7 @@ public decimal Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -121,9 +121,7 @@ public decimal Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroup.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroup.cs index ac770d4e8..ed4905be5 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroup.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroup.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ГруппаМоделиXS", "XSModelGroup")] - public class XSModelGroup : AutoContext, IXSFragment + public sealed class XSModelGroup : AutoContext, IXSFragment { private XmlSchemaGroupBase _group; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroupDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroupDefinition.cs index 745e5ffac..c12979632 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroupDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSModelGroupDefinition.cs @@ -19,7 +19,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределениеГруппыМоделиXS", "XSModelGroupDefinition")] - public class XSModelGroupDefinition : AutoContext, IXSFragment, IXSNamedComponent + public sealed class XSModelGroupDefinition : AutoContext, IXSFragment, IXSNamedComponent { private XmlSchemaAnnotated _group; private string _name; @@ -42,7 +42,7 @@ internal XSModelGroupDefinition(XmlSchemaGroup xmlGroup) if (xmlGroup.Particle is XmlSchemaGroupBase xmlGroupBase) { - IXSComponent component = XMLSchemaSerializer.CreateInstance(xmlGroupBase); + var component = XMLSchemaSerializer.CreateInstance(xmlGroupBase); if (component is XSParticle particle) _modelGroup = particle; @@ -52,7 +52,7 @@ internal XSModelGroupDefinition(XmlSchemaGroup xmlGroup) } } - internal XSModelGroupDefinition(XmlSchemaGroupRef xmlGroupRef) + internal XSModelGroupDefinition(in XmlSchemaGroupRef xmlGroupRef) { _group = xmlGroupRef; @@ -83,7 +83,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -162,7 +162,7 @@ public XMLExpandedName Reference #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSNotationDeclaration.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSNotationDeclaration.cs index f245270a3..a12229e61 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSNotationDeclaration.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSNotationDeclaration.cs @@ -16,7 +16,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОбъявлениеНотацииXS", "XSNotationDeclaration")] - public class XSNotationDeclaration : AutoContext, IXSAnnotated, IXSNamedComponent + public sealed class XSNotationDeclaration : AutoContext, IXSAnnotated, IXSNamedComponent { private readonly XmlSchemaNotation _notation; private XSAnnotation _annotation; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSParticle.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSParticle.cs index a4146fca0..adc340feb 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSParticle.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSParticle.cs @@ -19,7 +19,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФрагментXS", "XSParticle")] - public class XSParticle : AutoContext, IXSComponent + public sealed class XSParticle : AutoContext, IXSComponent { private IXSFragment _term; private IValue _minOccurs; diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSPatternFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSPatternFacet.cs index fcb15227c..53792aa9c 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSPatternFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSPatternFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетОбразцаXS", "XSPatternFacet")] - public class XSPatternFacet : AutoContext, IXSFacet + public sealed class XSPatternFacet : AutoContext, IXSFacet { private readonly XmlSchemaPatternFacet _facet; private XSAnnotation _annotation; @@ -52,7 +52,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -95,7 +95,7 @@ public string Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -120,9 +120,7 @@ public string Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSRedefine.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSRedefine.cs index 06769c0c2..752d39371 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSRedefine.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSRedefine.cs @@ -16,25 +16,21 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ПереопределениеXS", "XSRedefine")] - public class XSRedefine : AutoContext, IXSDirective + public sealed class XSRedefine : AutoContext, IXSDirective { private readonly XmlSchemaRedefine _redefine; + private XMLSchema _resolvedSchema; - private XSRedefine() - { - _redefine = new XmlSchemaRedefine(); - Components = new XSComponentFixedList(); - - Content = new XSComponentList(); - Content.Inserted += Content_Inserted; - Content.Cleared += Content_Cleared; - } + private XSRedefine() : this (new XmlSchemaRedefine()) { } internal XSRedefine(XmlSchemaRedefine redefine) - : this() { _redefine = redefine; + _resolvedSchema = new XMLSchema(_redefine.Schema); + + Components = new XSComponentFixedList(); + Content = new XSComponentList(); Content.Inserted -= Content_Inserted; Content.Cleared -= Content_Cleared; @@ -47,7 +43,7 @@ internal XSRedefine(XmlSchemaRedefine redefine) Components.Add(component); Content.Add(component); } - + Content.Inserted += Content_Inserted; Content.Cleared += Content_Cleared; } @@ -77,8 +73,12 @@ internal XSRedefine(XmlSchemaRedefine redefine) [ContextProperty("РазрешеннаяСхема", "ResolvedSchema")] public XMLSchema ResolvedSchema { - get => ResolvedSchema; - set => ResolvedSchema = value; + get => _resolvedSchema; + set + { + _resolvedSchema = value; + _redefine.Schema = _resolvedSchema.SchemaObject; + } } [ContextProperty("РасположениеСхемы", "SchemaLocation")] diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSSimpleTypeDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSSimpleTypeDefinition.cs index eb61ed102..bbafd61c4 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSSimpleTypeDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSSimpleTypeDefinition.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.Xml; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; @@ -20,31 +20,21 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределениеПростогоТипаXS", "XSSimpleTypeDefinition")] - public class XSSimpleTypeDefinition : AutoContext, IXSType, IXSNamedComponent + public sealed class XSSimpleTypeDefinition : AutoContext, IXSType, IXSNamedComponent { private readonly XmlSchemaSimpleType _type; + private readonly XSComponentFixedList _components = new XSComponentFixedList(); + private readonly XSComponentList _typeDefinitions = new XSComponentList(); + private readonly XSComponentList _facets = new XSComponentList(); + private XSAnnotation _annotation; private XMLExpandedName _baseTypeName; private XMLExpandedName _itemTypeName; private XSSimpleTypeVariety _variety; - private XSSimpleTypeDefinition() - { - _type = new XmlSchemaSimpleType(); - Facets = new XSComponentList(); - Facets.Inserted += Facets_Inserted; - Facets.Cleared += Facets_Cleared; - - MemberTypeDefinitions = new XSComponentList(); - MemberTypeDefinitions.Inserted += MemberTypeDefinitions_Inserted; - MemberTypeDefinitions.Cleared += MemberTypeDefinitions_Cleared; - - Components = new XSComponentFixedList(); - Variety = XSSimpleTypeVariety.Atomic; - } + private XSSimpleTypeDefinition() : this(new XmlSchemaSimpleType()) { } internal XSSimpleTypeDefinition(XmlSchemaSimpleType simpleType) - : this() { _type = simpleType; @@ -54,47 +44,126 @@ internal XSSimpleTypeDefinition(XmlSchemaSimpleType simpleType) _annotation.BindToContainer(RootContainer, this); } + InitContentTypeVariety(); + + _facets.Inserted += Facets_Inserted; + _facets.Cleared += Facets_Cleared; + + _typeDefinitions.Inserted += MemberTypeDefinitions_Inserted; + _typeDefinitions.Cleared += MemberTypeDefinitions_Cleared; + } + + private void InitContentTypeVariety() + { if (_type.Content is XmlSchemaSimpleTypeList typeList) - { - _variety = XSSimpleTypeVariety.List; + InitListVariety(typeList); + + else if (_type.Content is XmlSchemaSimpleTypeUnion typeUnion) + InitUnionVariety(typeUnion); - if (typeList.ItemTypeName is XmlQualifiedName qualifiedName) - _itemTypeName = new XMLExpandedName(qualifiedName); + else if (_type.Content is XmlSchemaSimpleTypeRestriction typeRestriction) + InitAtomicVariety(typeRestriction); + else + { + var newRestriction = new XmlSchemaSimpleTypeRestriction(); + _type.Content = newRestriction; + InitAtomicVariety(newRestriction); } - else if (_type.Content is XmlSchemaSimpleTypeUnion typeUnion) + } + + private void InitListVariety(XmlSchemaSimpleTypeList typeList) + { + _variety = XSSimpleTypeVariety.List; + InitItemTypeName(typeList.ItemTypeName); + } + + private void InitUnionVariety(XmlSchemaSimpleTypeUnion typeUnion) + { + _variety = XSSimpleTypeVariety.Union; + foreach (var item in typeUnion.BaseTypes) { - _variety = XSSimpleTypeVariety.Union; - - MemberTypeDefinitions.Inserted -= MemberTypeDefinitions_Inserted; - foreach (XmlSchemaObject item in typeUnion.BaseTypes) - { - IXSComponent component = XMLSchemaSerializer.CreateInstance(item); - component.BindToContainer(RootContainer, this); - MemberTypeDefinitions.Add(component); - Components.Add(component); - } - MemberTypeDefinitions.Inserted += MemberTypeDefinitions_Inserted; + var component = XMLSchemaSerializer.CreateInstance(item); + component.BindToContainer(RootContainer, this); + _typeDefinitions.Add(component); + _components.Add(component); + } + } + + private void InitAtomicVariety(XmlSchemaSimpleTypeRestriction typeRestriction) + { + _variety = XSSimpleTypeVariety.Atomic; + InitBaseTypeName(typeRestriction.BaseTypeName); + + foreach (var item in typeRestriction.Facets) + { + var component = XMLSchemaSerializer.CreateInstance(item); + component.BindToContainer(RootContainer, this); + _facets.Add(component); + _components.Add(component); } - else if (_type.Content is XmlSchemaSimpleTypeRestriction typeRestriction) + } + + private void InitItemTypeName(XmlQualifiedName xmlQualifiedName) + { + if (xmlQualifiedName is XmlQualifiedName qualifiedName) + _itemTypeName = new XMLExpandedName(qualifiedName); + } + + private void InitBaseTypeName(XmlQualifiedName xmlQualifiedName) + { + if (xmlQualifiedName is XmlQualifiedName qualifiedName) + _baseTypeName = new XMLExpandedName(qualifiedName); + } + + private void SetContentTypeVariety(XSSimpleTypeVariety value) + { + if (_variety == value) return; + _variety = value; + + switch (_variety) { - _variety = XSSimpleTypeVariety.Atomic; - - if (typeRestriction.BaseTypeName is XmlQualifiedName qualifiedName) - _baseTypeName = new XMLExpandedName(qualifiedName); - - Facets.Inserted -= Facets_Inserted; - foreach (XmlSchemaObject item in typeRestriction.Facets) - { - IXSComponent component = XMLSchemaSerializer.CreateInstance(item); - component.BindToContainer(RootContainer, this); - Facets.Add(component); - Components.Add(component); - } - Facets.Inserted += Facets_Inserted; + case XSSimpleTypeVariety.List: + _type.Content = new XmlSchemaSimpleTypeList(); + _itemTypeName = default; + break; + + case XSSimpleTypeVariety.Union: + _type.Content = new XmlSchemaSimpleTypeUnion(); + _typeDefinitions.Clear(); + break; + + case XSSimpleTypeVariety.Atomic: + _type.Content = new XmlSchemaSimpleTypeRestriction(); + _baseTypeName = default; + _facets.Clear(); + break; + + default: + break; } } + private void SetBaseTypeName(XMLExpandedName value) + { + if (_baseTypeName == value) return; + Contract.Requires(Variety == XSSimpleTypeVariety.Atomic); + _baseTypeName = value; + + var content = _type.Content as XmlSchemaSimpleTypeRestriction; + content.BaseTypeName = _baseTypeName?.NativeValue; + } + + private void SetItemTypeName(XMLExpandedName value) + { + if (_itemTypeName == value) return; + Contract.Requires(Variety == XSSimpleTypeVariety.List); + _itemTypeName = value; + + var content = _type.Content as XmlSchemaSimpleTypeList; + content.ItemTypeName = _itemTypeName?.NativeValue; + } + #region OneScript #region Properties @@ -112,7 +181,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components { get; } + public XSComponentFixedList Components => _components; [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -130,7 +199,7 @@ public XSAnnotation Annotation public IValue DOMElement => ValueFactory.Create(); [ContextProperty("URIПространстваИмен", "NamespaceURI")] - public string URIПространстваИмен => _type.SourceUri; + public string NamespaceURI => _type.SourceUri; [ContextProperty("Имя", "Name")] public string Name @@ -152,19 +221,7 @@ public string Name public XSSimpleTypeVariety Variety { get => _variety; - set - { - _variety = value; - - if (_variety == XSSimpleTypeVariety.List) - _type.Content = new XmlSchemaSimpleTypeList(); - - else if (_variety == XSSimpleTypeVariety.Union) - _type.Content = new XmlSchemaSimpleTypeUnion(); - - else - _type.Content = new XmlSchemaSimpleTypeRestriction(); - } + set => SetContentTypeVariety(value); } [ContextProperty("Завершенность", "Final")] @@ -177,32 +234,14 @@ public XSSimpleTypeVariety Variety public XMLExpandedName BaseTypeName { get => _baseTypeName; - set - { - _baseTypeName = value; - if (Variety == XSSimpleTypeVariety.Atomic) - { - XmlSchemaSimpleTypeRestriction content = _type.Content as XmlSchemaSimpleTypeRestriction; - content.BaseTypeName = _baseTypeName.NativeValue; - } - else - throw RuntimeException.InvalidArgumentValue(); - } + set => SetBaseTypeName(value); } [ContextProperty("ИмяТипаЭлемента", "ItemTypeName")] public XMLExpandedName ItemTypeName { get => _itemTypeName; - set - { - _itemTypeName = value; - if (Variety == XSSimpleTypeVariety.List) - { - XmlSchemaSimpleTypeList content = (XmlSchemaSimpleTypeList)_type.Content; - content.ItemTypeName = _itemTypeName.NativeValue; - } - } + set => SetItemTypeName(value); } [ContextProperty("ОпределениеБазовогоТипа", "BaseTypeDefinition")] @@ -215,17 +254,17 @@ public XMLExpandedName ItemTypeName public XSSimpleTypeDefinition ItemTypeDefinition { get; set; } [ContextProperty("ОпределенияТиповОбъединения", "MemberTypeDefinitions")] - public XSComponentList MemberTypeDefinitions { get; } + public XSComponentList MemberTypeDefinitions => _typeDefinitions; [ContextProperty("Фасеты", "Facets")] - public XSComponentList Facets { get; } + public XSComponentList Facets => _facets; #endregion #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -264,46 +303,46 @@ public void BindToContainer(IXSComponent rootContainer, IXSComponent container) private void Facets_Inserted(object sender, XSComponentListEventArgs e) { - IXSComponent component = e.Component; - - if (!(component is IXSFacet)) - throw RuntimeException.InvalidArgumentType(); + var component = e.Component; + Contract.Requires(_variety == XSSimpleTypeVariety.Atomic); + Contract.Requires(component is IXSFacet); component.BindToContainer(RootContainer, this); - Components.Add(component); + _components.Add(component); - if (_type.Content is XmlSchemaSimpleTypeRestriction content) - content.Facets.Add(component.SchemaObject); + var content = _type.Content as XmlSchemaSimpleTypeRestriction; + content.Facets.Add(component.SchemaObject); } private void Facets_Cleared(object sender, EventArgs e) { - Components.Clear(); + Contract.Requires(_variety == XSSimpleTypeVariety.Atomic); + _components.Clear(); - if (_type.Content is XmlSchemaSimpleTypeRestriction content) - content.Facets.Clear(); + var content = _type.Content as XmlSchemaSimpleTypeRestriction; + content.Facets.Clear(); } private void MemberTypeDefinitions_Inserted(object sender, XSComponentListEventArgs e) { - IXSComponent component = e.Component; - - if (!(component is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); + var component = e.Component; + Contract.Requires(_variety == XSSimpleTypeVariety.Union); + Contract.Requires(component is XSSimpleTypeDefinition); component.BindToContainer(RootContainer, this); - Components.Add(component); + _components.Add(component); - if (_type.Content is XmlSchemaSimpleTypeUnion content) - content.BaseTypes.Add(component.SchemaObject); + var content = _type.Content as XmlSchemaSimpleTypeUnion; + content.BaseTypes.Add(component.SchemaObject); } private void MemberTypeDefinitions_Cleared(object sender, EventArgs e) { - Components.Clear(); + Contract.Requires(_variety == XSSimpleTypeVariety.Union); + _components.Clear(); - if (_type.Content is XmlSchemaSimpleTypeUnion content) - content.BaseTypes.Clear(); + var content = _type.Content as XmlSchemaSimpleTypeUnion; + content.BaseTypes.Clear(); } #endregion diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSTotalDigitsFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSTotalDigitsFacet.cs index f4ae00949..498bae27d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSTotalDigitsFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSTotalDigitsFacet.cs @@ -6,10 +6,10 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетОбщегоКоличестваРазрядовXS", "XSTotalDigitsFacet")] - public class XSTotalDigitsFacet : AutoContext, IXSFacet + public sealed class XSTotalDigitsFacet : AutoContext, IXSFacet { private readonly XmlSchemaTotalDigitsFacet _facet; private XSAnnotation _annotation; @@ -53,7 +53,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -96,7 +96,7 @@ public decimal Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -121,9 +121,7 @@ public decimal Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWhitespaceFacet.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWhitespaceFacet.cs index a36bb7060..a71ce3216 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWhitespaceFacet.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWhitespaceFacet.cs @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the ----------------------------------------------------------*/ using System; +using System.Diagnostics.Contracts; using System.Xml.Schema; using OneScript.Contexts; -using OneScript.Exceptions; using OneScript.StandardLibrary.XMLSchema.Collections; using OneScript.StandardLibrary.XMLSchema.Enumerations; using OneScript.StandardLibrary.XMLSchema.Interfaces; @@ -17,7 +17,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ФасетПробельныхСимволовXS", "XSWhitespaceFacet")] - public class XSWhitespaceFacet : AutoContext, IXSFacet + public sealed class XSWhitespaceFacet : AutoContext, IXSFacet { private readonly XmlSchemaWhiteSpaceFacet _facet; private XSAnnotation _annotation; @@ -52,7 +52,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container => SimpleTypeDefinition; @@ -131,7 +131,7 @@ public XSWhitespaceHandling Value #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); @@ -156,9 +156,7 @@ public XSWhitespaceHandling Value void IXSComponent.BindToContainer(IXSComponent rootContainer, IXSComponent container) { - if (!(container is XSSimpleTypeDefinition)) - throw RuntimeException.InvalidArgumentType(); - + Contract.Requires(container is XSSimpleTypeDefinition); RootContainer = rootContainer; SimpleTypeDefinition = container as XSSimpleTypeDefinition; } diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWildcard.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWildcard.cs index d770a6778..f5718511d 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWildcard.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSWildcard.cs @@ -18,7 +18,7 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("МаскаXS", "XSWildcard")] - public class XSWildcard : AutoContext, IXSAnnotated, IXSFragment + public sealed class XSWildcard : AutoContext, IXSFragment { private XmlSchemaAnnotated _wildcard; private XSAnnotation _annotation; @@ -43,6 +43,7 @@ internal XSWildcard(XmlSchemaAny xmlAny) SetNamespaceConstraint(); } + internal XSWildcard(XmlSchemaAnyAttribute xmlAnyAttribute) { _wildcard = xmlAnyAttribute; @@ -120,7 +121,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; } @@ -164,7 +165,7 @@ public string LexicalNamespaceConstraint #region Methods [ContextMethod("КлонироватьКомпоненту", "CloneComponent")] - public IXSComponent CloneComponent(bool recursive = true) => throw new NotImplementedException(); + public IXSComponent CloneComponent(bool recursive) => throw new NotImplementedException(); [ContextMethod("ОбновитьЭлементDOM", "UpdateDOMElement")] public void UpdateDOMElement() => throw new NotImplementedException(); diff --git a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSXPathDefinition.cs b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSXPathDefinition.cs index a2616af9c..9377abadd 100644 --- a/src/OneScript.StandardLibrary/XMLSchema/Objects/XSXPathDefinition.cs +++ b/src/OneScript.StandardLibrary/XMLSchema/Objects/XSXPathDefinition.cs @@ -16,13 +16,15 @@ This Source Code Form is subject to the terms of the namespace OneScript.StandardLibrary.XMLSchema.Objects { [ContextClass("ОпределенияXPathXS", "XSXPathDefinition")] - public class XSXPathDefinition : AutoContext, IXSAnnotated, IXSNamedComponent + public sealed class XSXPathDefinition : AutoContext, IXSAnnotated, IXSNamedComponent { private readonly XmlSchemaXPath _xpath; private XSAnnotation _annotation; private XSXPathDefinition() => _xpath = new XmlSchemaXPath(); - + + internal XSXPathDefinition(XmlSchemaXPath xpath) => _xpath = xpath; + #region OneScript #region Properties @@ -39,7 +41,7 @@ public XSAnnotation Annotation } [ContextProperty("Компоненты", "Components")] - public XSComponentFixedList Components => null; + public XSComponentFixedList Components => XSComponentFixedList.EmptyList(); [ContextProperty("Контейнер", "Container")] public IXSComponent Container { get; private set; }