public ProcessCommandLineInfo Process(string[] args) { ProcessCommandLineInfo processCommandLineInfo = new ProcessCommandLineInfo(); args = String.Join(" ", args).Split("/".ToCharArray()); if (args.Length < 2 || args.Length > 4) throw new ArgumentException(String.Format("Arguments specified: {0}", args.Length)); DirectoryInfo sourceDir = new DirectoryInfo(args[0]); if (!sourceDir.Exists) { FileInfo fi = new FileInfo(args[0]); sourceDir = new DirectoryInfo(fi.Directory.FullName); } if (!sourceDir.Exists) throw new ArgumentException(String.Format("Source directory not found: {0}", sourceDir.ToString())); TargetLanguage targetLanguage = TargetLanguage.CPP; DirectoryInfo targetDir = sourceDir; switch (args.Length) { case 2: targetDir = sourceDir; targetLanguage = ParseTargetLanguage(args[1]); break; case 3: case 4: targetDir = new DirectoryInfo(args[1]); targetLanguage = ParseTargetLanguage(args[2]); break; } if (!targetDir.Exists) { Directory.CreateDirectory(targetDir.FullName); } FileInfo[] sourceFiles = sourceDir.GetFiles("*.xsd"); if (sourceFiles.Length == 0) throw new ArgumentException(String.Format("No .xsd files found in: {0}", sourceDir.ToString())); if (args.Length == 4) { processCommandLineInfo.CrossPlatformSerializationSupport = (args[3] == "CPSS" ? true : false); } processCommandLineInfo.TargetLanguage = targetLanguage; processCommandLineInfo.OutputDirectory = targetDir.FullName; foreach (FileInfo sourceFile in sourceFiles) { processCommandLineInfo.SourceFiles.Add(sourceFile.FullName); } return processCommandLineInfo; }
public ProcessCommandLineInfo Process(string[] args) { ProcessCommandLineInfo processCommandLineInfo = new ProcessCommandLineInfo(); args = String.Join(" ", args).Split("/".ToCharArray()); if (args.Length < 2 || args.Length > 4) { throw new ArgumentException(String.Format("Arguments specified: {0}", args.Length)); } DirectoryInfo sourceDir = new DirectoryInfo(args[0]); if (!sourceDir.Exists) { FileInfo fi = new FileInfo(args[0]); sourceDir = new DirectoryInfo(fi.Directory.FullName); } if (!sourceDir.Exists) { throw new ArgumentException(String.Format("Source directory not found: {0}", sourceDir.ToString())); } TargetLanguage targetLanguage = TargetLanguage.CPP; DirectoryInfo targetDir = sourceDir; switch (args.Length) { case 2: targetDir = sourceDir; targetLanguage = ParseTargetLanguage(args[1]); break; case 3: case 4: targetDir = new DirectoryInfo(args[1]); targetLanguage = ParseTargetLanguage(args[2]); break; } if (!targetDir.Exists) { Directory.CreateDirectory(targetDir.FullName); } FileInfo[] sourceFiles = sourceDir.GetFiles("*.xsd"); if (sourceFiles.Length == 0) { throw new ArgumentException(String.Format("No .xsd files found in: {0}", sourceDir.ToString())); } if (args.Length == 4) { processCommandLineInfo.CrossPlatformSerializationSupport = (args[3] == "CPSS" ? true : false); } processCommandLineInfo.TargetLanguage = targetLanguage; processCommandLineInfo.OutputDirectory = targetDir.FullName; foreach (FileInfo sourceFile in sourceFiles) { processCommandLineInfo.SourceFiles.Add(sourceFile.FullName); } return(processCommandLineInfo); }