Пример #1
0
        // Sets the count of TextPositions referencing the node's BeforeEnd edge.
        // Since nodes don't usually have any references, we demand allocate
        // storage when needed.
        protected void SetBeforeEndReferenceCount(ref EdgeReferenceCounts edgeReferenceCounts, int value)
        {
            EdgeReferenceCounts originalCounts;

            if (edgeReferenceCounts != null)
            {
                if (value == 0 &&
                    edgeReferenceCounts.BeforeStartReferenceCount == 0 &&
                    edgeReferenceCounts.AfterStartReferenceCount == 0 &&
                    edgeReferenceCounts.AfterEndReferenceCount == 0)
                {
                    edgeReferenceCounts = null;
                }
                else
                {
                    if (!(edgeReferenceCounts is ElementEdgeReferenceCounts))
                    {
                        // We need a slightly bigger object, which tracks the inner edges.
                        Invariant.Assert(this is TextTreeTextElementNode, "Non-element nodes should never have inner edge references!");
                        originalCounts      = edgeReferenceCounts;
                        edgeReferenceCounts = new ElementEdgeReferenceCounts();
                        edgeReferenceCounts.BeforeStartReferenceCount = originalCounts.BeforeStartReferenceCount;
                        edgeReferenceCounts.AfterEndReferenceCount    = originalCounts.AfterEndReferenceCount;
                    }
                    edgeReferenceCounts.BeforeEndReferenceCount = value;
                }
            }
            else if (value != 0)
            {
                edgeReferenceCounts = new ElementEdgeReferenceCounts();
                edgeReferenceCounts.BeforeEndReferenceCount = value;
            }
        }
Пример #2
0
 // Sets the count of TextPositions referencing the node's right
 // edge.
 // Since nodes don't usually have any references, we demand allocate
 // storage when needed.
 protected static void SetAfterEndReferenceCount(ref EdgeReferenceCounts edgeReferenceCounts, int value)
 {
     if (edgeReferenceCounts != null)
     {
         if (value == 0 &&
             edgeReferenceCounts.BeforeStartReferenceCount == 0 &&
             edgeReferenceCounts.AfterStartReferenceCount == 0 &&
             edgeReferenceCounts.BeforeEndReferenceCount == 0)
         {
             edgeReferenceCounts = null;
         }
         else
         {
             edgeReferenceCounts.AfterEndReferenceCount = value;
         }
     }
     else if (value != 0)
     {
         edgeReferenceCounts = new EdgeReferenceCounts();
         edgeReferenceCounts.AfterEndReferenceCount = value;
     }
 }
Пример #3
0
 // Sets the count of TextPositions referencing the node's right 
 // edge.
 // Since nodes don't usually have any references, we demand allocate 
 // storage when needed.
 protected static void SetAfterEndReferenceCount(ref EdgeReferenceCounts edgeReferenceCounts, int value)
 {
     if (edgeReferenceCounts != null) 
     {
         if (value == 0 && 
             edgeReferenceCounts.BeforeStartReferenceCount == 0 && 
             edgeReferenceCounts.AfterStartReferenceCount == 0 &&
             edgeReferenceCounts.BeforeEndReferenceCount == 0) 
         {
             edgeReferenceCounts = null;
         }
         else 
         {
             edgeReferenceCounts.AfterEndReferenceCount = value; 
         } 
     }
     else if (value != 0) 
     {
         edgeReferenceCounts = new EdgeReferenceCounts();
         edgeReferenceCounts.AfterEndReferenceCount = value;
     } 
 }
Пример #4
0
        // Sets the count of TextPositions referencing the node's BeforeEnd edge. 
        // Since nodes don't usually have any references, we demand allocate 
        // storage when needed.
        protected void SetBeforeEndReferenceCount(ref EdgeReferenceCounts edgeReferenceCounts, int value) 
        {
            EdgeReferenceCounts originalCounts;

            if (edgeReferenceCounts != null) 
            {
                if (value == 0 && 
                    edgeReferenceCounts.BeforeStartReferenceCount == 0 && 
                    edgeReferenceCounts.AfterStartReferenceCount == 0 &&
                    edgeReferenceCounts.AfterEndReferenceCount == 0) 
                {
                    edgeReferenceCounts = null;
                }
                else 
                {
                    if (!(edgeReferenceCounts is ElementEdgeReferenceCounts)) 
                    { 
                        // We need a slightly bigger object, which tracks the inner edges.
                        Invariant.Assert(this is TextTreeTextElementNode, "Non-element nodes should never have inner edge references!"); 
                        originalCounts = edgeReferenceCounts;
                        edgeReferenceCounts = new ElementEdgeReferenceCounts();
                        edgeReferenceCounts.BeforeStartReferenceCount = originalCounts.BeforeStartReferenceCount;
                        edgeReferenceCounts.AfterEndReferenceCount = originalCounts.AfterEndReferenceCount; 
                    }
                    edgeReferenceCounts.BeforeEndReferenceCount = value; 
                } 
            }
            else if (value != 0) 
            {
                edgeReferenceCounts = new ElementEdgeReferenceCounts();
                edgeReferenceCounts.BeforeEndReferenceCount = value;
            } 
        }