public void InitializeContext() { this.store.TransactionManager.DoWithinTransaction(() => { var patternModel = this.store.ElementFactory.CreateElement<PatternModelSchema>(); this.product = patternModel.Create<PatternSchema>(); var automationSettings = this.product.Create<AutomationSettingsSchema>(); this.settings = automationSettings.AddExtension<TemplateSettings>(); }); validationContext = new ValidationContext(ValidationCategories.Save, this.settings); }
private static void WritePropertiesAsElements(DslModeling::SerializationContext serializationContext, TemplateSettings element, global::System.Xml.XmlWriter writer) { // RawTargetFileName if (!serializationContext.Result.Failed) { global::System.String propValue = element.RawTargetFileName; if (!serializationContext.Result.Failed) { if (!string.IsNullOrEmpty(propValue)) LibrarySerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "targetFileName", propValue); } } // RawTargetPath if (!serializationContext.Result.Failed) { global::System.String propValue = element.RawTargetPath; if (!serializationContext.Result.Failed) { if (!string.IsNullOrEmpty(propValue)) LibrarySerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "targetPath", propValue); } } }
private static void ReadPropertiesFromElements(DslModeling::SerializationContext serializationContext, TemplateSettings element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "targetFileName": // RawTargetFileName if (reader.IsEmptyElement) { // No serialized value, must be default one. DslModeling::SerializationUtilities.Skip(reader); // Skip this tag. } else { string strRawTargetFileName = LibrarySerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader); global::System.String valueOfRawTargetFileName; if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(serializationContext, strRawTargetFileName, out valueOfRawTargetFileName)) { element.RawTargetFileName = valueOfRawTargetFileName; } else { // Invalid property value, ignored. LibrarySerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "targetFileName", typeof(global::System.String), strRawTargetFileName); } DslModeling::SerializationUtilities.SkipToNextElement(reader); } break; case "targetPath": // RawTargetPath if (reader.IsEmptyElement) { // No serialized value, must be default one. DslModeling::SerializationUtilities.Skip(reader); // Skip this tag. } else { string strRawTargetPath = LibrarySerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader); global::System.String valueOfRawTargetPath; if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(serializationContext, strRawTargetPath, out valueOfRawTargetPath)) { element.RawTargetPath = valueOfRawTargetPath; } else { // Invalid property value, ignored. LibrarySerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "targetPath", typeof(global::System.String), strRawTargetPath); } DslModeling::SerializationUtilities.SkipToNextElement(reader); } break; default: return; // Don't know this element. } } }