コード例 #1
0
ファイル: SIFWriter.cs プロジェクト: rubitek/OpenADK-csharp
        /// <summary>  Write a SIF element in the version of SIF currently in effect for this
        /// SifWriter.
        /// </summary>
        /// <param name="element">The SIF Element instance to Write to the output stream
        /// <param name="isLegacy">if true, this method assumes that it needs to do more work,
        /// such as looking for rendering surrogates for the specific version of SIF</param>
        /// </param>
        private void WriteElement(SifElement element, bool isLegacy)
        {
            IElementDef def = element.ElementDef;

            if (!(Include(element) && def.IsSupported(fVersion)))
            {
                return;
            }

            if (isLegacy)
            {
                IRenderSurrogate surrogate = def.GetVersionInfo(fVersion).GetSurrogate();
                if (surrogate != null)
                {
                    surrogate.RenderRaw(fWriter, fVersion, element, fFormatter);
                    return;
                }
            }

            if (element.IsEmpty() || !HasContent(element, fVersion))
            {
                if (element is XMLData)
                {
                    XmlDocument doc = ((XMLData)element).Xml;
                    doc.Save(fWriter);
                }
                else
                {
                    Write(element, EMPTY, isLegacy);
                }
            }
            else
            {
                Write(element, OPEN, isLegacy);

                ICollection <Element> elements = fFormatter.GetContent(element, fVersion);
                foreach (Element childElement in elements)
                {
                    if (childElement is SifElement)
                    {
                        WriteElement((SifElement)childElement, isLegacy);
                    }
                    else
                    {
                        Write((SimpleField)childElement, isLegacy);
                    }
                }
                fWriter.WriteEndElement();
            }
        }
コード例 #2
0
ファイル: SIFWriter.cs プロジェクト: rafidzal/OpenADK-csharp
        /// <summary>  Write a SIF element in the version of SIF currently in effect for this
        /// SifWriter.
        /// </summary>
        /// <param name="element">The SIF Element instance to Write to the output stream
        /// <param name="isLegacy">if true, this method assumes that it needs to do more work,
        /// such as looking for rendering surrogates for the specific version of SIF</param>
        /// </param>
        private void WriteElement( SifElement element, bool isLegacy )
        {
            IElementDef def = element.ElementDef;
            if ( !(Include( element ) && def.IsSupported( fVersion ) )  )
            {
                return;
            }

            if (isLegacy)
            {
                IRenderSurrogate surrogate = def.GetVersionInfo(fVersion).GetSurrogate();
                if (surrogate != null)
                {
                    surrogate.RenderRaw(fWriter, fVersion, element, fFormatter);
                    return;
                }
            }

            if ( element.IsEmpty() || !HasContent( element, fVersion ) )
            {
                if (element is XMLData)
                {
                    XmlDocument doc = ((XMLData) element).Xml;
                    doc.Save( fWriter );
                }
                else
                {
                    Write( element, EMPTY, isLegacy );
                }
            }
            else
            {
                Write( element, OPEN, isLegacy );

                ICollection<Element> elements = fFormatter.GetContent( element, fVersion );
                foreach ( Element childElement in elements )
                {
                    if ( childElement is SifElement )
                    {
                        WriteElement( (SifElement) childElement, isLegacy );
                    }
                    else
                    {
                        Write( (SimpleField) childElement, isLegacy );
                    }
                }
                fWriter.WriteEndElement();
            }
        }