public static ProjectFileDto FromViewModelToModel(ProjectFileViewModel viewModel)
 {
     var model = new ProjectFileDto();
     model.Id = viewModel.Id;
     model.ProjectId = viewModel.ProjectId;
     model.Name = viewModel.Name;
     model.LastModified = viewModel.LastModified;
     model.Content = viewModel.Content;
     return model;
 }
 public static ProjectFileViewModel FromModelToViewModel(ProjectFileDto model)
 {
     var vm = new ProjectFileViewModel();
     vm.Id = model.Id;
     vm.ProjectId = model.ProjectId;
     vm.Name = model.Name;
     vm.LastModified = model.LastModified;
     vm.Content = model.Content;
     return vm;
 }
        public static ProjectFileDto FromViewModelToModel(ProjectFileViewModel viewModel)
        {
            var model = new ProjectFileDto();

            model.Id           = viewModel.Id;
            model.ProjectId    = viewModel.ProjectId;
            model.Name         = viewModel.Name;
            model.LastModified = viewModel.LastModified;
            model.Content      = viewModel.Content;
            return(model);
        }
        public static ProjectFileViewModel FromModelToViewModel(ProjectFileDto model)
        {
            var vm = new ProjectFileViewModel();

            vm.Id           = model.Id;
            vm.ProjectId    = model.ProjectId;
            vm.Name         = model.Name;
            vm.LastModified = model.LastModified;
            vm.Content      = model.Content;
            return(vm);
        }
        /// <summary>
        /// try to convert the content index to a line and column
        /// </summary>
        /// <param name="fileVm"></param>
        /// <param name="caretIndex"></param>
        private void ResolveLineAndColumnPositionInFileFromCaretIndex(ProjectFileViewModel fileVm)
        {
            int caretIndex = fileVm.CaretIndex;
            var contentParts = fileVm.Content.Split(new[] { "\r\n" }, StringSplitOptions.None);
            int newStart = 0;
            bool done = false;
            for (int line = 0; line < contentParts.Length && !done; line++)
            {
                string lineContent = contentParts[line];
                int start = newStart;
                int end = newStart + lineContent.Length;
                if (caretIndex >= start && caretIndex <= end)
                {
                    fileVm.CaretLine = line + 1;
                    fileVm.CaretColumn = caretIndex - start + 1;
                    done = true;
                }
                newStart = end + 2;
            }

            fileVm.CaretLocation = string.Format("line {0}, col {1}", fileVm.CaretLine, fileVm.CaretColumn);
        }
        private void ParseFile()
        {
            if (Dispatcher != null && !Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)ParseFile);
                return;
            }

            ProjectFileViewModel fileToParse = _fileToParse;

            #region Do Parsing and other stuff...

            //Logger.AppendLine("this is where we will parse file {0}...", fileToParse.Name);
            //ParseFile(fileToParse);

            #endregion

            // if the preconditions for this method invocation still hold true, then clear the file to parse ref to indicate that we've parse the file.
            if (fileToParse == _fileToParse && DateTime.Now > _timeAtWhichToParse)
                _fileToParse = null;
        }