System.Xml.BitStack.PushBit C# (CSharp) Méthode

PushBit() public méthode

Push a 0 or 1 bit onto the stack.
public PushBit ( bool bit ) : void
bit bool
Résultat void
        public void PushBit(bool bit) {
            if ((this.curr & 0x80000000) != 0) {
                // If sentinel bit has reached the last position, push this.curr
                PushCurr();
            }

            // Shift new bit onto this.curr (which must have at least one open position)
            this.curr = (this.curr << 1) | (bit ? 1u : 0u);
        }

Usage Example

        public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
        {
            _wrapped = writer;

            _systemId = settings.DocTypeSystem;
            _publicId = settings.DocTypePublic;

            if (settings.OutputMethod == XmlOutputMethod.Xml)
            {
                bool documentConformance = false;

                // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is)
                // Only check for well-formed document if output method is xml
                if (_systemId != null)
                {
                    documentConformance = true;
                    _outputDocType = true;
                }

                // Check for well-formed document if standalone="yes" in an auto-generated xml declaration
                if (settings.Standalone == XmlStandalone.Yes)
                {
                    documentConformance = true;
                    _standalone = settings.Standalone;
                }

                if (documentConformance)
                {
                    if (settings.Standalone == XmlStandalone.Yes)
                    {
                        _wrapped.WriteStartDocument(true);
                    }
                    else
                    {
                        _wrapped.WriteStartDocument();
                    }
                }

                if (settings.CDataSectionElements != null && settings.CDataSectionElements.Count > 0)
                {
                    _bitsCData = new BitStack();
                    _lookupCDataElems = new Dictionary<XmlQualifiedName, XmlQualifiedName>();
                    _qnameCData = new XmlQualifiedName();

                    // Add each element name to the lookup table
                    foreach (XmlQualifiedName name in settings.CDataSectionElements)
                    {
                        _lookupCDataElems[name] = null;
                    }

                    _bitsCData.PushBit(false);
                }
            }
            else if (settings.OutputMethod == XmlOutputMethod.Html)
            {
                // Html output method should output doc-type-decl if system ID or public ID is defined
                if (_systemId != null || _publicId != null)
                    _outputDocType = true;
            }
        }
All Usage Examples Of System.Xml.BitStack::PushBit