Ejemplo n.º 1
0
        private static void WriteMetaData(VSProject project)
        {
            string metaUrl = Path.Combine(project.metaFolderUrl, "projects.meta");

            NjoxNode metaRoot = new NjoxNode("meta");
            NjoxNode cache    = new NjoxNode("cached_guids");

            foreach (var pair in cachedGuids)
            {
                cache.AddChild(new NjoxNode(pair.Key.Replace(" ", "_%20_"), pair.Value.ToString()));
            }

            metaRoot.AddChild(cache);
            NjoxStatics.TryWriteObjectToFile(metaUrl, metaRoot);
        }
Ejemplo n.º 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);
        }