public HttpSourceServerDescriptor(int version, string versionControl, string target, SourceFileDescriptor[] sourceFiles) { Contract.Assert(versionControl != null); Contract.Assert(target != null); Contract.Assert(sourceFiles != null); Version = version; VersionControl = versionControl; Target = target; SourceFiles = sourceFiles; }
public static bool TryParse(string rawSrcSrv, out HttpSourceServerDescriptor descriptor) { string currentSection = ""; int version = 0; string versionControl = ""; string target = ""; var sources = new List <SourceFileDescriptor>(); foreach (var line in rawSrcSrv.GetLines()) { if (new[] { InitSection, VariablesSection, SourceFilesSection, EndSection }.Contains(line)) { currentSection = line; } else { switch (currentSection) { case InitSection: case VariablesSection: var groups = VariablesRegex.Match(line).Groups; var key = groups[1].Value; var value = groups[2].Value; switch (key) { case VersionKey: version = int.Parse(value); break; case VersionControlKey: versionControl = value; break; case TargetKey: target = value; break; } break; case SourceFilesSection: sources.Add(SourceFileDescriptor.Parse(line)); break; } } } descriptor = new[] { "http", "https" }.Contains(versionControl) ? new HttpSourceServerDescriptor(version, versionControl, target, sources.ToArray()) : null; return(descriptor != null); }