WriteManifestToFile() public method

public WriteManifestToFile ( ) : void
return void
Exemplo n.º 1
0
        private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label != null && e.Label.Length > 0)
            {
                FileData        fileData       = e.Node.Tag as FileData;
                IModuleFileData moduleFileData = e.Node.Tag as IModuleFileData;
                ModuleFile      moduleFile     = moduleFileData.GetModuleFile();
                string          oldAlias       = moduleFile.FullAlias;
                Module          mod            = moduleFile.Module;
                string          newAlias       = mod.Name + ":" + e.Label;

                // Update the references to use the new alias.
                foreach (FileData reference in fileData.ReferencedByFileData.Values)
                {
                    if (reference.FlatFileData != null)
                    {
                        string updatedFlatFile = reference.FlatFileData.Replace(oldAlias, newAlias);
                        reference.TrySetFlatFileData(updatedFlatFile);
                        reference.TrySaveFile();
                    }
                }

                mod.AddToManifest(e.Label, moduleFile.OriginalPath);
                mod.RemoveFromManifest("aliases", moduleFile.Alias);
                mod.WriteManifestToFile();
                Reload();
            }
            else
            {
                e.CancelEdit = true;
            }
        }
Exemplo n.º 2
0
        public bool Clone(CloneObjectParameters parameters, HashSet <string> alreadyCloned, bool execute)
        {
            string newAlias      = parameters.TransformAlias(mAlias);
            string sourceModName = Module.Name;
            string targetModName = parameters.TargetModule == null ? sourceModName : parameters.TargetModule;
            Module targetModule  = ModuleDataManager.GetInstance().GetMod(targetModName);

            if (targetModule.GetAliasFile(newAlias) != null)
            {
                // MessageBox.Show("The alias " + newAlias + " already exists in manifest.json");
                return(false);
            }

            string modPath      = targetModule.ParentDirectory;
            string relativePath = ResolvedPath.Replace(mModule.Path + "/", "");
            string newPath      = parameters.TransformParameter(relativePath);
            string fullPath     = modPath + "/" + targetModName + "/" + newPath;

            if (!FileData.Clone(fullPath, parameters, alreadyCloned, execute))
            {
                return(false);
            }

            alreadyCloned.Add(targetModName + ':' + newAlias);
            if (execute)
            {
                string     fileLocation = "file(" + newPath + ")";
                ModuleFile file         = new ModuleFile(targetModule, newAlias, fileLocation);
                file.TryLoad();
                if (file.FileData != null)
                {
                    targetModule.AddToManifest(newAlias, fileLocation, parameters.manifestEntryType);
                    targetModule.WriteManifestToFile();
                    return(true);
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
            public bool OnAccept(string inputMessage)
            {
                // Do the cloning
                string newAliasName = inputMessage.Trim();

                if (newAliasName.Length <= 1)
                {
                    MessageBox.Show("You must enter a name longer than 1 character for the new alias!");
                    return(false);
                }

                if (mModule.GetAliasFile(newAliasName) != null)
                {
                    MessageBox.Show("An alias already exists with that name!");
                    return(false);
                }

                mModule.AddToManifest(newAliasName, "file(" + mFilePath + ")", mManifestEntryType);
                mModule.WriteManifestToFile();
                mOwner.Reload();
                return(true);
            }
Exemplo n.º 4
0
        public bool Clone(CloneObjectParameters parameters, HashSet <string> alreadyCloned, bool execute)
        {
            string newAlias = parameters.TransformAlias(mAlias);

            if (mModule.GetAliasFile(newAlias) != null)
            {
                // MessageBox.Show("The alias " + newAlias + " already exists in manifest.json");
                return(false);
            }

            string newPath = parameters.TransformParameter(ResolvedPath);

            if (!FileData.Clone(newPath, parameters, alreadyCloned, execute))
            {
                return(false);
            }

            alreadyCloned.Add(mModule.Name + ':' + newAlias);
            if (execute)
            {
                string     fileLocation = "file(" + newPath.Replace(mModule.Path + "/", "") + ")";
                ModuleFile file         = new ModuleFile(Module, newAlias, fileLocation);
                file.TryLoad();
                if (file.FileData != null)
                {
                    mModule.AddToManifest(newAlias, fileLocation);
                    mModule.WriteManifestToFile();
                    return(true);
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }