StonehearthEditor.ModuleFile.Clone C# (CSharp) Method

Clone() public method

public Clone ( CloneObjectParameters parameters, HashSet alreadyCloned, bool execute ) : bool
parameters CloneObjectParameters
alreadyCloned HashSet
execute bool
return bool
        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 newPath = parameters.TransformParameter(ResolvedPath.Replace(sourceModName, targetModName));
            if (!FileData.Clone(newPath, parameters, alreadyCloned, execute))
            {
                return false;
            }

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

            return false;
        }

Usage Example

Exemplo n.º 1
0
        public HashSet <string> PreviewCloneDependencies(ModuleFile module, CloneObjectParameters cloneParameters)
        {
            HashSet <string> alreadyCloned = new HashSet <string>();

            module.Clone(cloneParameters, alreadyCloned, false);
            return(alreadyCloned);
        }
All Usage Examples Of StonehearthEditor.ModuleFile::Clone