Пример #1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public Resource GetResource(string resource, ResourceManagerParams managerParams)
        {
            if(managerParams == null)
                managerParams = new ResourceManagerParams();

            /*get the extension*/
            if (managerParams.Type == null) {
                int lastPeriod = resource.LastIndexOf('.');
                managerParams.Type = "";
                if (lastPeriod > -1) managerParams.Type = (resource.Substring(lastPeriod + 1, resource.Length));
            }

            managerParams.Type = managerParams.Type.ToLowerCase();

            /*try to load the resource*/
            IResourceLoader loader = this._loaders[managerParams.Type];

            if (loader == null)
                throw new Exception("The specified resource is unsuppoted");

            return loader.Load(this.RootUrl + resource);
        }
Пример #2
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public LibraryResult LoadLibrary(String url)
        {
            ResourceManagerParams param = new ResourceManagerParams();
            LibraryResult ret = new LibraryResult();
            Library that = this;

            param.Type = "json";

            SystemCore.ResourceManager.GetResource(url, param).ResourceChanged.Subscribe(
                delegate(Object sender, object args) {
                    Resource resource = (Resource) sender;

                    if (resource.Finished) {
                        ResourceCollection res = this.LoadLibraryFromJson(resource.Data);

                        ret.Finished.Fire(this, res);
                    }
                }, true);

            return ret;
        }