コード例 #1
0
        /// <summary>
        /// Get the configuration data for the given name, which should be identical to the config dat file name without its extension (e.g. "tile").<para/>
        /// Throws an <see cref="ArgumentException"/> if the given name isn't valid, and an <see cref="ArgumentNullException"/> if the given name is <see langword="null"/>.<para/>
        /// In many cases this will be an <see cref="Array"/> type, but this is not guaranteed.
        /// </summary>
        /// <param name="cfgName">The name of the configuration, identical to its dat name without the extension (e.g. "tile")</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">If the name isn't correct.</exception>
        /// <exception cref="ArgumentNullException">If the name is null.</exception>
        public ManagedConfig[] this[string cfgName] {
            get {
                if (cfgName == null)
                {
                    throw new ArgumentNullException("cfgName");
                }
                cfgName = cfgName.ToLower();
                if (!ValidNames.Contains(cfgName))
                {
                    throw new ArgumentException("The given index is not valid! (" + cfgName + " is not a valid OOO Configuration name)");
                }
                if (References.ContainsKey(cfgName))
                {
                    return(References[cfgName]);
                }

                XanLogger.WriteLine("One sec! I'm loading up the config data for [" + cfgName + "]...");
                XanLogger.UpdateLog();                 // UpdateLog call is here since auto-logging might be off here, and this is a status update message
                // people get antsy when things take time, so it's good to tell them.

                ManagedConfig[] reference = ConfigReferenceBootstrapper.GetConfigReferenceFromName(cfgName);
                // ^ calls the setter down here.
                return(reference);
            }
        }
コード例 #2
0
        /// <summary>
        /// Given a <see cref="Type"/> representing a specific config (e.g. <see cref="MaterialConfig"/>), the container for this config and all of its instances will be returned.<para/>
        /// In many cases this will be an <see cref="Array"/> type, but this is not guaranteed.
        /// </summary>
        /// <param name="cfgType"></param>
        /// <returns></returns>
        public ManagedConfig[] this[Type cfgType] {
            get {
                if (ReferencesByType.ContainsKey(cfgType))
                {
                    return(ReferencesByType[cfgType]);
                }

                XanLogger.WriteLine("One sec! I'm loading up the config data for [" + cfgType.Name + "]...");
                XanLogger.UpdateLog();                 // UpdateLog call is here since auto-logging might be off here, and this is a status update message
                // people get antsy when things take time, so it's good to tell them.

                ManagedConfig[] reference = ConfigReferenceBootstrapper.GetConfigReferenceFromType(cfgType);
                // ^ calls the setter on the name variant (which sets the type too)
                return(reference);
            }
        }