public override void ParseText() { StreamReader sr = new StreamReader(FileName); string input = sr.ReadLine(); while (null != input) { while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } ApiUtility.RemoveExtraSpace(ref input); if (input.StartsWith("Declare ")) { string[] pieces = input.Split(' '); string returnType = GetFunctionReturnType(pieces); string funcName = pieces[2]; string dllName = GetDllName(pieces[4]); string paramStr = ParseParameters(input); string cSharpCode = CompleteDllImportCoding(dllName, returnType, funcName, paramStr); AddCSharpCode(funcName, cSharpCode); } input = sr.ReadLine(); } sr.Close(); }
public override void ParseText() { bool structStart = false; bool structEnd = false; string cSharpCode = ""; string structKey = ""; StreamReader sr = new StreamReader(FileName); string input = sr.ReadLine(); while (null != input) { while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } ApiUtility.RemoveExtraSpace(ref input); if (IsStruct(input)) { structStart = true; structEnd = false; cSharpCode += DefineCShpStruct(input, ref structKey); input = sr.ReadLine(); continue; } if (structStart) { if (input.Trim().StartsWith(ApiUtility.VB_END_TYPE)) { structStart = false; structEnd = true; cSharpCode += "}\n"; AddCSharpCode(structKey, cSharpCode); structKey = ""; cSharpCode = ""; input = sr.ReadLine(); continue; } else if (!structEnd) { cSharpCode += DefineCShpStructBody(input); input = sr.ReadLine(); continue; } } input = sr.ReadLine(); } sr.Close(); }
public override void ParseText() { StreamReader sr = new StreamReader(FileName); string input = sr.ReadLine(); while (null != input) { // Ignore comments // ReSharper disable once PossibleNullReferenceException while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } ApiUtility.RemoveExtraSpace(ref input); if (input.StartsWith("Const ")) { string cKey = input.Split(' ')[1]; string cshpType = "int"; if (input.IndexOf(" As ") > 0) { input = input.Replace(" As ", " : "); cshpType = input.Split(':')[1].Trim(); cshpType = cshpType.Substring(0, cshpType.IndexOf(" ")); input = input.Replace(": " + cshpType, ""); ApiUtility.GetCSharpStyle(ref cshpType); } string cSharpCode = ApiUtility.CSHP_SCOPE + " " + input + ";\n"; cSharpCode = cSharpCode.Replace(ApiUtility.VB_CONST_LEADING, ApiUtility.CSHP_CONST_LEADING + cshpType); cSharpCode = cSharpCode.Replace(ApiUtility.VB_HEX_EXP, ApiUtility.CSHP_HEX_EXP); cSharpCode = cSharpCode.Replace(ApiUtility.VB_OR, ApiUtility.CSHP_OR); cSharpCode = cSharpCode.Replace("&'", "; //"); cSharpCode = cSharpCode.Replace("'", "; //"); cSharpCode = cSharpCode.Replace("&;", ";"); AddCSharpCode(cKey, cSharpCode); cSharpCode = ""; } input = sr.ReadLine(); } sr.Close(); }