/// <summary> /// Initializes a new instance of the <see cref="PathResolver"/> class. /// </summary> /// <param name="session">The session.</param> /// <param name="pathData">The path data.</param> /// <param name="controllerMapper">The controller mapper.</param> /// <param name="container">The container.</param> public PathResolver(IDocumentSession session, IPathData pathData, IControllerMapper controllerMapper, IContainer container) { _pathData = pathData; _controllerMapper = controllerMapper; _container = container; _session = session; }
/// <summary> /// Initializes a new instance of the <see cref="PathResolver"/> class. /// </summary> /// <param name="pathData">The path data.</param> /// <param name="repository">The repository.</param> /// <param name="controllerMapper">The controller mapper.</param> /// <param name="container">The container.</param> public PathResolver(IPathData pathData, IPageRepository repository, IControllerMapper controllerMapper, IContainer container) { _pathData = pathData; _repository = repository; _controllerMapper = controllerMapper; _container = container; }
/// <summary> /// Starts a new thread to handle path requests. /// </summary> public static void StartPathThread() { ThreadStart start = new ThreadStart(delegate { while (true) { if (pathQueue.Count > 0) { IPathData data = pathQueue.Dequeue(); Type type = data.Type; var method = typeof(AStar).GetMethod("GeneratePath", new Type[] { typeof(INode), typeof(INode), typeof(object), typeof(Action <string>) }).MakeGenericMethod(type); var path = method.Invoke(null, new object[] { data.Start, data.End, data.Agent, data.Debug }); data.Invoke(new Queue <INode>((path as IEnumerable).Cast <INode>())); } } }); new Thread(start).Start(); }
public DashboardPathResolver(IDocumentSession session, IPathData pathData, IControllerMapper controllerMapper) { _session = session; _pathData = pathData; _controllerMapper = controllerMapper; }
public LocalProxy(IPathData pathData) { //Read in students.json //dynamic studentsJSON = JsonConvert.DeserializeObject(File.ReadAllText(HttpContext.Current.Server.MapPath(filePath + "students.json"))); dynamic studentsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("students.json"))); foreach (var student in studentsJSON) { JObject modelJSON = student; this.studentsList.Add((Student)ModelFactory.createModelFromJson("student", modelJSON.ToString())); } //Read in instructor.json dynamic instructorsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("instructors.json"))); foreach (var instructor in instructorsJSON) { JObject modelJSON = instructor; this.instructorsList.Add((Instructor)ModelFactory.createModelFromJson("instructor", modelJSON.ToString())); } //Read in admins.json dynamic adminJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("admins.json"))); foreach (var admin in adminJSON) { JObject modelJSON = admin; this.adminsList.Add((Admin)ModelFactory.createModelFromJson("admin", modelJSON.ToString())); } //Read in courses.json dynamic coursesJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("courses.json"))); foreach (var course in coursesJSON) { List <int> prereqs = new List <int>(); foreach (var pre in course.prereqs) { int id = pre; prereqs.Add(id); } JObject modelJSON = course; Course newCourse = (Course)ModelFactory.createModelFromJson("course", modelJSON.ToString()); this.coursesList.Add(newCourse); this.prereqsInCourseDict.Add(newCourse.ID, prereqs); } //Read in sections.json dynamic sectionsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("sections.json"))); foreach (var section in sectionsJSON) { List <int> books = new List <int>(); foreach (var book in section.books) { int id = book; books.Add(id); } JObject modelJSON = section; Section newSection = (Section)ModelFactory.createModelFromJson("section", modelJSON.ToString()); this.sectionsList.Add(newSection); this.booksInSectionDict.Add(newSection.ID, books); } //Read in terms.json dynamic termsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("terms.json"))); foreach (var term in termsJSON) { JObject modelJSON = term; this.termsList.Add((Term)ModelFactory.createModelFromJson("term", modelJSON.ToString())); } //Read in locations.json dynamic locationsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("locations.json"))); foreach (var location in locationsJSON) { JObject modelJSON = location; this.locationsList.Add((Location)ModelFactory.createModelFromJson("location", modelJSON.ToString())); } //Read in books.json dynamic booksJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("books.json"))); foreach (var book in booksJSON) { JObject modelJSON = book; this.booksList.Add((Book)ModelFactory.createModelFromJson("book", modelJSON.ToString())); } //Create Reference Dictionaries dynamic students_sectionsJSON = JsonConvert.DeserializeObject(File.ReadAllText(pathData.GetPath("students_sections.json"))); foreach (var item in students_sectionsJSON) { int studentID = item.studentID; int sectionID = item.sectionID; if (sectionsInStudentDict.ContainsKey(studentID)) { sectionsInStudentDict[studentID].Add(sectionID); } else { sectionsInStudentDict.Add(studentID, new List <int> { sectionID }); } if (studentsInSectionDict.ContainsKey(sectionID)) { studentsInSectionDict[sectionID].Add(studentID); } else { studentsInSectionDict.Add(sectionID, new List <int> { studentID }); } } }
/// <summary> /// Initializes a new instance of the <see cref="PathResolver"/> class. /// </summary> /// <param name="pathData">The path data.</param> /// <param name="pageService">The page service facade.</param> /// <param name="controllerMapper">The controller mapper.</param> /// <param name="container">The container.</param> public PathResolver(IPathData pathData, IPageServiceFacade pageService, IControllerMapper controllerMapper) //, IContainer container { _pathData = pathData; _pageService = pageService; _controllerMapper = controllerMapper; //_container = container; }
public void DiffTextBlocks(string filePath, string leftContent, string rightContent, string title = null, IPathData data = null) { ThreadHelper.ThrowIfNotOnUIThread(); if (leftContent.IsNullOrWhiteSpace()) { leftContent = string.Empty; } if (rightContent.IsNullOrWhiteSpace()) { rightContent = string.Empty; } var filePath1 = CreateTempFileFromData(filePath, leftContent, "left", data); var filePath2 = CreateTempFileFromData(filePath, rightContent, "right", data); try { var diffService = (IVsDifferenceService)_serviceProvider.GetService(typeof(SVsDifferenceService)); Assumes.Present(diffService); string roles = null; var grfDiffOptions = __VSDIFFSERVICEOPTIONS.VSDIFFOPT_DetectBinaryFiles | __VSDIFFSERVICEOPTIONS.VSDIFFOPT_LeftFileIsTemporary | __VSDIFFSERVICEOPTIONS.VSDIFFOPT_RightFileIsTemporary; IVsWindowFrame frame; using (new NewDocumentStateScope(__VSNEWDOCUMENTSTATE.NDS_Provisional, VSConstants.NewDocumentStateReason.SolutionExplorer)) { frame = diffService.OpenComparisonWindow2( filePath1, filePath2, title ?? $"Your version vs Other version", filePath1 + Environment.NewLine + filePath2, filePath1, filePath2, null, roles, (uint)grfDiffOptions); } var diffViewer = GetDiffViewer(frame); diffViewer.Properties.AddProperty(PropertyNames.IsReviewDiff, true); diffViewer.ViewMode = DifferenceViewMode.SideBySide; //var leftText = diffViewer.LeftView.TextBuffer.CurrentSnapshot.GetText(); //var rightText = diffViewer.RightView.TextBuffer.CurrentSnapshot.GetText(); //if (leftText.Length == 0) { // diffViewer.ViewMode = DifferenceViewMode.RightViewOnly; //} //else if (rightText.Length == 0) { // diffViewer.ViewMode = DifferenceViewMode.LeftViewOnly; //} //else if (leftText == rightText) { // diffViewer.ViewMode = DifferenceViewMode.RightViewOnly; //} } catch (Exception ex) { Log.Error(ex, nameof(DiffTextBlocks)); } finally { RemoveTempFileSafe(filePath1); RemoveTempFileSafe(filePath2); } }
private string CreateTempFileFromData(string filePath, string content, string direction, IPathData data = null) { List <string> parts = data?.PathParts.AnySafe() == true ? data.PathParts : new List <string>(); var pathParts = parts.Concat(new List <string>() { direction, "codestream-diff" }); var path = Path.Combine(Path.GetTempPath(), "codestream", "vs", "codestream-diff"); path = Path.Combine((new string[] { path }).Concat(pathParts).ToArray()); path = Path.Combine(path, Path.GetDirectoryName(filePath)); Directory.CreateDirectory(path); path = Path.Combine(path, Path.GetFileName(filePath)); System.IO.File.WriteAllText(path, content.NormalizeLineEndings(), Encoding.UTF8); return(path); }
public FileController(IConfiguration config, IFyleData fileData, IPathData pathData) { this.config = config; this.fileData = fileData; this.pathData = pathData; }
public FileService(IConfiguration config, IFyleData fyleData, IPathData pathData) { this.config = config; this.fyleData = fyleData; this.pathData = pathData; }