GetEnumerator() 공개 메소드

public GetEnumerator ( ) : IEnumerator
리턴 IEnumerator
예제 #1
0
 static public int GetEnumerator(IntPtr l)
 {
     try {
         System.Collections.Queue self = (System.Collections.Queue)checkSelf(l);
         var ret = self.GetEnumerator();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #2
0
 static int GetEnumerator(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Queue       obj = (System.Collections.Queue)ToLua.CheckObject(L, 1, typeof(System.Collections.Queue));
         System.Collections.IEnumerator o   = obj.GetEnumerator();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #3
0
 public override void Draw(Microsoft.DirectX.Direct3D.Device device, Matrix worldMatrix)
 {
     base.Draw(device, worldMatrix);
     device.Transform.World = worldMatrix;
     if (points.Count > 1)
     {
         IEnumerator j = points.GetEnumerator();
         j.MoveNext();
         Vector3 temp = (Vector3)j.Current;
         for (int i = 0; i < points.Count - 1; ++i)
         {
             j.MoveNext();
             MainForm.LineTo(ref device, (Vector3)temp, (Vector3)j.Current, Color.Pink);
             temp = (Vector3)j.Current;
         }
     }
 }
예제 #4
0
파일: bookmarks.cs 프로젝트: nfan/Jaxer
        ///////////////////////////////////////////////////////////////////////////
        // IDataStore implementation
        public void GetElements(String aContainerID, out IEnumerator aElements)
        {
            XmlElement container = GetElementById(aContainerID);
              if (container == null)
            container = mBookmarksDocument.DocumentElement.FirstChild as XmlElement;
              int itemCount = container.ChildNodes.Count;
              Queue items = new Queue();
              for (int i = 0; i < itemCount; ++i)
              {
            XmlElement currElt = container.ChildNodes[i] as XmlElement;
            // If the bookmark does not have an ID, generate one and set it.
            if (!currElt.HasAttribute("id") || currElt.GetAttribute("id") == "")
              currElt.SetAttribute("id", Bookmarks.GenerateID());

            CommandTarget target = new CommandTarget();
            target.Label = currElt.GetAttribute("label");
            target.AccessKey = currElt.GetAttribute("accesskey");
            target.Data = currElt.GetAttribute("id");
            target.IsContainer = currElt.HasChildNodes;
            target.IconURL = currElt.GetAttribute("icon");
            target.IsOpen = currElt.GetAttribute("open") == "true";

            items.Enqueue(target);
              }
              aElements = items.GetEnumerator();
        }
예제 #5
0
    // Finds identical subtrees in both trees and skrinks them into XmlDiffShrankNode instances
    private void MatchIdenticalSubtrees()
    {
        Hashtable sourceUnmatchedNodes = new Hashtable( 16 );
        Hashtable targetUnmatchedNodes = new Hashtable( 16 );

        Queue sourceNodesToExpand = new Queue( 16 );
        Queue targetNodesToExpand = new Queue( 16 );

        sourceNodesToExpand.Enqueue( _sourceDoc );
        targetNodesToExpand.Enqueue( _targetDoc );

        AddNodeToHashTable( sourceUnmatchedNodes, _sourceDoc );
        AddNodeToHashTable( targetUnmatchedNodes, _targetDoc );

        while ( sourceNodesToExpand.Count > 0  ||
                targetNodesToExpand.Count > 0 )
        {
            // Expand next level of source nodes and add them to the sourceUnmatchedNodes hashtable.
            // Leave the parents of expanded nodes in the sourceNodesToExpand queue for later use.
            {
                IEnumerator en = sourceNodesToExpand.GetEnumerator();
                while ( en.MoveNext() )
                {
                    XmlDiffParentNode sourceParentNode = (XmlDiffParentNode) en.Current;
                    Debug.Assert( !sourceParentNode._bExpanded );

                    sourceParentNode._bExpanded = true;
                    
                    if ( !sourceParentNode.HasChildNodes )
                        continue;

                    XmlDiffNode curSourceNode = sourceParentNode._firstChildNode;
                    while ( curSourceNode != null )
                    {
                        AddNodeToHashTable( sourceUnmatchedNodes, curSourceNode );
                        curSourceNode = curSourceNode._nextSibling;
                    }
                }
            }

            // Expand next level of target nodes and try to match them against the sourceUnmatchedNodes hashtable.
            // to find matching node. 
            int count = targetNodesToExpand.Count;
            for ( int i = 0; i < count; i++ )
            {
                XmlDiffParentNode targetParentNode = (XmlDiffParentNode) targetNodesToExpand.Dequeue();
                Debug.Assert( !targetParentNode._bExpanded );

                if ( !NodeInHashTable( targetUnmatchedNodes, targetParentNode ) ) {
                    continue;
                }

                targetParentNode._bExpanded = true;
                
                if ( !targetParentNode.HasChildNodes )
                    continue;

                XmlDiffNode curTargetNode = targetParentNode._firstChildNode;
                while ( curTargetNode != null )
                {
                    Debug.Assert( !( curTargetNode is XmlDiffAttributeOrNamespace ) );

                    // try to match
                    XmlDiffNode firstSourceNode = null;
                    XmlDiffNodeListHead matchingSourceNodes = (XmlDiffNodeListHead) sourceUnmatchedNodes[ curTargetNode.HashValue ];

                    if ( matchingSourceNodes != null  ) {
                        // find matching node and remove it from the hashtable
                        firstSourceNode = HTFindAndRemoveMatchingNode( sourceUnmatchedNodes, matchingSourceNodes, curTargetNode );
                    }
                    
                    // no match
                    if ( firstSourceNode == null || 
                         // do not shrink xml declarations and DTD
                         (int)curTargetNode.NodeType < 0 )
                    {
                        if ( curTargetNode.HasChildNodes )
                            targetNodesToExpand.Enqueue( curTargetNode );
                        else
                            curTargetNode._bExpanded = true;

                        AddNodeToHashTable( targetUnmatchedNodes, curTargetNode );
                        curTargetNode = curTargetNode._nextSibling;
                        continue;
                    }

                    HTRemoveAncestors( sourceUnmatchedNodes, firstSourceNode );
                    HTRemoveDescendants( sourceUnmatchedNodes, firstSourceNode );

                    HTRemoveAncestors( targetUnmatchedNodes, curTargetNode );
                    // there are no target node descendants in the hash table

                    // find matching interval - starts at startSourceNode and startTargetNode
                    XmlDiffNode firstTargetNode = curTargetNode;
                    XmlDiffNode lastSourceNode = firstSourceNode;
                    XmlDiffNode lastTargetNode = firstTargetNode;

                    curTargetNode = curTargetNode._nextSibling;
                    XmlDiffNode curSourceNode = firstSourceNode._nextSibling;

                    while ( curTargetNode != null  &&  
                            curSourceNode != null  &&
                            curSourceNode.NodeType != XmlDiffNodeType.ShrankNode )
                    {
                        // still matches and the nodes has not been matched elsewhere
                        if ( IdenticalSubtrees( curSourceNode, curTargetNode )  &&
                             sourceUnmatchedNodes.Contains( curSourceNode.HashValue ) )
                        {
                            HTRemoveNode( sourceUnmatchedNodes, curSourceNode );
                            HTRemoveDescendants( sourceUnmatchedNodes, curSourceNode );
                        }
                        // no match -> end of interval
                        else
                            break;

                        lastSourceNode = curSourceNode;
                        curSourceNode = curSourceNode._nextSibling;
                        //Debug.Assert( curSourceNode == null || curSourceNode.NodeType != XmlDiffNodeType.ShrankNode );

                        lastTargetNode = curTargetNode;
                        curTargetNode = curTargetNode._nextSibling;
                        //Debug.Assert( curTargetNode == null || curTargetNode.NodeType != XmlDiffNodeType.ShrankNode );
                    }

                    if ( firstSourceNode != lastSourceNode || 
                         firstSourceNode.NodeType != XmlDiffNodeType.Element ) {
                        ShrinkNodeInterval( firstSourceNode, lastSourceNode, firstTargetNode, lastTargetNode);
                    }
                    else {
                        XmlDiffElement e = (XmlDiffElement)firstSourceNode;
                        if ( e.FirstChildNode != null || e._attributes != null ) {
                            ShrinkNodeInterval( firstSourceNode, lastSourceNode, firstTargetNode, lastTargetNode);
                        }
                    }
                }
            }

            // Walk through the newly expanded source nodes (=children of nodes in sourceNodesToExpand queue)
            // and try to match them against targetUnmatchedNodes hashtable.
            count = sourceNodesToExpand.Count;
            for ( int i = 0; i < count; i++ )
            {
                XmlDiffParentNode sourceParentNode = (XmlDiffParentNode) sourceNodesToExpand.Dequeue();
                Debug.Assert( sourceParentNode._bExpanded );

                if ( !sourceParentNode.HasChildNodes )
                    continue;

                XmlDiffNode curSourceNode = sourceParentNode._firstChildNode;
                while ( curSourceNode != null )
                {
                    // it it's an attribute or the node has already been matched -> continue
                    Debug.Assert( ! ( curSourceNode is XmlDiffAttributeOrNamespace ) ) ;
                    if ( curSourceNode is XmlDiffShrankNode ||
                         !NodeInHashTable( sourceUnmatchedNodes, curSourceNode ) )
                    {
                        curSourceNode = curSourceNode._nextSibling;
                        continue;
                    }

                    // try to match
                    XmlDiffNode firstTargetNode = null;
                    XmlDiffNodeListHead matchingTargetNodes = (XmlDiffNodeListHead) targetUnmatchedNodes[ curSourceNode.HashValue ];

                    if ( matchingTargetNodes != null  ) {
                        // find matching node and remove it from the hashtable
                        firstTargetNode = HTFindAndRemoveMatchingNode( targetUnmatchedNodes, matchingTargetNodes, curSourceNode );
                    }
                    
                    // no match
                    if ( firstTargetNode == null || 
                         // do not shrink xml declarations and DTD
                         (int)curSourceNode.NodeType < 0 )
                    {
                        if ( curSourceNode.HasChildNodes )
                            sourceNodesToExpand.Enqueue( curSourceNode );
                        else
                            curSourceNode._bExpanded = true;

                        curSourceNode = curSourceNode._nextSibling;
                        continue;
                    }

                    HTRemoveAncestors( targetUnmatchedNodes, firstTargetNode );
                    HTRemoveDescendants( targetUnmatchedNodes, firstTargetNode );

                    if ( !HTRemoveNode( sourceUnmatchedNodes, curSourceNode ) )
                        Debug.Assert( false );
                    HTRemoveAncestors( sourceUnmatchedNodes, curSourceNode );
                    // there are no source node descendants in the hash table

                    Debug.Assert( !( curSourceNode is XmlDiffAttributeOrNamespace ) );

                    // find matching interval - starts at startSourceNode and startTargetNode
                    XmlDiffNode firstSourceNode = curSourceNode;
                    XmlDiffNode lastSourceNode = firstSourceNode;
                    XmlDiffNode lastTargetNode = firstTargetNode;

                    curSourceNode = curSourceNode._nextSibling;
                    XmlDiffNode curTargetNode = firstTargetNode._nextSibling;

                    while ( curSourceNode != null  && 
                            curTargetNode != null  &&
                            curTargetNode.NodeType != XmlDiffNodeType.ShrankNode )
                    {
                        // still matches and the nodes has not been matched elsewhere
                        if ( IdenticalSubtrees( curSourceNode, curTargetNode ) &&
                            sourceUnmatchedNodes.Contains( curSourceNode.HashValue ) &&
                            targetUnmatchedNodes.Contains( curTargetNode.HashValue ) )
                        {
                            HTRemoveNode( sourceUnmatchedNodes, curSourceNode );
                            HTRemoveDescendants( sourceUnmatchedNodes, curSourceNode );

                            HTRemoveNode( targetUnmatchedNodes, curTargetNode );
                            HTRemoveDescendants( targetUnmatchedNodes, curTargetNode );
                        }
                        // no match -> end of interval
                        else {
                            break;
                        }

                        lastSourceNode = curSourceNode;
                        curSourceNode = curSourceNode._nextSibling;

                        lastTargetNode = curTargetNode;
                        curTargetNode = curTargetNode._nextSibling;
                    }

                    if ( firstSourceNode != lastSourceNode || 
                         firstSourceNode.NodeType != XmlDiffNodeType.Element ) {
                        ShrinkNodeInterval( firstSourceNode, lastSourceNode, firstTargetNode, lastTargetNode);
                    }
                    else {
                        XmlDiffElement e = (XmlDiffElement)firstSourceNode;
                        if ( e.FirstChildNode != null || e._attributes != null ) {
                            ShrinkNodeInterval( firstSourceNode, lastSourceNode, firstTargetNode, lastTargetNode);
                        }
                    }
                }
            }
        }
    }
예제 #6
0
 public IEnumerator GetEnumerator()
 {
     return(m_logQueue.GetEnumerator());
 }
예제 #7
0
        private static Hashtable AdjustGenericTypes(Type genericType, Hashtable genInnerTypes, short genTypeHandle, ref Hashtable nestedGenerics, bool throwExceptions)
        {
            Hashtable genNestedTypes = new Hashtable();

            if (genInnerTypes != null)
            {
                IDictionaryEnumerator ide1 = genInnerTypes.GetEnumerator();
                while (ide1.MoveNext())
                {
                    System.Collections.Queue genConcreteTypes = (System.Collections.Queue)ide1.Value;
                    IEnumerator ide          = genConcreteTypes.GetEnumerator();
                    int         genArgsCount = genericType.GetGenericArguments().Length;
                    Type[]      parms        = new Type[genArgsCount];
                    SortedList  sortedTypes  = new SortedList(genArgsCount);
                    int         index        = 0;
                    short       typeHandle   = 0;
                    while (ide.MoveNext())
                    {
                        TypeHandlePair thp = (TypeHandlePair)ide.Current;
                        if (!genNestedTypes.Contains((Type)thp._type) && CheckForBuiltinSurrogate((Type)thp._type))
                        {
                            if (!nestedGenerics.Contains((Type)thp._type))
                            {
                                nestedGenerics.Add((Type)thp._type, (short)thp._handle);
                            }
                        }

                        if (typeof(Dictionary <,>) == genericType && index == 0)
                        {
                            Type typ = typeof(System.Collections.Generic.Dictionary <,>);
                            if (!nestedGenerics.Contains(typ))
                            {
                                nestedGenerics.Add(typ, genTypeHandle);
                            }
                        }
                        if (typeof(List <>).Equals(genericType) && index == 0)
                        {
                            Type typ = typeof(System.Collections.Generic.List <>);
                            if (!nestedGenerics.Contains(typ))
                            {
                                nestedGenerics.Add(typ, genTypeHandle);
                            }
                        }


                        if (index == 0 || ((Type)thp._type).IsGenericType)
                        {
                            typeHandle = (short)((short)thp._handle - 1);
                            index++;
                        }
                        sortedTypes.Add((short)thp._handle, (Type)thp._type);
                    }
                    for (int indx = 0; indx < sortedTypes.Count; indx++)
                    {
                        if (indx < parms.Length)
                        {
                            parms[indx] = (Type)sortedTypes.GetByIndex(indx);
                        }
                    }
                    Type genType = null;
                    try
                    {
                        genType = genericType.MakeGenericType(parms);
                    }
                    catch (Exception ex)
                    {
                        if (throwExceptions)
                        {
                            string data = "param count : " + parms.Length.ToString() + "\n\n";
                            for (int i = 0; i < parms.Length; i++)
                            {
                                data += "  FullName Arg " + i + " : " + ((Type)parms[i]).FullName;
                                data += "  Name Arg " + i + " : " + ((Type)parms[i]).Name + "\n";
                            }
                            throw new Exception(genericType.FullName + " can not be registered with compact framework ( ex.Message : " + ex.Message + " ) ex.Tostring() : " + ex.ToString() + "Data:" + data);
                        }
                    }
                    if (genType != null && !genNestedTypes.Contains(genType))
                    {
                        typeHandle = GetUniqueHandle(genNestedTypes, nestedGenerics, sortedTypes);
                        genNestedTypes.Add(genType, typeHandle);
                    }
                }
            }
            return(genNestedTypes);
        }
예제 #8
0
 public override IEnumerator GetEnumerator()
 {
     lock (queue) {
         return(queue.GetEnumerator());
     }
 }