Esempio n. 1
0
        ///<summary>
        ///</summary>
        public void SaveFileTreeStatus(ProjectFileTree model, string savePath)
        {
            string folderPath  = GetTempFilePathForComponent(ComponentKey.Workbench_Scratch);
            string xmlFilename = Path.Combine(folderPath, "filetree.xml");

            if (Directory.Exists(folderPath) == false)
            {
                Directory.CreateDirectory(folderPath);
            }

            File.Create(xmlFilename).Close();
            XmlDocument document = model.WriteIntelliMergeAndEnableStatusToXml();

            document.Save(xmlFilename);

            if (!string.IsNullOrEmpty(savePath))
            {
                Slyce.Common.Utility.DeleteFileBrute(savePath);

                var savePathDir = Path.GetDirectoryName(savePath);

                if (!Directory.Exists(savePathDir))
                {
                    Directory.CreateDirectory(savePathDir);
                }

                File.Copy(xmlFilename, savePath);
            }
        }
Esempio n. 2
0
 private Controller()
 {
     CurrentProject = new WorkbenchProject();
     Interfaces.Events.DataChangedEvent += On_DataChanged;
     OnProjectLoaded += Project_OnProjectLoaded;
     projectFileTreeModel = new ProjectFileTree();
     //InitializeSettings();
 }
        public void TestGenerateAllFiles_Folder_Sub_File()
        {
            IFile staticFile = mocks.DynamicMock<IFile>();
            IScript scriptFile = mocks.DynamicMock<IScript>();
            IFolder subFolder = mocks.DynamicMock<IFolder>();
            ProviderInfo providerMock = mocks.DynamicMock<ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(subFolder, new IFolder[0], new[] { scriptFile }, new[] { staticFile }, "folder");
                SetupFolder(folder, new[]{subFolder}, new IScript[0], new IFile[0], "");
                SetupProject();
                SetupStaticFile(staticFile);
                SetupScriptFile(scriptFile);
                SetupProvider(providerMock);
                SetupController();
                SetupLoader(scriptFile);
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                    "Class.cs", "C:\\Temp\\folder\\Class.cs", "folder\\Class.cs", "Class", "Iterator")));
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                    "file.jpg", "C:\\Temp\\folder\\file.jpg", "folder\\file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree tree = new ProjectFileTree();
            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(3));
            ProjectFileTreeNode subfolder = tree.ChildNodes[0];

            Assert.That(subfolder.Status, Is.EqualTo(ProjectFileStatusEnum.Folder));
            Assert.That(subfolder.Text, Is.EqualTo("folder"));
            Assert.That(subfolder.ChildNodes.Count, Is.EqualTo(2));

            ProjectFileTreeNode childNode = subfolder.ChildNodes[0];
            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("Class.cs"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "Class.cs")));
            TextFileInformation tfi = (TextFileInformation)childNode.AssociatedFile;
            Assert.That(tfi.NewGenFile.FilePath,
                Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                "New Gen file was not assigned to");

            childNode = subfolder.ChildNodes[1];
            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("file.jpg"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "file.jpg")));
            BinaryFileInformation bfi = (BinaryFileInformation)childNode.AssociatedFile;
            Assert.That(bfi.NewGenFile.FilePath,
                Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                "New Gen file was not assigned to");

            mocks.VerifyAll();
        }
Esempio n. 4
0
 internal ProjectFileTreeNode(ProjectFileTreeNode parentNode, ProjectFileTree parentTree)
 {
     this.parentNode = parentNode;
     this.parentTree = parentTree;
 }
Esempio n. 5
0
 public void SaveFileTreeStatus(ProjectFileTree model)
 {
     SaveFileTreeStatus(model, "");
 }
        public void TestGenerateAllFiles_Static_File()
        {
            IFile file = mocks.DynamicMock<IFile>();
            ProviderInfo providerMock = mocks.DynamicMock<ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(folder, new IFolder[0],  new IScript[0], new[] { file }, "");
                SetupProject();
                SetupLoader();
                SetupStaticFile(file);
                SetupProvider(providerMock);
                SetupController();
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                    "file.jpg", "C:\\Temp\\file.jpg", "file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree tree = new ProjectFileTree();
            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(1));
            Assert.That(tree.AllNodes[0].Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(tree.AllNodes[0].Text, Is.EqualTo("file.jpg"));
            Assert.That(tree.ChildNodes[0].AssociatedFile.RelativeFilePath, Is.EqualTo("file.jpg"));
            BinaryFileInformation bfi = (BinaryFileInformation)tree.ChildNodes[0].AssociatedFile;
            Assert.That(bfi.NewGenFile.FilePath,
                Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), tree.ChildNodes[0].AssociatedFile.RelativeFilePath)),
                "New Gen file was not assigned to");
            mocks.VerifyAll();
        }
        public void TestGenerateAllFiles_No_Files()
        {
            using(mocks.Record())
            {
                SetupFolder(folder, new IFolder[0],  new IScript[0], new IFile[0], "");
                SetupProject();
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, new FileController());
            ProjectFileTree tree = new ProjectFileTree();
            helper.GenerateAllFiles("fasdkj", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes, Is.Empty);
        }
        ///<summary>
        ///</summary>
        public void SaveFileTreeStatus(ProjectFileTree model, string savePath)
        {
            string folderPath = GetTempFilePathForComponent(ComponentKey.Workbench_Scratch);
            string xmlFilename = Path.Combine(folderPath, "filetree.xml");

            if (Directory.Exists(folderPath) == false)
                Directory.CreateDirectory(folderPath);

            File.Create(xmlFilename).Close();
            XmlDocument document = model.WriteIntelliMergeAndEnableStatusToXml();
            document.Save(xmlFilename);

            if (!string.IsNullOrEmpty(savePath))
            {
                Slyce.Common.Utility.DeleteFileBrute(savePath);

                var savePathDir = Path.GetDirectoryName(savePath);

                if (!Directory.Exists(savePathDir))
                    Directory.CreateDirectory(savePathDir);

                File.Copy(xmlFilename, savePath);
            }
        }
 public void SaveFileTreeStatus(ProjectFileTree model)
 {
     SaveFileTreeStatus(model, "");
 }
Esempio n. 10
0
        ///<summary>
        ///</summary>
        public void LoadFileTreeStatus(ProjectFileTree model)
        {
            string xmlFilename = Path.Combine(GetTempFilePathForComponent(ComponentKey.Workbench_Scratch), "filetree.xml");

            if (!File.Exists(xmlFilename))
            {
                string dir = Path.GetDirectoryName(xmlFilename);

                if (!Directory.Exists(dir))
                    Directory.CreateDirectory(dir);

                if (CurrentProject != null && !string.IsNullOrEmpty(CurrentProject.AppConfigFilename))
                {
                    string path = Path.GetDirectoryName(CurrentProject.AppConfigFilename).PathSlash("filetree.xml");

                    if (File.Exists(path))
                        File.Copy(path, xmlFilename);
                }
            }
            if (File.Exists(xmlFilename))
            {
                XmlDocument document = new XmlDocument();
                document.Load(xmlFilename);
                try
                {
                    model.LoadCheckedStatusFromXml(document);
                }
                catch (ArgumentException)
                {
                    // Ignore the file - it is malformed. It will be overwritten when the user saves anyway.
                }
            }
        }
Esempio n. 11
0
 internal ProjectFileTreeNode(ProjectFileTreeNode parentNode, ProjectFileTree parentTree)
 {
     this.parentNode = parentNode;
     this.parentTree = parentTree;
 }