1 // Copyright (c) 2004 Francisco T. Martinez <paco@mfcon.com>
2 // All rights reserved.
6 using System
.Xml
.Serialization
;
7 using System
.Collections
;
10 using System
.Text
.RegularExpressions
;
11 using Mfconsulting
.General
.Prj2Make
.Schema
.Prjx
;
12 using Mfconsulting
.General
.Prj2Make
.Schema
.Csproj
;
14 namespace Mfconsulting
.General
.Prj2Make
17 public static string Escape (string s
)
19 if (s
.IndexOf (' ') == -1)
22 StringBuilder sb
= new StringBuilder ();
23 foreach (char c
in s
){
28 return sb
.ToString ();
36 public enum TypeOfFile
{
44 // Helper function to determine the type of
45 // file being parsed based on its extension
46 protected TypeOfFile
DetermineFileType(string inFileName
)
48 string ExtentionString
= System
.IO
.Path
.GetExtension (inFileName
);
50 switch(ExtentionString
)
53 return TypeOfFile
.sln
;
55 return TypeOfFile
.csproj
;
57 return TypeOfFile
.cmbx
;
59 return TypeOfFile
.prjx
;
62 return TypeOfFile
.unknown
;
65 public bool CreateCombineFromSln(string slnFileName
)
67 SlnMaker slnMkObj
= new SlnMaker();
69 // Load the sln and parse it
70 slnMkObj
.MsSlnToCmbxHelper(slnFileName
);
75 public bool CreatePrjxFromCsproj(string csprojFileName
)
77 SlnMaker slnMkObj
= new SlnMaker();
79 // Load the csproj and parse it
80 slnMkObj
.CreatePrjxFromCsproj(csprojFileName
);
85 // Main entry point for Makefile generation
86 public string MakerMain(bool isUnixMode
, bool isMcsMode
, string slnFile
)
88 SlnMaker mk1Obj
= null;
89 CmbxMaker mk2Obj
= null;
90 // Test to see what kind if file we got
91 // sln, csproj, cmbx, prjx
92 switch(DetermineFileType(slnFile
))
95 mk1Obj
= new SlnMaker();
96 return mk1Obj
.MsSlnHelper (isUnixMode
, isMcsMode
, true, slnFile
);
97 case TypeOfFile
.csproj
:
98 mk1Obj
= new SlnMaker();
99 return mk1Obj
.MsSlnHelper (isUnixMode
, isMcsMode
, false, slnFile
);
100 case TypeOfFile
.cmbx
:
101 mk2Obj
= new CmbxMaker();
102 return mk2Obj
.MdCmbxHelper (isUnixMode
, isMcsMode
, true, slnFile
);
103 case TypeOfFile
.prjx
:
104 mk2Obj
= new CmbxMaker();
105 return mk2Obj
.MdCmbxHelper (isUnixMode
, isMcsMode
, false, slnFile
);
107 return "Error: unknown file type.";