当前位置: 首页>>代码示例>>C#>>正文


C# Xml.XmlBoundElement类代码示例

本文整理汇总了C#中System.Xml.XmlBoundElement的典型用法代码示例。如果您正苦于以下问题:C# XmlBoundElement类的具体用法?C# XmlBoundElement怎么用?C# XmlBoundElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlBoundElement类属于System.Xml命名空间,在下文中一共展示了XmlBoundElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XPathNodePointer

 private XPathNodePointer(DataDocumentXPathNavigator owner, XmlDataDocument doc, XmlNode node, DataColumn c, bool bOnValue, XmlBoundElement parentOfNS)
 {
     this._owner = new WeakReference(owner);
     this._doc = doc;
     this._node = node;
     this._column = c;
     this._fOnValue = bOnValue;
     this._parentOfNS = parentOfNS;
     this._doc.AddPointer(this);
     this._bNeedFoliate = false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:XPathNodePointer.cs

示例2: SearchMatchingTableSchema

        // SearchMatchingTableSchema function works only when the elem has not been bound to a DataRow. If you want to get the table associated w/ an element after 
        // it has been associated w/ a DataRow use GetTableSchemaForElement function.
        // rowElem is the parent region rowElem or null if there is no parent region (in case elem is a row elem, then rowElem will be the parent region; if elem is not
        //    mapped to a DataRow, then rowElem is the region elem is part of)
        //
        // Those are the rules for determing if elem is a row element:
        //  1. node is an element (already meet, since elem is of type XmlElement)
        //  2. If the node is already associated w/ a DataRow, then the node is a row element - not applicable, b/c this function is intended to be called on a
        //    to find out if the node s/b associated w/ a DataRow (see XmlDataDocument.LoadRows)
        //  3. If the node localName/ns matches a DataTable then
        //      3.1 Take the parent region DataTable (in our case rowElem.Row.DataTable)
        //          3.2 If no parent region, then the node is associated w/ a DataTable
        //          3.3 If there is a parent region
        //              3.3.1 If the node has no elem children and no attr other than namespace declaration, and the node can match
        //                  a column from the parent region table, then the node is NOT associated w/ a DataTable (it is a potential DataColumn in the parent region)
        //              3.3.2 Else the node is a row-element (and associated w/ a DataTable / DataRow )
        //
        internal DataTable SearchMatchingTableSchema( XmlBoundElement rowElem, XmlBoundElement elem ) {
            Debug.Assert( elem != null );

            DataTable t = SearchMatchingTableSchema( elem.LocalName, elem.NamespaceURI );
            if ( t == null )
                return null;

            if ( rowElem == null )
                return t;
            // Currently we expect we map things from top of the tree to the bottom
            Debug.Assert( rowElem.Row != null );

            DataColumn col = GetColumnSchemaForNode( rowElem, elem );
            if ( col == null )
                return t;

            foreach ( XmlAttribute a in elem.Attributes ) {
#if DEBUG
                // Some sanity check to catch errors like namespace attributes have the right localName/namespace value, but a wrong atomized namespace value
                if ( a.LocalName == "xmlns" ) {
                    Debug.Assert( a.Prefix != null && a.Prefix.Length == 0 );
                    Debug.Assert( (object)a.NamespaceURI == (object)strReservedXmlns );
                }
                if ( a.Prefix == "xmlns" ) {
                    Debug.Assert( (object)a.NamespaceURI == (object)strReservedXmlns );
                }
                if ( a.NamespaceURI == strReservedXmlns )
                    Debug.Assert( (object)a.NamespaceURI == (object)strReservedXmlns );
#endif
                // No namespace attribute found, so elem cannot be a potential DataColumn, therefore is a row-elem
                if ( (object)(a.NamespaceURI) != (object)strReservedXmlns )
                    return t;
            }

            for ( XmlNode n = elem.FirstChild; n != null; n = n.NextSibling ) {
                if ( n.NodeType == XmlNodeType.Element ) {
                    // elem has an element child, so elem cannot be a potential DataColumn, therefore is a row-elem
                    return t;
                }
            }
            // Node is a potential DataColumn in rowElem region
            return null;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:60,代码来源:DataSetMappper.cs

示例3: GetRegion

 internal bool GetRegion(XmlNode node, out XmlBoundElement rowElem)
 {
     while (node != null)
     {
         XmlBoundElement be = node as XmlBoundElement;
         if ((be != null) && (this.GetRowFromElement(be) != null))
         {
             rowElem = be;
             return true;
         }
         if (node.NodeType == XmlNodeType.Attribute)
         {
             node = ((XmlAttribute) node).OwnerElement;
         }
         else
         {
             node = node.ParentNode;
         }
     }
     rowElem = null;
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:DataSetMapper.cs

示例4: GetColumnSchemaForNode

 internal DataColumn GetColumnSchemaForNode(XmlBoundElement rowElem, XmlNode node)
 {
     object identity = GetIdentity(rowElem.LocalName, rowElem.NamespaceURI);
     object obj2 = GetIdentity(node.LocalName, node.NamespaceURI);
     Hashtable hashtable = (Hashtable) this.columnSchemaMap[identity];
     if (hashtable != null)
     {
         DataColumn column = (DataColumn) hashtable[obj2];
         if (column == null)
         {
             return null;
         }
         MappingType columnMapping = column.ColumnMapping;
         if ((node.NodeType == XmlNodeType.Attribute) && (columnMapping == MappingType.Attribute))
         {
             return column;
         }
         if ((node.NodeType == XmlNodeType.Element) && (columnMapping == MappingType.Element))
         {
             return column;
         }
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:DataSetMapper.cs

示例5: MoveToNamespace

 internal bool MoveToNamespace(string name) {
     //Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:MoveToNamespace(name)");
     _parentOfNS = this._node as XmlBoundElement;
     //only need to check with _node, even if _column is not null and its mapping type is element, it can't have attributes
     if ( _parentOfNS == null )
         return false; 
     string attrName = name;
     if ( attrName == "xmlns" )
         attrName = "xmlns:xmlns";
     if ( attrName != null && attrName.Length == 0 )
         attrName = "xmlns";
     RealFoliate();
     XmlNode node = this._node;
     XmlNodeType nt = node.NodeType;
     XmlAttribute attr = null;
     XmlBoundElement be = null;
     while ( node != null ) {
         //check current element node
         be = node as XmlBoundElement;
         if ( be != null ) {
             if ( be.IsFoliated ) {
                 attr = be.GetAttributeNode ( name, s_strReservedXmlns );
                 if ( attr != null ) {
                     MoveTo( attr );
                     return true;
                 }
             } 
             else {//defoliated so that we need to search through its column 
                 DataRow curRow = be.Row;
                 if ( curRow == null )
                     return false;
                 //going through its attribute columns
                 DataColumn curCol = PreviousColumn( curRow, null, true );
                 while ( curCol != null ) {
                     if ( curCol.Namespace == s_strReservedXmlns && curCol.ColumnName == name ) {
                         MoveTo( be, curCol, false );
                         return true;
                     }
                     curCol = PreviousColumn( curRow, curCol, true );
                 }
             }
         } 
         //didn't find it, try the next element anccester.
         do {
             node = node.ParentNode;
         } while ( node != null && node.NodeType != XmlNodeType.Element );
     }
     //nothing happens, the name doesn't exist as a namespace node.
     _parentOfNS = null;
     return false;
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:51,代码来源:XPathNodePointer.cs

示例6: XPathNodePointer

 private XPathNodePointer( DataDocumentXPathNavigator owner, XmlDataDocument doc, XmlNode node, DataColumn c, bool bOnValue, XmlBoundElement parentOfNS ) {
     Debug.Assert( owner != null );
     this._owner = new WeakReference( owner );
     this._doc = doc;
     this._node = node;
     this._column = c;
     this._fOnValue = bOnValue;
     this._parentOfNS = parentOfNS;
     // Add this pointer to the document so it will be updated each time region changes it's foliation state.
     this._doc.AddPointer( (IXmlDataVirtualNode)this );
     _bNeedFoliate = false;
     AssertValid();
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:13,代码来源:XPathNodePointer.cs

示例7: GetNamespace

        //The function only helps to find out if there is a namespace declaration of given name is defined on the given node
        //It will not check the accestors of the given node.
        private string GetNamespace( XmlBoundElement be, string name ) {
            //Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:GetNamespace(be,name)");

            if ( be == null )
                return null;
            XmlAttribute attr = null;
            if ( be.IsFoliated ) {
                attr = be.GetAttributeNode ( name, s_strReservedXmlns );
                if ( attr != null )
                    return attr.Value;
                else
                    return null;
            } 
            else { //defoliated so that we need to search through its column 
                DataRow curRow = be.Row;
                if ( curRow == null )
                    return null;
                //going through its attribute columns
                DataColumn curCol = PreviousColumn( curRow, null, true );
                while ( curCol != null ) {
                    if ( curCol.Namespace == s_strReservedXmlns ) {
                        //
                        DataRowVersion rowVersion = ( curRow.RowState == DataRowState.Detached ) ? DataRowVersion.Proposed : DataRowVersion.Current;
                        return curCol.ConvertObjectToXml( curRow[curCol,rowVersion] );
                    }
                    curCol = PreviousColumn( curRow, curCol, true );
                }
                return null;
            }
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:32,代码来源:XPathNodePointer.cs

示例8: GetRowFromElement

 internal DataRow GetRowFromElement( XmlBoundElement be ) {
     return be.Row;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:3,代码来源:DataSetMappper.cs

示例9: EnsureDisconnectedDataRow

        // Disconnect the DataRow associated w/ the rowElem region
        private void EnsureDisconnectedDataRow(XmlBoundElement rowElem)
        {
            Debug.Assert(rowElem.Row != null);

            DataRow row = rowElem.Row;
            DataRowState rowState = row.RowState;

            switch (rowState)
            {
                case DataRowState.Detached:
#if DEBUG
                    try
                    {
                        Debug.Assert(row.Table.DataSet.EnforceConstraints == false);
#endif
                        SetNestedParentRegion(rowElem);
#if DEBUG
                    }
                    catch
                    {
                        // We should not get any exceptions here
                        Debug.Assert(false);
                        throw;
                    }
#endif
                    break;

                case DataRowState.Deleted:
                    // Nothing to do: moving a region associated w/ a deleted row to another disconnected tree is a NO-OP.
                    break;

                case DataRowState.Unchanged:
                case DataRowState.Modified:
                    EnsureFoliation(rowElem, ElementState.WeakFoliation);
                    row.Delete();
                    break;

                case DataRowState.Added:
                    EnsureFoliation(rowElem, ElementState.WeakFoliation);
                    row.Delete();
                    SetNestedParentRegion(rowElem);
                    break;

                default:
                    // Handle your case above
                    Debug.Assert(false);
                    break;
            }

            Debug.Assert(!IsRowLive(rowElem.Row));
        }
开发者ID:ericeil,项目名称:corefx,代码行数:52,代码来源:XmlDataDocument.cs

示例10: DuplicateNS

 //endElem is on the path from startElem to root is enforced by the caller
 private bool DuplicateNS( XmlBoundElement endElem, string lname) {
     //Debug.WriteLineIf( XmlTrace.traceXPathNodePointerFunctions.Enabled, "XPathNodePointer:DuplicateNS(endElem, lname)");
     if ( this._parentOfNS == null || endElem == null )
         return false;
     XmlBoundElement be = this._parentOfNS; 
     XmlNode node = null;
     while ( be != null && be != endElem ) {
         if ( GetNamespace( be, lname ) != null )
             return true;
         node = (XmlNode)be;
         do {
             node = node.ParentNode;
         } while ( node != null && node.NodeType != XmlNodeType.Element );
         be = node as XmlBoundElement;
     }
     return false;            
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:18,代码来源:XPathNodePointer.cs

示例11: GetColumnSchemaForNode

        internal DataColumn GetColumnSchemaForNode( XmlBoundElement rowElem, XmlNode node ) {
            // 
            Debug.Assert( rowElem != null );
            // The caller must make sure that node is not a row-element
            Debug.Assert( (node is XmlBoundElement) ? ((XmlBoundElement)node).Row == null : true );

            object tid = GetIdentity( rowElem.LocalName, rowElem.NamespaceURI );
            object cid = GetIdentity( node.LocalName, node.NamespaceURI );

            Hashtable columns = (Hashtable) columnSchemaMap[ tid ];
            if ( columns != null ) {
                DataColumn col = (DataColumn)(columns[ cid ]);
                if ( col == null )
                    return null;

                MappingType mt = col.ColumnMapping;

                if ( node.NodeType == XmlNodeType.Attribute && mt == MappingType.Attribute )
                    return col;
                if ( node.NodeType == XmlNodeType.Element && mt == MappingType.Element )
                    return col;
                // node's (localName, ns) matches a column, but the MappingType is different (i.e. node is elem, MT is attr)
                return null;
            }
            return null;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:26,代码来源:DataSetMappper.cs

示例12: EnsureDocumentElement

        private XmlElement EnsureDocumentElement()
        {
            XmlElement docelem = DocumentElement;
            if (docelem == null)
            {
                string docElemName = XmlConvert.EncodeLocalName(DataSet.DataSetName);
                if (docElemName == null || docElemName.Length == 0)
                    docElemName = "Xml";
                string ns = DataSet.Namespace;
                if (ns == null)
                    ns = string.Empty;
                docelem = new XmlBoundElement(string.Empty, docElemName, ns, this);
                AppendChild(docelem);
            }

            return docelem;
        }
开发者ID:ericeil,项目名称:corefx,代码行数:17,代码来源:XmlDataDocument.cs

示例13: Foliate

        // This function accepts node params that are not row-elements. In this case, calling this function is a no-op
        internal void Foliate(XmlBoundElement node, ElementState newState)
        {
            Debug.Assert(newState == ElementState.WeakFoliation || newState == ElementState.StrongFoliation);
#if DEBUG
            // If we want to strong foliate one of the non-row-elem in a region, then the region MUST be strong-foliated (or there must be no region)
            // Do this only when we are not loading
            if (IsFoliationEnabled)
            {
                if (newState == ElementState.StrongFoliation && node.Row == null)
                {
                    XmlBoundElement rowElem;
                    ElementState rowElemState = ElementState.None;
                    if (_mapper.GetRegion(node, out rowElem))
                    {
                        rowElemState = rowElem.ElementState;
                        Debug.Assert(rowElemState == ElementState.StrongFoliation || rowElemState == ElementState.WeakFoliation);
                    }
                    // Add a no-op, so we can still debug in the assert fails

#pragma warning disable 1717 // assignment to self
                    rowElemState = rowElemState;
#pragma warning restore 1717
                }
            }
#endif

            if (IsFoliationEnabled)
            {
                if (node.ElementState == ElementState.Defoliated)
                {
                    ForceFoliation(node, newState);
                }
                else if (node.ElementState == ElementState.WeakFoliation && newState == ElementState.StrongFoliation)
                {
                    // Node must be a row-elem
                    Debug.Assert(node.Row != null);
                    node.ElementState = newState;
                }
            }
        }
开发者ID:ericeil,项目名称:corefx,代码行数:41,代码来源:XmlDataDocument.cs

示例14: SetNestedParentRegion

        private void SetNestedParentRegion(XmlBoundElement childRowElem, XmlBoundElement parentRowElem)
        {
            DataRow childRow = childRowElem.Row;
            if (parentRowElem == null)
            {
                SetNestedParentRow(childRow, null);
                return;
            }

            DataRow parentRow = parentRowElem.Row;
            Debug.Assert(parentRow != null);
            // We should set it only if there is a nested relationship between this child and parent regions
            DataRelation[] relations = childRow.Table.NestedParentRelations;
            if (relations.Length != 0 && relations[0].ParentTable == parentRow.Table) // just backward compatable
            {
                SetNestedParentRow(childRow, parentRow);
            }
            else
            {
                SetNestedParentRow(childRow, null);
            }
        }
开发者ID:ericeil,项目名称:corefx,代码行数:22,代码来源:XmlDataDocument.cs

示例15: DefoliateRegion

        private void DefoliateRegion(XmlBoundElement rowElem)
        {
            // You must pass a row element (which s/b associated w/ a DataRow)
            Debug.Assert(rowElem.Row != null);

            if (!_optimizeStorage)
                return;

            if (rowElem.ElementState != ElementState.WeakFoliation)
                return;

            if (!_mapper.IsRegionRadical(rowElem))
            {
                return;
            }

            bool saveIgnore = IgnoreXmlEvents;
            IgnoreXmlEvents = true;

            rowElem.ElementState = ElementState.Defoliating;

            try
            {
                // drop all attributes
                rowElem.RemoveAllAttributes();

                XmlNode node = rowElem.FirstChild;
                while (node != null)
                {
                    XmlNode next = node.NextSibling;

                    XmlBoundElement be = node as XmlBoundElement;
                    if (be != null && be.Row != null)
                        break;

                    // The node must be mapped to a column (since the region is radically structured)
                    Debug.Assert(_mapper.GetColumnSchemaForNode(rowElem, node) != null);
                    rowElem.RemoveChild(node);

                    node = next;
                }
#if DEBUG
                // All subsequent siblings must be sub-regions
                for (; node != null; node = node.NextSibling)
                {
                    Debug.Assert((node is XmlBoundElement) && (((XmlBoundElement)node).Row != null));
                }
#endif

                rowElem.ElementState = ElementState.Defoliated;
            }
            finally
            {
                IgnoreXmlEvents = saveIgnore;
            }
        }
开发者ID:ericeil,项目名称:corefx,代码行数:56,代码来源:XmlDataDocument.cs


注:本文中的System.Xml.XmlBoundElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。