TryLoad() public method

public TryLoad ( ) : void
return void
Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
        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;
        }