コード例 #1
0
        /// <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();
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
ファイル: XmlPropertySerializer.cs プロジェクト: jerkka/Olan
 ///<summary>
 ///</summary>
 ///<param name = "writer"></param>
 public XmlPropertySerializer(IXmlWriter writer)
 {
     if (writer == null) {
         throw new ArgumentNullException("writer");
     }
     _writer = writer;
 }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: XmlPropertySerializer.cs プロジェクト: qtst/Logger
 ///<summary>
 ///</summary>
 ///<param name = "writer"></param>
 public XmlPropertySerializer(IXmlWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     _writer = writer;
 }
コード例 #6
0
ファイル: ComboBox.cs プロジェクト: drme/thw-ui
 protected override void WriteControls(IXmlWriter serializer)
 {
     foreach (ComboBoxItem item in this.items)
     {
         serializer.OpenTag("item");
         item.WriteAttributes(serializer);
         serializer.CloseTag();
     }
 }
コード例 #7
0
        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();
        }
コード例 #8
0
        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);
        }      
コード例 #9
0
        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();
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: Window.cs プロジェクト: drme/thw-ui
 /// <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);
         }
     }
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: XmlSerializer.cs プロジェクト: aritryakumar/dotnet
        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);
                        }
                    }
                }));
            }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        /// <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;
            }
        }
コード例 #20
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <CollectionMapping> >();
        }
コード例 #21
0
 public void GetWriterFromContainer()
 {
     var container = new XmlWriterContainer();
     writer = container.Resolve<IXmlWriter<CompositeElementMapping>>();
 }
コード例 #22
0
 public XmlReferenceComponentWriter(IXmlWriterServiceLocator serviceLocator)
     : base(serviceLocator)
 {
     innerWriter = serviceLocator.GetWriter <IComponentMapping>();
 }
コード例 #23
0
ファイル: ScrollPanel.cs プロジェクト: drme/thw-ui
 /// <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);
 }
コード例 #24
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <ElementMapping> >();
        }
コード例 #25
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <NaturalIdMapping> >();
        }
コード例 #26
0
 /// <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);
 }
コード例 #27
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <JoinedSubclassMapping> >();
        }
コード例 #28
0
 /// <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);
 }
コード例 #29
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <KeyPropertyMapping> >();
        }
コード例 #30
0
ファイル: ComboBoxItem.cs プロジェクト: drme/thw-ui
 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>>();
 }
コード例 #32
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <ManyToOneMapping> >();
        }
コード例 #33
0
 public NotaFiscalService(IXmlWriter <NotaFiscal> writer, INotaFiscalRepository notaFiscalRepository)
 {
     _writer = writer;
     _notaFiscalRepository = notaFiscalRepository;
 }
コード例 #34
0
 public override void Context()
 {
     writer = new XmlPackageWriter();
     mapping = new PackageMapping();
 }
コード例 #35
0
 public void GetWriterFromContainer()
 {
     var container = new XmlWriterContainer();
     writer = container.Resolve<IXmlWriter<ReferenceComponentMapping>>();
 }
コード例 #36
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <ReferenceComponentMapping> >();
        }
コード例 #37
0
 /// <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);
 }
コード例 #38
0
 /// <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);
 }
コード例 #39
0
        public static MappingXmlTestHelper VerifyXml <T>(this IXmlWriter <T> writer, T model)
        {
            var document = writer.Write(model);

            return(new MappingXmlTestHelper(document));
        }
コード例 #40
0
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();

            writer = container.Resolve <IXmlWriter <DiscriminatorMapping> >();
        }
コード例 #41
0
 /// <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);
 }
コード例 #42
0
 public void GetWriterFromContainer()
 {
     var container = new XmlWriterContainer();
     writer = container.Resolve<IXmlWriter<IdMapping>>();
 }
コード例 #43
0
 /// <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);
 }