Exemple #1
0
        /**
         * Return the dependency lookup for Objects using the ObjectDependencyResolver
         */
        public static void BuildDefaultAssetLookup(NodeDependencyLookupContext stateContext, bool loadFromCache,
                                                   string savePath,
                                                   ProgressBase progress)
        {
            ResolverUsageDefinitionList usageDefinitionList = new ResolverUsageDefinitionList();

            usageDefinitionList.Add <AssetDependencyCache, ObjectSerializedDependencyResolver>();

            LoadDependencyLookupForCaches(stateContext, usageDefinitionList, progress, loadFromCache, true, false,
                                          savePath);
        }
Exemple #2
0
        public static void LoadDependencyLookupForCaches(NodeDependencyLookupContext stateContext,
                                                         ResolverUsageDefinitionList resolverUsageDefinitionList, ProgressBase progress, bool loadCache = true,
                                                         bool updateCache = true, bool saveCache = true, string fileDirectory = DEFAULT_CACHE_SAVE_PATH)
        {
            stateContext.UpdateFromDefinition(resolverUsageDefinitionList);

            List <CreatedDependencyCache> caches = stateContext.GetCaches();

            foreach (CreatedDependencyCache cacheUsage in caches)
            {
                if (cacheUsage.ResolverUsages.Count == 0)
                {
                    continue;
                }

                IDependencyCache cache = cacheUsage.Cache;

                if (loadCache && !cacheUsage.IsLoaded)
                {
                    cache.Load(fileDirectory);
                    cacheUsage.IsLoaded = true;
                }

                if (updateCache && cache.NeedsUpdate(progress))
                {
                    if (cache.CanUpdate())
                    {
                        cache.Update(progress);

                        if (saveCache)
                        {
                            cache.Save(fileDirectory);
                        }
                    }
                    else
                    {
                        Debug.LogErrorFormat("{0} could not be updated", cache.GetType().FullName);
                    }
                }
            }

            RelationLookup.RelationsLookup lookup = new RelationLookup.RelationsLookup();
            lookup.Build(caches);

            stateContext.RelationsLookup = lookup;
        }
Exemple #3
0
        public void UpdateFromDefinition(ResolverUsageDefinitionList definitionList)
        {
            ResetCacheUsages();

            foreach (ResolverUsageDefinitionList.Entry entry in definitionList.CacheUsages)
            {
                string cacheTypeFullName = entry.CacheType.FullName;

                if (!CreatedCaches.ContainsKey(cacheTypeFullName))
                {
                    IDependencyCache       cache        = NodeDependencyLookupUtility.InstantiateClass <IDependencyCache>(entry.CacheType);
                    CreatedDependencyCache createdCache = new CreatedDependencyCache(cache);

                    CreatedCaches.Add(cacheTypeFullName, createdCache);
                }

                CreatedCaches[cacheTypeFullName].AddResolver(entry.ResolverType, entry.ConnectionTypes);
            }

            ConnectionTypeLookup = new ConnectionTypeLookup(GetCaches());
            NodeHandlerLookup    = NodeDependencyLookupUtility.BuildNodeHandlerLookup();
        }