private Format3DResult Parse(string[] videoFlags, Format3DRule rule) { var result = new Format3DResult(); if (string.IsNullOrWhiteSpace(rule.PreceedingToken)) { result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase)); result.Is3D = !string.IsNullOrWhiteSpace(result.Format3D); if (result.Is3D) { result.Tokens.Add(rule.Token); } } else { var foundPrefix = false; string format = null; foreach (var flag in videoFlags) { if (foundPrefix) { result.Tokens.Add(rule.PreceedingToken); if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase)) { format = flag; result.Tokens.Add(rule.Token); } break; } foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase); } result.Is3D = foundPrefix && !string.IsNullOrWhiteSpace(format); result.Format3D = format; } return(result); }
private Format3DResult Parse(string[] videoFlags, Format3DRule rule) { var result = new Format3DResult(); if (string.IsNullOrWhiteSpace(rule.PreceedingToken)) { result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase)); result.Is3D = !string.IsNullOrWhiteSpace(result.Format3D); if (result.Is3D) { result.Tokens.Add(rule.Token); } } else { var foundPrefix = false; string format = null; foreach (var flag in videoFlags) { if (foundPrefix) { result.Tokens.Add(rule.PreceedingToken); if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase)) { format = flag; result.Tokens.Add(rule.Token); } break; } foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase); } result.Is3D = foundPrefix && !string.IsNullOrWhiteSpace(format); result.Format3D = format; } return result; }