public static void CreateSolution(COMComponentReader reader, string directory)
        {
            XmlNode solutionNode   = reader.COMTree.SelectSingleNode(Constants.Solution);
            string  solutionName   = solutionNode.Attributes["Name"].InnerText;
            string  solutionPrefix = solutionNode.Attributes["Prefix"].InnerText;

            #region Directory

            string rootPath = Path.Combine(directory, solutionName);
            if (Directory.Exists(directory) == false)
            {
                Directory.CreateDirectory(directory);
            }

            if (Directory.Exists(rootPath) == true)
            {
                Directory.Delete(rootPath, true);
            }
            Directory.CreateDirectory(rootPath);

            #endregion

            string solutionFile = ReadTextFileFromRessource("Solution.sln");
            solutionFile = solutionFile.Replace("%SolutionName%", solutionName);

            string projectString = "";
            foreach (XmlNode projectNode in solutionNode.ChildNodes)
            {
                #region Project

                string projectName = projectNode.Attributes["ProjectName"].InnerText;
                if (false == Directory.Exists(Path.Combine(rootPath, projectName)))
                {
                    Directory.CreateDirectory(Path.Combine(rootPath, projectName));
                }
                projectString += GetProjectEntryInSolution(projectName);
                string projectDirectory = CreateProjectDirectory(rootPath, projectName);
                string projectFile      = CreateProjectFile(projectName);
                CreateFile("VS2008ProjectTemplate.AssemblyInfo.cs", Path.Combine(projectDirectory, "AssemblyInfo.cs"), projectName);

                #endregion

                XmlNode enumsNode    = projectNode.SelectSingleNode("Enums");
                string  enumsInclude = EnumGenerator.ConvertEnumsToFiles(projectDirectory, projectName, enumsNode);
                projectFile = projectFile.Replace("%EnumIncludes%", enumsInclude);

                XmlNode dispatchesNode    = projectNode.SelectSingleNode("DispatchInterfaces");
                string  dispatchesInclude = DispatchGenerator.ConvertDispatchesToFiles(projectDirectory, projectName, solutionPrefix, dispatchesNode);
                projectFile = projectFile.Replace("%DispatchIncludes%", dispatchesInclude);

                File.AppendAllText(Path.Combine(rootPath, projectName + "\\" + projectName + ".csproj"), projectFile, Encoding.UTF8);
            }
            solutionFile = solutionFile.Replace("%Projects%", projectString);

            byte[] coreBinary = ReadBinaryFromResource("LateBindingApi.dll");
            WriteBinaryToFile(coreBinary, Path.Combine(rootPath, "LateBindingApi.dll"));

            File.AppendAllText(Path.Combine(rootPath, solutionName + ".sln"), solutionFile, Encoding.UTF8);
        }
        public static void CreateSampleSolution(string directory)
        {
            COMComponentReader reader   = new COMComponentReader();
            string             innerXml = ReadTextFileFromRessource("LateBindingApi.CodeGenerator.SampleDocument.xml");

            reader.COMTree.LoadXml(innerXml);
            CreateSolution(reader, directory);
        }
Beispiel #3
0
 internal AliasHandler(COMComponentReader parent)
 {
     _parent = parent;
 }
 internal CoClassHandler(COMComponentReader parent)
 {
     _parent = parent;
 }
Beispiel #5
0
        public void ShowItems(COMComponentReader reader)
        {
            _initializeFlag = true;
            _reader         = reader;
            dataGridViewComponents.Rows.Clear();
            foreach (COMComponent itemComponent in reader.Components)
            {
                dataGridViewComponents.Rows.Add();
                int rowIndex = dataGridViewComponents.Rows.Count - 1;

                dataGridViewComponents.Rows[rowIndex].Tag = itemComponent;

                dataGridViewComponents.Rows[rowIndex].Cells[0].Value           = itemComponent.Name;
                dataGridViewComponents.Rows[rowIndex].Cells[0].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[0].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[1].Value           = itemComponent.Description;
                dataGridViewComponents.Rows[rowIndex].Cells[1].Style.BackColor = Color.FromKnownColor(KnownColor.DarkKhaki);

                dataGridViewComponents.Rows[rowIndex].Cells[2].Value           = itemComponent.VersionAttribute;
                dataGridViewComponents.Rows[rowIndex].Cells[2].Style.BackColor = Color.FromKnownColor(KnownColor.DarkKhaki);

                dataGridViewComponents.Rows[rowIndex].Cells[3].Value           = itemComponent.ContainingFile;
                dataGridViewComponents.Rows[rowIndex].Cells[3].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[3].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[4].Value           = itemComponent.GUID;
                dataGridViewComponents.Rows[rowIndex].Cells[4].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[4].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[5].Value           = itemComponent.MajorVersion;
                dataGridViewComponents.Rows[rowIndex].Cells[5].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[5].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[6].Value           = itemComponent.MinorVersion;
                dataGridViewComponents.Rows[rowIndex].Cells[6].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[6].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[7].Value           = itemComponent.LCID;
                dataGridViewComponents.Rows[rowIndex].Cells[7].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[7].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[8].Value           = itemComponent.SysKind;
                dataGridViewComponents.Rows[rowIndex].Cells[8].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[8].ReadOnly        = true;

                dataGridViewComponents.Rows[rowIndex].Cells[9].Value           = itemComponent.ContainingFile;
                dataGridViewComponents.Rows[rowIndex].Cells[9].Style.BackColor = Color.FromKnownColor(KnownColor.Control);
                dataGridViewComponents.Rows[rowIndex].Cells[9].ReadOnly        = true;
            }

            XmlNode solutionNode = reader.COMTree.SelectSingleNode("LateBindingApi.CodeGenerator.Document/Solution");

            if (null == solutionNode)
            {
                solutionNode = CreateSolutionNode();
            }

            textBoxSolutionName.Text = solutionNode.Attributes["Name"].Value;
            textBoxClassPrefix.Text  = solutionNode.Attributes["Prefix"].Value;

            _initializeFlag = false;
        }
 internal InterfaceHandler(COMComponentReader parent)
 {
     _parent = parent;
 }
 internal MethodHandler(COMComponentReader parent)
 {
     _parent = parent;
 }
 internal PropertyHandler(COMComponentReader parent)
 {
     _parent = parent;
 }
 internal EnumHandler(COMComponentReader parent)
 {
     _parent = parent;
 }