Esempio n. 1
0
 /// <summary>
 /// Adds a new area type to the factory.
 /// </summary>
 /// <param name="name">
 /// The name of the area type
 /// </param>
 /// <param name="createArea">
 /// The delegate to call to create an instance of this area type.
 /// </param>
 /// <remarks>This is used by plugins to register new area types.</remarks>
 static public void AddFactoryItem(string name, AreaCreatorFunc createArea)
 {
     if (pluginTable == null)
     {
         pluginTable = new Dictionary <string, AreaCreatorFunc>();
     }
     // System.Console.WriteLine("Adding plugin name {0}", name);
     pluginTable.Add(name, createArea);
 }
Esempio n. 2
0
        /// <summary>
        /// Factory method to create instances of area types by name.
        /// </summary>
        /// <param name="name">
        /// The name of the type of the area to create.
        /// </param>
        /// <param name="ag">
        /// The <see cref="AreaGroup"/> this area will belong in.
        /// </param>
        /// <returns>
        /// The created area.
        /// </returns>
        static public Area Factory(string name, AreaGroup ag)
        {
            try {
                AreaCreatorFunc acf = pluginTable[name];
                return(acf(ag));
            }
            catch (KeyNotFoundException e) {
                System.Console.WriteLine(e.Message);
            }

            return(null);
        }