示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Resources{T}" /> class.
        /// </summary>
        public Resources()
        {
            Resource[] collection = null;
            if (typeof(T).IsEnum)
            {
                var resources = ResourceCollection.GetResources(typeof(T));
                if (resources != null)
                {
                    var names = Enum.GetNames(typeof(T));
                    var ids   = new int[names.Length];
                    int maxId = 0;
                    for (var i = 0; i < names.Length; i++)
                    {
                        var id = (int)Enum.Parse(typeof(T), names[i]);
                        ids[i] = id;
                        if (maxId < id)
                        {
                            maxId = id;
                        }
                    }

                    collection = new Resource[names.Length];
                    for (var i = 0; i < names.Length; i++)
                    {
                        var      name = names[i];
                        Resource data;
                        if (resources.TryGetValue(name, out data))
                        {
                            collection[ids[i]] = data;
                        }
                    }
                }
            }

            this.resources = collection;
        }
示例#2
0
 public Resources GetSimulation(Resources.ResourcesType type)
 {
     return(resourcesSimu.GetResources(type));
 }
示例#3
0
 public Resources GetResources(Resources.ResourcesType type)
 {
     return(resourcesConf.GetResources(type));
 }
示例#4
0
 private GFResource[] GetResources()
 {
     return(m_ResourceCollection.GetResources());
 }