Exemple #1
0
        public void MsSlnToCmbxHelper(string slnFileName)
        {
            int           i               = 0;
            FileStream    fsOut           = null;
            XmlSerializer xmlSer          = null;
            StringBuilder MakefileBuilder = new StringBuilder();

            Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine cmbxObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine();
            string cmbxFileName = String.Format("{0}.cmbx",
                                                Path.Combine(Path.GetDirectoryName(slnFileName),
                                                             Path.GetFileNameWithoutExtension(slnFileName))
                                                );

            Console.WriteLine(String.Format("Will create combine filename:{0}", cmbxFileName));

            try
            {
                string d = Path.GetDirectoryName(slnFileName);
                if (d != "")
                {
                    Directory.SetCurrentDirectory(d);
                }

                // We invoke the ParseSolution
                // by passing the file obtained
                ParseSolution(slnFileName);

                // Create all of the prjx files form the csproj files
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    CreatePrjxFromCsproj(pi.csprojpath);
                }

                // Begin prjxObj population
                cmbxObj.name        = Path.GetFileNameWithoutExtension(slnFileName);
                cmbxObj.description = "";
                cmbxObj.fileversion = (decimal)1.0;

                // Create and attach the StartMode element
                Mfconsulting.General.Prj2Make.Schema.Cmbx.StartMode startModeElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.StartMode();

                // Create the array of Execute objects
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute[] executeElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute[projNameInfo.Count];

                // Populate the Element objects instances
                i = 0;
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute execElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute();
                    execElem.entry = pi.name;
                    execElem.type  = "None";

                    executeElem[i++] = execElem;
                }

                startModeElem.startupentry = executeElem[0].entry;
                startModeElem.single       = "True";
                startModeElem.Execute      = executeElem;

                // Attach the StartMode Object to the
                // Combine object
                cmbxObj.StartMode = startModeElem;

                // Gnerate the entries array
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry[] entriesObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry[projNameInfo.Count];
                // Populate the Entry objects instances
                i = 0;
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry entryObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry();
                    string PrjxFileName = String.Format(".{0}{1}.prjx",
                                                        Path.DirectorySeparatorChar,
                                                        Path.Combine(Path.GetDirectoryName(pi.csprojpath),
                                                                     Path.GetFileNameWithoutExtension(pi.csprojpath))
                                                        );

                    entryObj.filename = PrjxFileName;

                    entriesObj[i++] = entryObj;
                }

                // Attach the Entries Object to the
                // Combine object
                cmbxObj.Entries = entriesObj;

                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configurations configurationsObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configurations();

                // Hack hardcoded configuration value must get the one
                // from analyzing the different configuration entries
                configurationsObj.active = "Debug";

                // Hack hardcoded number of configuration object
                // assuming 2 for Debug and Release
                configurationsObj.Configuration = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration[2];
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration confObj1 = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration();
                configurationsObj.Configuration[0] = confObj1;
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration confObj2 = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration();
                configurationsObj.Configuration[1] = confObj2;

                configurationsObj.Configuration[0].name  = "Release";
                configurationsObj.Configuration[0].Entry = CreateArrayOfConfEntries();
                configurationsObj.Configuration[1].name  = "Debug";
                configurationsObj.Configuration[1].Entry = CreateArrayOfConfEntries();

                // Attach the Configurations object to the
                // Combine Object
                cmbxObj.Configurations = configurationsObj;

                // Serialize
                fsOut  = new FileStream(cmbxFileName, FileMode.Create);
                xmlSer = new XmlSerializer(typeof(Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine));
                xmlSer.Serialize(fsOut, cmbxObj);
                fsOut.Close();

                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}\n", e);
                return;
            }
        }
Exemple #2
0
        public void MsSlnToCmbxHelper(string slnFileName)
        {
            int i = 0;
            FileStream fsOut = null;
            XmlSerializer xmlSer = null;
            StringBuilder MakefileBuilder = new StringBuilder();
            Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine cmbxObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine();
            string cmbxFileName = String.Format ("{0}.cmbx",
                Path.Combine(Path.GetDirectoryName(slnFileName),
                Path.GetFileNameWithoutExtension(slnFileName))
                );

            Console.WriteLine(String.Format("Will create combine filename:{0}", cmbxFileName));

            try
            {
                string d = Path.GetDirectoryName(slnFileName);
                if (d != "")
                    Directory.SetCurrentDirectory(d);

                // We invoke the ParseSolution
                // by passing the file obtained
                ParseSolution (slnFileName);

                // Create all of the prjx files form the csproj files
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    CreatePrjxFromCsproj(pi.csprojpath);
                }

                // Begin prjxObj population
                cmbxObj.name = Path.GetFileNameWithoutExtension(slnFileName);
                cmbxObj.description = "";
                cmbxObj.fileversion = (decimal)1.0;

                // Create and attach the StartMode element
                Mfconsulting.General.Prj2Make.Schema.Cmbx.StartMode startModeElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.StartMode();

                // Create the array of Execute objects
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute[] executeElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute[projNameInfo.Count];

                // Populate the Element objects instances
                i = 0;
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute execElem = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Execute();
                    execElem.entry = pi.name;
                    execElem.type = "None";

                    executeElem[i++] = execElem;
                }

                startModeElem.startupentry = executeElem[0].entry;
                startModeElem.single = "True";
                startModeElem.Execute = executeElem;

                // Attach the StartMode Object to the
                // Combine object
                cmbxObj.StartMode = startModeElem;

                // Gnerate the entries array
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry[] entriesObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry[projNameInfo.Count];
                // Populate the Entry objects instances
                i = 0;
                foreach (CsprojInfo pi in projNameInfo.Values)
                {
                    Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry entryObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Entry();
                    string PrjxFileName = String.Format (".{0}{1}.prjx",
                        Path.DirectorySeparatorChar,
                        Path.Combine(Path.GetDirectoryName(pi.csprojpath),
                        Path.GetFileNameWithoutExtension(pi.csprojpath))
                        );

                    entryObj.filename = PrjxFileName;

                    entriesObj[i++] = entryObj;
                }

                // Attach the Entries Object to the
                // Combine object
                cmbxObj.Entries = entriesObj;

                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configurations configurationsObj = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configurations();

                // Hack hardcoded configuration value must get the one
                // from analyzing the different configuration entries
                configurationsObj.active = "Debug";

                // Hack hardcoded number of configuration object
                // assuming 2 for Debug and Release
                configurationsObj.Configuration = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration[2];
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration confObj1 = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration();
                configurationsObj.Configuration[0] = confObj1;
                Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration confObj2 = new Mfconsulting.General.Prj2Make.Schema.Cmbx.Configuration();
                configurationsObj.Configuration[1] = confObj2;

                configurationsObj.Configuration[0].name = "Release";
                configurationsObj.Configuration[0].Entry = CreateArrayOfConfEntries();
                configurationsObj.Configuration[1].name = "Debug";
                configurationsObj.Configuration[1].Entry = CreateArrayOfConfEntries();

                // Attach the Configurations object to the
                // Combine Object
                cmbxObj.Configurations = configurationsObj;

                // Serialize
                fsOut = new FileStream (cmbxFileName, FileMode.Create);
                xmlSer = new XmlSerializer (typeof(Mfconsulting.General.Prj2Make.Schema.Cmbx.Combine));
                xmlSer.Serialize(fsOut, cmbxObj);
                fsOut.Close();

                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}\n", e);
                return;
            }
        }