コード例 #1
0
        /// <summary>
        /// This method provides configurable initialization of the iterator.
        /// The default version works exactly as Begin(). It can be overriden
        /// by a subclass if a configurable initialization is necessary
        /// </summary>
        /// <param name="param">The context either as an integer index or as ContextType parameter </param>
        /// <returns>The first element in the context</returns>
        public override RASTElement Begin(object param = null)
        {
            m_elementIndex = 0;
            if (param is int)
            {
                m_contextIndex = (int)param;
            }
            else if (param is ContextType)
            {
                m_contextIndex = m_node.MapContextToIndex((ContextType)param);
            }
            else
            {
                return(base.Begin(param));
            }

            // Update item
            m_item = m_node.GetChild(m_contextIndex, m_elementIndex);

            return(m_item);
        }
コード例 #2
0
    public override RASTElement Begin(object param = null)
    {
        int context = 0;

        // Initialize context from method parameter
        if (param != null)
        {
            if (param is int)
            {
                context = (int)param;
            }
            else if (param is ContextType)
            {
                context = m_node.MapContextToIndex((ContextType)param);
            }
            else
            {
                Console.WriteLine("WARNING!!! Iterator initialization didn't work as expected");
            }
        }

        // Initialize Iterator
        PrepareFirst(context);

        // Update item
        m_item = m_node.GetChild(m_contextIndex, m_elementIndex);

        //Event Triggering
        if (m_item != null)
        {
            // Prepare event information
            RASTVisitorEventArgs args = new RASTVisitorEventArgs();

            // Raise OnContextEnter and OnNodeEnter events
            m_Event.OnContextEnter(m_item, args);
            m_Event.OnNodeEnter(m_item, args);
        }

        return(m_item);
    }