/// <summary> /// Renders the element to the specified writer. /// </summary> /// <param name="writer">The writer.</param> internal override void Render(IXmlWriter writer) { writer.WriteStartElement(this.Tag); if (!string.IsNullOrEmpty(this.Id)) { writer.WriteAttributeString("id", this.Id); } if (this.Classes.Any()) { writer.WriteAttributeString("class", string.Join(" ", this.Classes)); } foreach (var attribute in this.Attributes) { attribute.Render(writer); } this.Content.Do(c => c.Render(writer)); foreach (var children in this.Elements) { children.Render(writer); } writer.WriteEndElement(); }
/// <summary> /// Serializes the specified object and writes the XML document to a file using the specified <see cref="IXmlWriter"/> and references the specified namespaces and encoding style. /// </summary> /// <param name="xmlWriter">The <see cref="IXmlWriter"/> used to write the XML document. </param> /// <param name="o">The object to serialize. </param> /// <param name="namespaces">The <see cref="T:System.Xml.Serialization.XmlSerializerNamespaces"/> referenced by the object. </param> /// <param name="encodingStyle">The encoding style of the serialized XML. </param> /// <exception cref="T:System.InvalidOperationException">An error occurred during serialization. The original exception is available using the <see cref="P:System.Exception.InnerException"/> property. </exception> public void Serialize(IXmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces, string encodingStyle) { this.XmlSerializerInstance.Serialize(xmlWriter.Writer, o, namespaces, encodingStyle, null); }
///<summary> ///</summary> ///<param name = "writer"></param> public XmlPropertySerializer(IXmlWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } _writer = writer; }
public override void ProcessCollection(CollectionMapping mapping) { IXmlWriter <CollectionMapping> writer = null; switch (mapping.Collection) { case Collection.Array: writer = new XmlArrayWriter(serviceLocator); break; case Collection.Bag: writer = new XmlBagWriter(serviceLocator); break; case Collection.List: writer = new XmlListWriter(serviceLocator); break; case Collection.Map: writer = new XmlMapWriter(serviceLocator); break; case Collection.Set: writer = new XmlSetWriter(serviceLocator); break; default: throw new InvalidOperationException("Unrecognised collection type " + mapping.Collection); } document = writer.Write(mapping); }
protected override void WriteControls(IXmlWriter serializer) { foreach (ComboBoxItem item in this.items) { serializer.OpenTag("item"); item.WriteAttributes(serializer); serializer.CloseTag(); } }
public void ShouldWriteColumns() { var container = new XmlWriterContainer(); var mapping = new ManyToManyMapping(); mapping.AddColumn(Layer.Defaults, new ColumnMapping("Column1")); writer = container.Resolve <IXmlWriter <ManyToManyMapping> >(); writer.VerifyXml(mapping) .Element("column").Exists(); }
public void ShouldWriteCheckAttribute() { IXmlWriter<StoredProcedureMapping> writer; var container = new XmlWriterContainer(); writer = container.Resolve<IXmlWriter<StoredProcedureMapping>>(); var testHelper = new XmlWriterTestHelper<StoredProcedureMapping>(); testHelper.Check(x => x.Check, "none").MapsToAttribute("check"); testHelper.VerifyAll(writer); }
public void ShouldWriteColumns() { var container = new XmlWriterContainer(); var mapping = new ManyToManyMapping(); mapping.AddColumn(new ColumnMapping { Name = "Column1" }); writer = container.Resolve<IXmlWriter<ManyToManyMapping>>(); writer.VerifyXml(mapping) .Element("column").Exists(); }
public void Serialize(IXmlWriter newWriter, object source) { if (source == null || source.GetType() != type) { throw new ArgumentNullException(nameof(source)); } writer = newWriter ?? throw new ArgumentNullException(nameof(newWriter)); Write(source); }
public void ShouldWriteCheckAttribute() { IXmlWriter <StoredProcedureMapping> writer; var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <StoredProcedureMapping> >(); var testHelper = new XmlWriterTestHelper <StoredProcedureMapping>(); testHelper.Check(x => x.Check, "none").MapsToAttribute("check"); testHelper.VerifyAll(writer); }
/// <summary> /// Saves window to xml file. Used by designer. /// </summary> /// <param name="fileName">file name to save window to.</param> public void Save(String fileName) { using (IXmlWriter writer = this.Engine.CreateXmlFile(fileName)) { if (null != writer) { this.WriteBegin(writer); this.WriteAttributes(writer); this.WriteControls(writer); this.WriteEnd(writer); } } }
public void VerifyAll(IXmlWriter <TMappingType> writer) { foreach (var test in _tests) { var mapping = new TMappingType(); test.ApplyToSource(mapping); var serializer = new MappingXmlSerializer(); var xmlDoc = writer.Write(mapping); test.Check(xmlDoc); } }
public void Serialize(IXmlWriter writer, object source) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (source == null || source.GetType() != type) { throw new ArgumentNullException(nameof(source)); } this.writer = writer; Write(source); }
public Task SaveAsync(IXmlDocument configXml, string path) { return(Task.Run(() => { using (IFileStream fileStream = mFileStreamFactory.Create(path, FileMode.Create)) { XmlWriterSettings settings = new XmlWriterSettings { Indent = true }; using (IXmlWriter xtw = mXmlWriterFactory.Create(fileStream.FileStreamInstance, settings)) { configXml.Save(xtw.Writer); } } })); }
internal IXmlWriter CreateXmlFile(String fileName) { IXmlWriter writer = null; if (null != this.xmlFactory) { writer = this.xmlFactory.CreateXmlWriter(this); } if (null != writer) { writer.OpenFile(fileName); return(writer); } return(null); }
protected override void Context() { _individual = new Individual(); _container = A.Fake <IContainer>(); _serializationContextFactory = A.Fake <ISerializationContextFactory>(); _simulationUpdater = A.Fake <ISimulationUpdaterAfterDeserialization>(); _eventPublisher = A.Fake <IEventPublisher>(); _xmlReaderIndividual = A.Fake <IXmlReader <Individual> >(); _xmlWriterIndividual = A.Fake <IXmlWriter <Individual> >(); _xmlReaderSimulation = A.Fake <IXmlReader <Simulation> >(); _xmlWriterSimulation = A.Fake <IXmlWriter <Simulation> >(); _objectConverterFinder = A.Fake <IObjectConverterFinder>(); _serializationContext = A.Fake <SerializationContext>(); A.CallTo(() => _container.Resolve <IXmlReader <Individual> >()).Returns(_xmlReaderIndividual); A.CallTo(() => _container.Resolve <IXmlWriter <Individual> >()).Returns(_xmlWriterIndividual); A.CallTo(() => _container.Resolve <IXmlReader <Simulation> >()).Returns(_xmlReaderSimulation); A.CallTo(() => _container.Resolve <IXmlWriter <Simulation> >()).Returns(_xmlWriterSimulation); _referenceResolver = A.Fake <IReferencesResolver>(); sut = new XmlSerializationManager(_referenceResolver, _container, _objectConverterFinder, _simulationUpdater, _eventPublisher, _serializationContextFactory); A.CallTo(() => _serializationContextFactory.Create(null, null)).Returns(_serializationContext); }
public void VerifyAll(IXmlWriter <TMappingType> writer) { foreach (var test in _tests) { TMappingType mapping; if (constructor == null) { mapping = (TMappingType)typeof(TMappingType).InstantiateUsingParameterlessConstructor(); } else { mapping = constructor(); } test.ApplyToSource(mapping); var serializer = new MappingXmlSerializer(); var xmlDoc = writer.Write(mapping); test.Check(xmlDoc); } }
/// <summary> /// Renders the specified writer. /// </summary> /// <param name="writer">The writer.</param> internal virtual void Render(IXmlWriter writer) { switch (this.type) { case "xml": writer.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); break; case "transitional": writer.WriteString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); break; case "strict": writer.WriteString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); break; case "frameset": writer.WriteString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"); break; case "1.1": writer.WriteString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"); break; case "basic": writer.WriteString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">"); break; case "mobile": writer.WriteString("<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">"); break; default: writer.WriteString("<!DOCTYPE " + this.type + ">"); break; } }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <CollectionMapping> >(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve<IXmlWriter<CompositeElementMapping>>(); }
public XmlReferenceComponentWriter(IXmlWriterServiceLocator serviceLocator) : base(serviceLocator) { innerWriter = serviceLocator.GetWriter <IComponentMapping>(); }
/// <summary> /// Saves control to file stream. /// </summary> /// <param name="writer">stream to write to.</param> protected override void WriteControls(IXmlWriter writer) { base.WriteControls(writer, this.internalPanel.Controls); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <ElementMapping> >(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <NaturalIdMapping> >(); }
/// <summary> /// Serializes the specified <see cref="T:System.Object"/> and writes the XML document to a file using the specified <see cref="IXmlWriter"/>, XML namespaces, and encoding. /// </summary> /// <param name="xmlWriter">The <see cref="IXmlWriter"/> used to write the XML document.</param> /// <param name="o">The object to serialize.</param> /// <param name="namespaces">An instance of the XmlSerializaerNamespaces that contains namespaces and prefixes to use.</param> /// <param name="encodingStyle">The encoding used in the document.</param> /// <param name="id">For SOAP encoded messages, the base used to generate id attributes. </param> public void Serialize(IXmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces, string encodingStyle, string id) { this.XmlSerializerInstance.Serialize(xmlWriter.Writer, o, namespaces, encodingStyle, id); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <JoinedSubclassMapping> >(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <KeyPropertyMapping> >(); }
internal void WriteAttributes(IXmlWriter serializer) { serializer.WriteAttribute("name", this.Name); serializer.WriteAttribute("text", this.text); serializer.WriteAttribute("icon", this.Icon); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve<IXmlWriter<ICollectionRelationshipMapping>>(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <ManyToOneMapping> >(); }
public NotaFiscalService(IXmlWriter <NotaFiscal> writer, INotaFiscalRepository notaFiscalRepository) { _writer = writer; _notaFiscalRepository = notaFiscalRepository; }
public override void Context() { writer = new XmlPackageWriter(); mapping = new PackageMapping(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve<IXmlWriter<ReferenceComponentMapping>>(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <ReferenceComponentMapping> >(); }
/// <summary> /// Serializes the specified <see cref="T:System.Object"/> and writes the XML document to a file using the specified <see cref="IXmlWriter"/>. /// </summary> /// <param name="xmlWriter">The <see cref="IXmlWriter"/> used to write the XML document. </param> /// <param name="o">The <see cref="T:System.Object"/> to serialize. </param> /// <exception cref="T:System.InvalidOperationException">An error occurred during serialization. The original exception is available using the <see cref="P:System.Exception.InnerException"/> property. </exception> public void Serialize(IXmlWriter xmlWriter, object o) { this.XmlSerializerInstance.Serialize(xmlWriter.Writer, o, null); }
/// <summary> /// Serializes the specified <see cref="T:System.Object"/> and writes the XML document to a file using the specified <see cref="IXmlWriter"/> and references the specified namespaces. /// </summary> /// <param name="xmlWriter">The <see cref="IXmlWriter"/> used to write the XML document. </param> /// <param name="o">The <see cref="T:System.Object"/> to serialize. </param> /// <param name="namespaces">The <see cref="T:System.Xml.Serialization.XmlSerializerNamespaces"/> referenced by the object. </param> /// <exception cref="T:System.InvalidOperationException">An error occurred during serialization. The original exception is available using the <see cref="P:System.Exception.InnerException"/> property. </exception> public void Serialize(IXmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces) { this.XmlSerializerInstance.Serialize(xmlWriter.Writer, o, namespaces, null); }
public static MappingXmlTestHelper VerifyXml <T>(this IXmlWriter <T> writer, T model) { var document = writer.Write(model); return(new MappingXmlTestHelper(document)); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve <IXmlWriter <DiscriminatorMapping> >(); }
public void GetWriterFromContainer() { var container = new XmlWriterContainer(); writer = container.Resolve<IXmlWriter<IdMapping>>(); }