public static IEnumerable <ReleaseEntry> ParseReleaseFileAndApplyStaging(string fileContents, Guid?userToken) { if (String.IsNullOrEmpty(fileContents)) { return(new ReleaseEntry[0]); } fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents); var ret = fileContents.Split('\n') .Where(x => !String.IsNullOrWhiteSpace(x)) .Select(ParseReleaseEntry) .Where(x => x != null && x.IsStagingMatch(userToken)) .ToArray(); return(ret.Any(x => x == null) ? null : ret); }
public static IEnumerable <ReleaseEntry> ParseReleaseFile(string fileContents) { if (string.IsNullOrEmpty(fileContents)) { return(new ReleaseEntry[0]); } fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents); if (fileContents.StartsWith("<?xml")) { return(new ReleaseEntry[0]); } char[] separator = new char[] { '\n' }; ReleaseEntry[] entryArray = (from x in Enumerable.Select <string, ReleaseEntry>(from x in fileContents.Split(separator) where !string.IsNullOrWhiteSpace(x) select x, new Func <string, ReleaseEntry>(ReleaseEntry.ParseReleaseEntry)) where x != null select x).ToArray <ReleaseEntry>(); return(Enumerable.Any <ReleaseEntry>(entryArray, x => ReferenceEquals(x, null)) ? ((IEnumerable <ReleaseEntry>) new ReleaseEntry[0]) : ((IEnumerable <ReleaseEntry>)entryArray)); }
public static IEnumerable <ReleaseEntry> ParseReleaseFile(string fileContents) { if (String.IsNullOrEmpty(fileContents)) { return(new ReleaseEntry[0]); } fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents); // workaround for our CDN returning 200 and a xml doc with an error message if you have the wrong url if (fileContents.StartsWith("<?xml")) { return(new ReleaseEntry[0]); } var ret = fileContents.Split('\n') .Where(x => !String.IsNullOrWhiteSpace(x)) .Select(ParseReleaseEntry) .Where(x => x != null) .ToArray(); return(ret.Any(x => x == null) ? new ReleaseEntry[0] : ret); }