A named collection of Resources.
コード例 #1
0
ファイル: Library.cs プロジェクト: colin-dumitru/GLSharp
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private ResourceCollection LoadLibraryFromJson(Object json)
        {
            LibraryObject library = (LibraryObject)json;

            SystemCore.Logger.Log("Loading library : " + library.Name);

            ResourceCollection resourceCollection = null;

            /*test to see if library already exists*/
            if((resourceCollection = this._collections[library.Name]) == null) {
                resourceCollection = new ResourceCollection();
                resourceCollection.Name = library.Name;
                resourceCollection.Resources = new Dictionary<string, ResourceItem>();

                this._collections[resourceCollection.Name] = resourceCollection;
            }

            /*add the library object to the ResourceCollection*/
            this.AppendToCollection(resourceCollection, library.ContentObjects);

            return resourceCollection;
        }
コード例 #2
0
ファイル: Library.cs プロジェクト: colin-dumitru/GLSharp
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void AppendToCollection(ResourceCollection resourceCollection, List<ResourceObject> resources)
        {
            foreach (ResourceObject resourceObject in resources) {
                IResourceConverter converter = this._converters[resourceObject.Type];

                if(converter == null) {
                    SystemCore.Logger.Log("No resource converter found for type + " + resourceObject.Type);
                    continue;
                }

                /*convert the resource*/
                ResourceItem res = converter.Convert(resourceObject.Resource, resourceCollection.Name);

                res.Id = resourceObject.Id;
                res.Type = resourceObject.Type;

                /*add the converter object as a resource*/
                resourceCollection.Resources[res.Id] = res;
                /*add the item by it's id*/
                this._items[res.ItemId] = res;
            }
        }