Exemple #1
0
        private static void LoadMetaData(VSProject project)
        {
            string metaUrl = Path.Combine(project.metaFolderUrl, "projects.meta");

            cachedGuids = new Dictionary <string, Guid>();

            NjoxNode metaRoot;

            if (NjoxStatics.TryReadObjectFromFile(metaUrl, out metaRoot))
            {
                NjoxNode cachedGuidNode;
                if (metaRoot.TryGetFirstChild("cached_guids", out cachedGuidNode))
                {
                    foreach (NjoxNode node in cachedGuidNode.ChildNodes)
                    {
                        Guid guid;
                        if (Guid.TryParse(node.PrimaryProperty.Value, out guid))
                        {
                            cachedGuids[node.PrimaryProperty.Key.Replace("_%20_", " ")] = guid;
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Load all modules from current data
        /// </summary>
        private bool LoadAllModules()
        {
            modules = new Dictionary <string, ModuleContainer>();
            if (!LoadModulesFromDirectory(new DirectoryInfo(modulesDirectory), modules))
            {
                return(false);
            }


            // Load any meta-data
            NjoxNode collectionMeta;
            NjoxNode moduleMeta;

            if (!NjoxStatics.TryReadObjectFromFile(collectionMetaFileUrl, out collectionMeta))
            {
                // Create new empty meta data
                collectionMeta = new NjoxNode("meta");
                moduleMeta     = new NjoxNode("modules");
                collectionMeta.AddChild(moduleMeta);
            }
            else
            {
                // Create new modules object (Can't be found)
                if (!collectionMeta.TryGetFirstChild("modules", out moduleMeta))
                {
                    moduleMeta = new NjoxNode("modules");
                    collectionMeta.AddChild(moduleMeta);
                }
            }

            // Read in module info
            foreach (var pair in modules)
            {
                ModuleContainer module = pair.Value;
                module.collection = this;

                // Read in any stored info
                NjoxNode moduleInfo;

                if (moduleMeta.TryGetFirstChild(module.internalName, out moduleInfo))
                {
                    module.ReadMetaData(moduleInfo);
                }
                else
                {
                    moduleInfo = new NjoxNode(module.internalName);
                    moduleMeta.AddChild(moduleInfo);
                }

                // Update any changed info
                module.WriteMetaData(moduleInfo);
            }


            if (!NjoxStatics.TryWriteObjectToFile(collectionMetaFileUrl, collectionMeta))
            {
                Logger.LogWarning("Failed to write collection meta to file '" + collectionMetaFileUrl + "'");
            }

            return(true);
        }