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));
        }
示例#2
0
        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);
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        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();
            }
        }
示例#6
0
        /// <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);
        }
示例#7
0
        /// <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));
        }
示例#8
0
        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(_)));
        }
示例#9
0
        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();
        }
示例#10
0
        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(_));
        }
示例#11
0
        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();
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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;
        }
示例#15
0
        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);
        }
示例#16
0
        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));
        }
示例#17
0
 Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject)
 {
     return File.OpenRead(element.GetAbsoluteFileName(parentProject));
 }
示例#18
0
 void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream)
 {
     throw new NotImplementedException("Not implemented... yet!");
 }
示例#19
0
 public VB6Namespace(IVbProject parent)
 {
     _name = parent.Properties.Name;
 }
 public ViewModel(IVbProject project, VB6leapProjectOptionsPanel parent)
 {
     _project = project;
     _parent = parent;
 }
示例#21
0
 public ViewModel(IVbProject project, VB6leapProjectOptionsPanel parent)
 {
     _project = project;
     _parent  = parent;
 }
示例#22
0
 void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream)
 {
     throw new NotImplementedException("Not implemented... yet!");
 }
示例#23
0
 Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject)
 {
     return(File.OpenRead(element.GetAbsoluteFileName(parentProject)));
 }
示例#24
0
        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();
            }
        }
示例#25
0
 public VB6Namespace(IVbProject parent)
 {
     _name = parent.Properties.Name;
 }