Ejemplo n.º 1
0
        /// <summary>
        /// Finds the first instance of an element of a specified type derived from <see cref="Map"/> in this <see cref="Map"/><br/>
        /// This includes this instance.
        /// </summary>
        /// <typeparam name="T">The type of <see cref="Map"/> that we wish to find the first instance of</typeparam>
        /// <returns>The first instance of type <typeparamref name="T"/> found in the hierarchy.</returns>
        internal override T FirstDescendentOfType <T>()
        {
            if (this is T)
            {
                return((T)(BaseMap)this);
            }

            // TableData is derived from BaseMap to try this...
            if (this.TableData != null)
            {
                BaseMap item = this.TableData.FirstDescendentOfType <T>();
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }

            // The Properties of a table are derived from BaseMap, so I suppose we should test these...
            if (this.properties == null || this.properties.Count == 0)
            {
                return(null);
            }

            for (int i = 0; i < this.properties.Count; i++)
            {
                BaseMap item = this.properties[i].FirstDescendentOfType <T>();
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }

            // NB! For the moment, we will ignore anything lower.
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the first instance of an element of a specified type derived from <see cref="BaseMap"/> in this <see cref="BaseMap"/><br/>
        /// which has a specified key. This includes this instance.
        /// </summary>
        /// <param name="key">The key of the typed item that we require</param>
        /// <typeparam name="T">The type of <see cref="BaseMap"/> that we wish to find the first instance of</typeparam>
        /// <returns>The first instance of type <typeparamref name="T"/> found in the hierarchy.</returns>
        internal override T FirstDescendentOfType <T>(string key)
        {
            if (this is T && this.Key == key)
            {
                return((T)(BaseMap)this);
            }

            // TableData is derived from BaseMap so try this...
            if (this.TableData != null)
            {
                BaseMap item = this.TableData.FirstDescendentOfType <T>(key);
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }

            // The Properties of a table are derived from BaseMap, so I suppose we should test these...
            if (this.properties != null && this.properties.Count > 0)
            {
                for (int i = 0; i < this.properties.Count; i++)
                {
                    BaseMap item = this.properties[i].FirstDescendentOfType <T>(key);
                    if (item != null)
                    {
                        return((T)(BaseMap)item);
                    }
                }
            }

            // Process any Item which may have been dynamically added.
            foreach (BaseMap i in this.Items)
            {
                BaseMap item = i.FirstDescendentOfType <T>(key);
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }

            // NB! For the moment, we will ignore anything lower.
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds the first instance of an element of a specified type derived from <see cref="Map"/> in this <see cref="Map"/><br/>
        /// This includes this instance.
        /// </summary>
        /// <typeparam name="T">The type of <see cref="Map"/> that we wish to find the first instance of</typeparam>
        /// <returns>The first instance of type <typeparamref name="T"/> found in the hierarchy.</returns>
        internal override T FirstDescendentOfType <T>()
        {
            if (this is T)
            {
                return((T)(BaseMap)this);
            }

            // The Properties of a table are derived from Map, so I suppose we should test these...
            if (this.items == null || this.items.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < this.items.Count; i++)
            {
                BaseMap item = this.items[i].FirstDescendentOfType <T>();
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Finds the first instance of an element of a specified type derived from <see cref="BaseMap"/> in this <see cref="BaseMap"/><br/>
        /// which has a specified key. This includes this instance.
        /// </summary>
        /// <param name="key">The key of the typed item that we require</param>
        /// <typeparam name="T">The type of <see cref="BaseMap"/> that we wish to find the first instance of</typeparam>
        /// <returns>The first instance of type <typeparamref name="T"/> found in the hierarchy.</returns>
        internal override T FirstDescendentOfType <T>(string key)
        {
            if (this is T && this.Key == key)
            {
                return((T)(BaseMap)this);
            }

            // The items in this stack panel derive from map so test these...
            if (this.items == null || this.items.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < this.items.Count; i++)
            {
                BaseMap item = this.items[i].FirstDescendentOfType <T>(key);
                if (item != null)
                {
                    return((T)(BaseMap)item);
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a keyed element to a list of keyed elements in a <see cref="ExcelMapCoOrdinate"/> derived class.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="element"></param>
 internal static void AddKeyedElement(this ExcelMapCoOrdinate map, string key, BaseMap element)
 {
     if (map.KeyedElements == null)
     {
         map.KeyedElements = new List <KeyValuePair <string, BaseMap> >();
     }
     map.KeyedElements.Add(new KeyValuePair <string, BaseMap>(key, element));
 }