Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        protected override void DoInitialize(bool isFullRestart)
        {
            lock (this)
            {
                if (isFullRestart)
                {
                    CloseAllDirectories();
                }
                else
                {
                    if (CurrentDirectory != null)
                    {
                        CurrentDirectory.Close();
                        luceneDirectoryIndexedByLanguageCodeThenView[CurrentLanguage].Remove(CurrentView);
                    }
                }

                if (!luceneDirectoryIndexedByLanguageCodeThenView.ContainsKey(CurrentLanguage))
                {
                    luceneDirectoryIndexedByLanguageCodeThenView.Add(CurrentLanguage, new Dictionary <string, Directory>());
                }

                luceneDirectoryIndexedByLanguageCodeThenView[CurrentLanguage].Add(CurrentView, GetInitialDirectory());
            }
        }
 private void DeleteFromCSV()
 {
     using (var file = new StreamWriter(CurrentDirectory.GetPythonAssetsDirectory(@"WideDeep\Prediction.csv")))
     {
         file.WriteLine(_predictionColumnNames);
     }
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     if (CurrentDirectory != null)
     {
         CurrentDirectory.Dispose();
     }
 }
Exemplo n.º 4
0
        public void ResolveNamespace()
        {
            var start     = CurrentDirectory.LastIndexOf(ProjectName);
            var nameSpace = CurrentDirectory.Substring(start).Replace('\\', '.').TrimEnd('.');

            this.textNamespace.Text = nameSpace;
        }
Exemplo n.º 5
0
        private void WebClientDownloadCompleted(object args, EventArgs e)
        {
            var directories = GetDirectories();

            CurrentDirectory.ExtractFiles(directories.CompressedImagesFileDir, directories.MNISTFileDir);
            CurrentDirectory.ExtractFiles(directories.CompressedLabelsFileDir, directories.MNISTFileDir);
        }
Exemplo n.º 6
0
        private void GetDirectoryStructure(string path, ScanMode mode)
        {
            try
            {
                foreach (string d in System.IO.Directory.GetDirectories(path))
                {
                    CurrentDirectory?.Invoke(path);
                    if (mode == ScanMode.AnalyseDirectoryStructure)
                    {
                        this.analyseDirectoryCount += 1;
                        UpdateDirectories?.Invoke(this.analyseDirectoryCount.ToString());
                    }
                    else
                    {
                        this.scanDirectoryCount += 1;
                        UpdateDirectories?.Invoke(this.scanDirectoryCount + " of " + this.analyseDirectoryCount);
                    }

                    GetFiles(d, mode);
                    GetDirectoryStructure(d, mode);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
            }
        }
Exemplo n.º 7
0
            internal static void post_PauseRegistrationList_InitList(PauseRegistrationList __instance)
            {
                if (v_prefabNode == null)
                {
                    v_prefabNode    = (GameObject)AccessTools.Field(typeof(PauseRegistrationList), "prefabNode").GetValue(__instance);
                    v_transformRoot = (Transform)AccessTools.Field(typeof(PauseRegistrationList), "transformRoot").GetValue(__instance);
                }

                var dirs = CurrentDirectory.GetDirectories();

                for (var i = dirs.Length - 1; i >= 0; i--)
                {
                    var subDir = dirs[i];
                    AddListButton($"[{subDir.Name}]", () =>
                    {
                        CurrentDirectory = subDir;
                        Traverse.Create(__instance).Method("InitList").GetValue();
                    }).SetAsFirstSibling();
                }
                var fn = CurrentDirectory.FullName;

                if (fn.Length > DefaultRootLength)
                {
                    AddListButton("..", () =>
                    {
                        CurrentDirectory = CurrentDirectory.Parent;
                        Traverse.Create(__instance).Method("InitList").GetValue();
                    }).SetAsFirstSibling();
                }
            }
Exemplo n.º 8
0
        public async Task <bool> Execute(Message message, TelegramBotClient client)
        {
            long chatId = message.Chat.Id;
            User user   = await _unitOfWork.UserAccessRepository.GetUserByChatId(chatId);

            if (user != null && user.isAuthorized)
            {
                LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id);

                if (linuxSystem != null)
                {
                    CurrentDirectory currentDirectory = await _unitOfWork.CurrentDirectoryRepository.GetByIdAsync(linuxSystem.CurrentDirectoryId);

                    if (currentDirectory != null)
                    {
                        Directory directory = await _unitOfWork.DirectoryRepository.GetByIdAsync(currentDirectory.DirectoryId);

                        await client.SendTextMessageAsync(chatId, $"<code>{directory.Path}</code>", ParseMode.Html);

                        return(true);
                    }

                    return(false);
                }

                return(false);
            }

            return(false);
        }
Exemplo n.º 9
0
        public virtual List <IBuildMetaData> GetAllPackageMetaData()
        {
            var metaDataList = new List <IBuildMetaData>();

            var reader = IoC.Resolve <IBuildConfigReader>();

            foreach (var buildFile in CurrentDirectory.GetFiles("*.boo"))
            {
                try
                {
                    var buildFileResolver = new BuildFileResolver().Resolve(CurrentDirectory, Path.GetFileNameWithoutExtension(buildFile.FullName));

                    var buildMetaData = reader.SetDslFactory(this).GetBuildMetaData(this, Path.GetFileNameWithoutExtension(buildFileResolver.BuildFile));

                    buildMetaData.Version = buildFileResolver.Version;

                    metaDataList.Add(buildMetaData);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }

            return(metaDataList);
        }
Exemplo n.º 10
0
        protected IList <string> GenerateReferencedIncludes()
        {
            var result = new List <string>();

            foreach (var reference in References)
            {
                var loadedReference = reference as CPlusPlusProject;

                if (loadedReference != null)
                {
                    result.AddRange(loadedReference.GenerateReferencedIncludes());
                }
            }

            foreach (var includePath in Includes.Where(i => i.Exported && !i.Global))
            {
                if (includePath.Value != string.Empty && includePath.Value != "./")
                {
                    result.Add(Path.Combine(CurrentDirectory, includePath.Value).ToPlatformPath());
                }
                else
                {
                    result.Add(CurrentDirectory.Substring(0, CurrentDirectory.Length - 1).ToPlatformPath());
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        public void UpdateItemIndependently_WhenNewItemNameIsNull_ReturnFalse(CurrentDirectory currentDirectory)
        {
            SetTestData(new Data());
            var result = dataService.UpdateItemIndependently("selectedItem", null, currentDirectory);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Dirty = false;
            MapData data = new MapData();
            // Tilemap
            string result = "";

            for (int i = 0; i < Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < Tiles.GetLength(1); j++)
                {
                    result += Tiles[i, j].TileID + "|";
                }
                result  = result.Substring(0, result.Length - 1);
                result += ";";
            }
            result     = result.Substring(0, result.Length - 1);
            data.Tiles = result;
            // Everything else
            data.Units       = Units;
            data.MapEvents   = melMapEvents.Datas;
            data.Tileset     = cmbTileSets.Text;
            data.LevelNumber = (int)nudLevelNumber.Value;
            data.Objective   = ObjectiveToString();
            data.Name        = txtLevelName.Text;
            CurrentDirectory.SaveFile(txtLevelName.Text, data.ToJson());
            flbFiles.UpdateList();
            VoiceAssist.Say("Save");
        }
Exemplo n.º 13
0
        private void LoadFile(string fileName)
        {
            if (HasUnsavedChanges())
            {
                return;
            }
            CurrentFile = fileName;
            MapData data = CurrentDirectory.LoadFile(txtLevelName.Text = fileName).JsonToObject <MapData>();

            Tiles = null;
            string[] rows = data.Tiles.Split(';');
            for (int i = 0; i < rows.Length; i++)
            {
                string[] row = rows[i].Split('|');
                if (Tiles == null)
                {
                    Tiles = new MapTile[rows.Length, row.Length];
                }
                for (int j = 0; j < row.Length; j++)
                {
                    Tiles[i, j]        = new MapTile();
                    Tiles[i, j].Pos    = new Point(i, j);
                    Tiles[i, j].TileID = int.Parse(row[j]);
                }
            }
            Units = data.Units;
            melMapEvents.Datas   = data.MapEvents;
            cmbTileSets.Text     = data.Tileset;
            nudLevelNumber.Value = data.LevelNumber;
            ObjectiveFromString(data.Objective);
            Render();
            UpdateUnitListBox();
            Dirty = false;
        }
Exemplo n.º 14
0
        public string Move(string name)
        {
            var old_path = CurrentPath;
            var sep      = Path.DirectorySeparatorChar;
            var path     = name.Replace(':', sep).Replace('/', sep);

            path = Path.GetFullPath(Path.Combine(CurrentPath, path));

            name = "";
            if (File.Exists(path))
            {
                name = Path.GetFileName(path);
                path = Path.GetDirectoryName(path);
            }
            if (!Directory.Exists(path))
            {
                return(null);
            }
            if (!path.StartsWith(RootDirectory))
            {
                return(null);
            }
            if (old_path != path)
            {
                CurrentDirectory = path.Replace(RootDirectory, "");
                if (CurrentDirectory.Length > 0 && CurrentDirectory[0] == sep)
                {
                    CurrentDirectory = CurrentDirectory.Remove(0, 1);
                }
                DirectoryWatcher.Path = CurrentPath;
                DirectoryWatcher.EnableRaisingEvents = true;
                DirectoryChanged?.Invoke(this, new WalkerEventArgs(old_path, path));
            }
            return(name);
        }
Exemplo n.º 15
0
        private static void PauseRegistrationList_InitList_Postfix(PauseRegistrationList __instance)
        {
            if (v_prefabNode == null)
            {
                v_prefabNode    = __instance.prefabNode;
                v_transformRoot = __instance.transformRoot;
            }

            var dirs = CurrentDirectory.GetDirectories();

            for (var i = dirs.Length - 1; i >= 0; i--)
            {
                var subDir = dirs[i];
                AddListButton($"[{subDir.Name}]", () =>
                {
                    CurrentDirectory = subDir;
                    __instance.InitList();
                }).SetAsFirstSibling();
            }
            var fn = CurrentDirectory.FullName;

            if (fn.Length > DefaultRootLength)
            {
                AddListButton("..", () =>
                {
                    CurrentDirectory = CurrentDirectory.Parent;
                    __instance.InitList();
                }).SetAsFirstSibling();
            }
        }
Exemplo n.º 16
0
        public static void Day2()
        {
            var filePath   = CurrentDirectory.ToString() + "/Day2/resources/input.txt";
            var lines      = System.IO.File.ReadAllLines(filePath);
            var intCode    = lines[0].Split(",").Select(int.Parse).ToList();
            var newIntCode = new List <int>(intCode);

            newIntCode[1] = 12;
            newIntCode[2] = 2;
            var processedIntCode = processIntCode(newIntCode, 0, 1);

            Console.WriteLine("Day 2, Problem 1: " + processedIntCode[0]);

            foreach (var noun in Enumerable.Range(0, 99))
            {
                foreach (var verb in Enumerable.Range(0, 99))
                {
                    newIntCode    = new List <int>(intCode);
                    newIntCode[1] = noun;
                    newIntCode[2] = verb;
                    var result = processIntCode(newIntCode, 0, 1)[0];
                    if (result == 19690720)
                    {
                        Console.WriteLine(
                            "Day 2, Problem 2:" +
                            " Noun: " + noun +
                            " Verb: " + verb +
                            " Result: " + result +
                            " Answer: " + ((100 * noun) + verb));
                    }
                }
            }
        }
Exemplo n.º 17
0
        public static void Day9()
        {
            var filePath = CurrentDirectory.ToString() + "/Day9/resources/input.txt";
            var lines    = System.IO.File.ReadAllLines(filePath);
            var intCode  = lines.First().Split(",").Select(long.Parse).ToList();

            var output = processIntCode(new List <long>(intCode), 0, new List <long>()
            {
                1
            }, new List <long>(), 0);

            Console.WriteLine("Day 9: Problem 1: " + String.Join(",", output));

            output = new List <long>();
            var thread =
                new Thread(
                    _ => processIntCode(new List <long>(intCode), 0, new List <long>()
            {
                2
            }, output, 0),
                    512000000); // ~ 128MB stack

            thread.Start();
            thread.Join();

            Console.WriteLine("Day 9: Problem 2: " + String.Join(",", output));
        }
Exemplo n.º 18
0
        private void DownloadDataset()
        {
            var webClient = new WebClient();

            webClient.UseDefaultCredentials  = true;
            webClient.DownloadDataCompleted += WebClientDownloadCompleted;

            var directories = GetDirectories();

            if (!CurrentDirectory.DirectoryExists(directories.MNISTFileDir))
            {
                CurrentDirectory.CreateNewDirectory(directories.MNISTFileDir);
            }

            if (!DatasetAlreadyExists(directories.MNISTFileDir))
            {
                try
                {
                    webClient.DownloadFile(_imagesDownloadLink, directories.CompressedImagesFileDir);
                    webClient.DownloadFile(_labelsDownloadLink, directories.CompressedLabelsFileDir);
                }
                catch (Exception e)
                {
                }
                finally
                {
                }
            }
        }
Exemplo n.º 19
0
        public void PostItemIndependently_WhenItemNameIsNull_ReturnFalse(CurrentDirectory currentDirectory)
        {
            SetTestData(new Data());
            var result = dataService.PostItemIndependently(null, currentDirectory);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 20
0
        void LoadSize()
        {
            textAreaWidth   = Font.MeasureString(CurrentDirectory.FullName).X;
            textAreaHeight  = Font.CharHeight;
            textAreaHeight += TextMargin * 2 + 1;

            foreach (DirectoryInfo d in CurrentDirectory.GetDirectories())
            {
                Point size = Font.MeasureString(d.Name);
                if (size.X > textAreaWidth)
                {
                    textAreaWidth = size.X;
                }

                textAreaHeight += Font.CharHeight + Font.VerticalSpace;
            }

            foreach (FileInfo f in fileList)
            {
                Point size = Font.MeasureString(f.Name);
                if (size.X + FolderSign.Width + TextMargin > textAreaWidth)
                {
                    textAreaWidth = size.X + FolderSign.Width + TextMargin;
                }

                textAreaHeight += Font.CharHeight + Font.VerticalSpace;
            }

            HScrollbar.Activated = textAreaWidth > selectorWidth;
            VScrollbar.Activated = textAreaHeight > selectorHeight;
            HScrollbar.Value     = 0;
            VScrollbar.Value     = 0;
        }
Exemplo n.º 21
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            //TextFormattedNumber();

            CurrentDirectory = Environment.CurrentDirectory;
            if (CurrentDirectory.Contains("Debug") || CurrentDirectory.Contains("Release"))
            {
                CurrentDirectory = Path.GetDirectoryName(CurrentDirectory);
            }
            if (CurrentDirectory.Contains("x64"))
            {
                CurrentDirectory = Path.GetDirectoryName(CurrentDirectory);
            }
            if (CurrentDirectory.Contains("bin"))
            {
                CurrentDirectory = Path.GetDirectoryName(CurrentDirectory);
            }

            CurrentDirectory = Path.GetDirectoryName(CurrentDirectory);
            CurrentDirectory = Path.Combine(CurrentDirectory, "Test");

            Loaded += OnLoaded;
        }
Exemplo n.º 22
0
        /// <summary>
        ///  Imports a less file and puts the root into the import node
        /// </summary>
        protected bool ImportLessFile(string lessPath, Import import)
        {
            string contents, file = null;

            if (IsEmbeddedResource(lessPath))
            {
                contents = ResourceLoader.GetResource(lessPath, FileReader, out file);
                if (contents == null)
                {
                    return(false);
                }
            }
            else
            {
                string fullName = lessPath;
                if (!string.IsNullOrEmpty(CurrentDirectory))
                {
                    fullName = CurrentDirectory.Replace(@"\", "/").TrimEnd('/') + '/' + lessPath;
                }

                bool fileExists = FileReader.DoesFileExist(fullName);
                if (!fileExists && !fullName.EndsWith(".less"))
                {
                    fullName  += ".less";
                    fileExists = FileReader.DoesFileExist(fullName);
                }

                if (!fileExists)
                {
                    return(false);
                }

                contents = FileReader.GetFileContents(fullName);

                file = fullName;
            }

            _paths.Add(Path.GetDirectoryName(import.Path));

            try
            {
                if (!string.IsNullOrEmpty(file))
                {
                    Imports.Add(file);
                }
                import.InnerRoot = Parser().Parse(contents, lessPath);
            }
            catch
            {
                Imports.Remove(file);
                throw;
            }
            finally
            {
                _paths.RemoveAt(_paths.Count - 1);
            }

            return(true);
        }
Exemplo n.º 23
0
 public void RemoveItem(ISolutionItem item)
 {
     if (item is IProject project)
     {
         Items.Remove(project);
         ProjectReferences.Remove(CurrentDirectory.MakeRelativePath(project.Location).ToAvalonPath());
     }
 }
Exemplo n.º 24
0
        public static void Day3()
        {
            var filePath     = CurrentDirectory.ToString() + "/Day3/resources/input.txt";
            var instructions = System.IO.File.ReadAllLines(filePath);
            var distance     = GetDistance(instructions.First(), instructions.Last());

            Console.WriteLine("Day 3: Problem 1 Answer: " + distance);
        }
Exemplo n.º 25
0
        public Directory GetDirectory(Path directoryPath)
        {
            var resolvedDirectoryPath = CurrentDirectory.Combine(directoryPath);
            var segments = resolvedDirectoryPath.Segments;
            var baseCase = GetFirstSegmentAsRootIfRooted(resolvedDirectoryPath, segments);

            return(segments.Skip(1).Aggregate(baseCase, (current, segment) => current.GetDirectory(segment)));
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            LinkedDictionary <String, ICommand> cmds    = new LinkedDictionary <String, ICommand>();
            IHandler <String, String[]>         handler = new StringHandler();

            CurrentDirectory dir = new CurrentDirectory()
            {
                CPath = System.IO.Directory.GetCurrentDirectory()
            };

            cmds.Add("change", new ChangeCommand(dir));
            cmds.Add("mkfile", new MkFileCommand(dir));
            cmds.Add("show", new ShowCommand(dir));
            cmds.Add("mkdir", new MkDirCommand(dir));
            cmds.Add("copy", new CopyCommand(dir));
            cmds.Add("s", new ShowCommand(dir));
            cmds.Add("help", new HelpCommand(GetCmds(cmds.Values)));


            Console.WriteLine("===Welcome to the ConsoleCommander===\nTo see available commands type help\n");
            while (true)
            {
                String c = Console.ReadLine();

                String[] A   = handler.Handle(c);//c.Split(new Char[]{'-',' ','='},StringSplitOptions.RemoveEmptyEntries);
                ICommand cmd = cmds[A[0]];
                if (A[0] == "change")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "mkfile")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "mkdir")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "show" || A[0] == "s")
                {
                    cmd.Execute(null);
                }
                else if (A[0] == "copy")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "help")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 27
0
 private void SaveExperimentResults(ObservableCollection <PerformanceIndicatorEntity> experimentResults)
 {
     using (var file = new StreamWriter(CurrentDirectory.GetAssetsDirectoryFolder(@"CSVFiles\ExperimentResults.csv")))
     {
         foreach (var experiment in experimentResults)
         {
             file.WriteLine(experiment.ToCSV());
         }
     }
 }
Exemplo n.º 28
0
        private void btnNewFolder_Click(object sender, EventArgs e)
        {
            string folderName = InputBox.Show("New folder", "Enter folder name:", this);

            if ((folderName ?? "") == "")
            {
                return;
            }
            CurrentDirectory.CreateDirectory(folderName);
            flbFiles.UpdateList();
        }
Exemplo n.º 29
0
        public string GetFileComment(string selectedItem, CurrentDirectory currentDirectory)
        {
            var data = ReadData();

            return(data
                   .PlayLists?
                   .FirstOrDefault(playList => playList.Name == currentDirectory.PlayList)?
                   .MediaFiles?
                   .FirstOrDefault(mediaFile => mediaFile.Name == selectedItem)?
                   .Comment);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Initializes the specified target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="args">The args.</param>
        public void Initialize(LogTargets target, string[] args)
        {
            CacheTargets(GetType().Assembly);
            CacheNodeTypes(GetType().Assembly);
            CacheVersion();

            m_CommandLine = new CommandLineCollection(args);

            string logFile = null;

            if (m_CommandLine.WasPassed("log"))
            {
                logFile = m_CommandLine["log"];

                if (logFile != null && logFile.Length == 0)
                {
                    logFile = "Prebuild.log";
                }
            }
            else
            {
                target = target & ~LogTargets.File;                     //dont output to a file
            }

            m_Log = new Log(target, logFile);
            LogBanner();

            m_CurrentWorkingDirectory = new CurrentDirectory();

            m_Target       = m_CommandLine["target"];
            m_Conditionals = m_CommandLine["conditionals"];
            if (m_CommandLine["targetframework"] != null)
            {
                m_TargetFramework      = (FrameworkVersion)Enum.Parse(typeof(FrameworkVersion), m_CommandLine["targetframework"]);
                cmdlineTargetFramework = true;
            }
            m_Clean = m_CommandLine["clean"];
            string removeDirs = m_CommandLine["removedir"];

            if (removeDirs != null && removeDirs.Length == 0)
            {
                m_RemoveDirectories = removeDirs.Split('|');
            }

            string flags = m_CommandLine["allowedgroups"];            //allows filtering by specifying a pipe-delimited list of groups to include

            if (flags != null && flags.Length == 0)
            {
                m_ProjectGroups = flags.Split('|');
            }
            m_PauseAfterFinish = m_CommandLine.WasPassed("pause");

            LoadSchema();
        }