ElementBase IVbElementSerializer.Deserialize(string content, IVbProject project) { string kind = content.Substring(0, content.IndexOf('=')); string value = content.Remove(0, kind.Length + 1); switch (kind) { case "Reference": return(_referenceParser.Parse(value)); case "Object": return(ParseObject(value)); case "Module": return(ParseModule(value)); case "Class": return(ParseClass(value)); case "Form": return(ParseForm(value)); case "UserControl": return(ParseUserControl(value)); } throw new NotSupportedException(string.Format("Kind '{0}' is not supported!", kind)); }
internal static IEnumerable <ElementBase> GetAllElements(this IVbProject project) { List <ElementBase> elements = new List <ElementBase>(); elements.AddRange(project.References); elements.AddRange(project.Modules); elements.AddRange(project.Objects); elements.AddRange(project.Classes); elements.AddRange(project.Forms); elements.AddRange(project.UserControls); return(elements); }
internal static void RunProject(IVbProject project) { string arguments = string.Format("/run \"{0}\"", project.Source.FullName); using (Process process = new Process()) { process.StartInfo.FileName = GetVB6Path(); process.StartInfo.Arguments = arguments; process.Start(); process.WaitForExit(); } }
private void btnOpenProject_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Properties.Resources.Vb6ProjectFileFilter; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileInfo fileToParse = new FileInfo(ofd.FileName); IVbProjectReader parser = new Vb6ProjectReader(); using (Stream stream = fileToParse.OpenRead()) { _project = parser.Read(fileToParse, stream); } Dictionary <string, IEnumerable <ElementBase> > map = new Dictionary <string, IEnumerable <ElementBase> >(); map["REFERENCES"] = _project.References; map["MODULES"] = _project.Modules; map["CLASSES"] = _project.Classes; map["FORMS"] = _project.Forms; map["OBJECTS"] = _project.Objects; foreach (var mapItem in map) { TreeNode node = trvProject.Nodes[0].Nodes[mapItem.Key]; node.Nodes.Clear(); foreach (var item in mapItem.Value.OrderBy(_ => _.Name)) { TreeNode itemNode = new TreeNode(); if (!string.IsNullOrWhiteSpace(item.Name)) { itemNode.Text = item.Name; } else { itemNode.Text = item.FileName; } itemNode.Tag = item; ExtendNode(item, itemNode); node.Nodes.Add(itemNode); } } trvProject.Nodes[0].Nodes["MODULES"].Expand(); trvProject.Nodes[0].Nodes["CLASSES"].Expand(); trvProject.Nodes[0].Nodes["FORMS"].Expand(); } }
/// <summary> /// Returns the absolute path to the underlying file. /// </summary> /// <param name="project">The <see cref="IVbProject"/> instance used for retrieving the full path (if the file path is relative).</param> /// <returns>The absolute path to the underlying file.</returns> public string GetAbsoluteFileName(IVbProject project) { if (project == null) { throw new ArgumentNullException("project"); } if (Path.IsPathRooted(this.FileName)) { return this.FileName; } return Path.Combine(project.Source.DirectoryName, this.FileName); }
/// <summary> /// Returns the absolute path to the underlying file. /// </summary> /// <param name="project">The <see cref="IVbProject"/> instance used for retrieving the full path (if the file path is relative).</param> /// <returns>The absolute path to the underlying file.</returns> public string GetAbsoluteFileName(IVbProject project) { if (project == null) { throw new ArgumentNullException("project"); } if (Path.IsPathRooted(this.FileName)) { return(this.FileName); } return(Path.Combine(project.Source.DirectoryName, this.FileName)); }
private static IEnumerable <string> MakeProjectCore(IVbProject project) { string outFilePath = Path.GetTempFileName(); string arguments = string.Format("/make \"{0}\" /out \"{1}\"", project.Source.FullName, outFilePath); using (Process process = new Process()) { process.StartInfo.FileName = GetVB6Path(); process.StartInfo.Arguments = arguments; process.Start(); process.WaitForExit(); } return(File.ReadAllLines(outFilePath).Where(_ => !string.IsNullOrWhiteSpace(_))); }
void IVbProjectWriter.Write(IVbProject project, Stream stream) { StreamWriter writer = new StreamWriter(stream); foreach (ElementBase element in project.GetAllElements()) { writer.WriteLine(_serializer.Serialize(element)); } foreach (string key in project.Properties) { writer.WriteLine("{0}={1}", key, project.Properties.Get(key, "")); } writer.Flush(); }
private static IEnumerable<string> MakeProjectCore(IVbProject project) { string outFilePath = Path.GetTempFileName(); string arguments = string.Format("/make \"{0}\" /out \"{1}\"", project.Source.FullName, outFilePath); using (Process process = new Process()) { process.StartInfo.FileName = GetVB6Path(); process.StartInfo.Arguments = arguments; process.Start(); process.WaitForExit(); } return File.ReadAllLines(outFilePath).Where(_ => !string.IsNullOrWhiteSpace(_)); }
public VbpProject(ProjectLoadInformation info) : base(info) { _projectReader = new Vb6ProjectReader(); _projectWriter = new Vb6ProjectWriter(); FileInfo file = new FileInfo(info.FileName); using (Stream stream = file.OpenRead()) { _vbProject = _projectReader.Read(file, stream); } AddGenericItems(); AddReferences(); _symbolCache = VbpProjectSymbolCache.FromProject(this); }
internal static MakeResult MakeProject(IVbProject project) { MakeResult result = new MakeResult(); try { result.Results = MakeProjectCore(project).ToArray(); // HACK: This is not too good. Should be refactored. if (result.Results.Length == 1 && result.Results[0].ToLowerInvariant().Contains("succeeded")) { result.Results = new string[0]; } } catch (Exception ex) { result.Results = new string[] { ex.Message }; } return result; }
internal static MakeResult MakeProject(IVbProject project) { MakeResult result = new MakeResult(); try { result.Results = MakeProjectCore(project).ToArray(); // HACK: This is not too good. Should be refactored. if (result.Results.Length == 1 && result.Results[0].ToLowerInvariant().Contains("succeeded")) { result.Results = new string[0]; } } catch (Exception ex) { result.Results = new string[] { ex.Message }; } return(result); }
ElementBase IVbElementSerializer.Deserialize(string content, IVbProject project) { string kind = content.Substring(0, content.IndexOf('=')); string value = content.Remove(0, kind.Length + 1); switch (kind) { case "Reference": return _referenceParser.Parse(value); case "Object": return ParseObject(value); case "Module": return ParseModule(value); case "Class": return ParseClass(value); case "Form": return ParseForm(value); case "UserControl": return ParseUserControl(value); } throw new NotSupportedException(string.Format("Kind '{0}' is not supported!", kind)); }
Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject) { return File.OpenRead(element.GetAbsoluteFileName(parentProject)); }
void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream) { throw new NotImplementedException("Not implemented... yet!"); }
public VB6Namespace(IVbProject parent) { _name = parent.Properties.Name; }
public ViewModel(IVbProject project, VB6leapProjectOptionsPanel parent) { _project = project; _parent = parent; }
Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject) { return(File.OpenRead(element.GetAbsoluteFileName(parentProject))); }
private void btnOpenProject_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Properties.Resources.Vb6ProjectFileFilter; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileInfo fileToParse = new FileInfo(ofd.FileName); IVbProjectReader parser = new Vb6ProjectReader(); using (Stream stream = fileToParse.OpenRead()) { _project = parser.Read(fileToParse, stream); } Dictionary<string, IEnumerable<ElementBase>> map = new Dictionary<string, IEnumerable<ElementBase>>(); map["REFERENCES"] = _project.References; map["MODULES"] = _project.Modules; map["CLASSES"] = _project.Classes; map["FORMS"] = _project.Forms; map["OBJECTS"] = _project.Objects; foreach (var mapItem in map) { TreeNode node = trvProject.Nodes[0].Nodes[mapItem.Key]; node.Nodes.Clear(); foreach (var item in mapItem.Value.OrderBy(_ => _.Name)) { TreeNode itemNode = new TreeNode(); if (!string.IsNullOrWhiteSpace(item.Name)) { itemNode.Text = item.Name; } else { itemNode.Text = item.FileName; } itemNode.Tag = item; ExtendNode(item, itemNode); node.Nodes.Add(itemNode); } } trvProject.Nodes[0].Nodes["MODULES"].Expand(); trvProject.Nodes[0].Nodes["CLASSES"].Expand(); trvProject.Nodes[0].Nodes["FORMS"].Expand(); } }