private object TargetFrameworkName_Parser( string name, PatternTable table) { object obj = null; // Check for replacements if (table != null) { if (table.TryLookup(PropertyNames.TargetFrameworkMoniker, name, out obj)) { return(obj); } } // Check the cache for an exact match if (!string.IsNullOrEmpty(name)) { NuGetFramework cachedResult; if (!_frameworkCache.TryGetValue(name, out cachedResult)) { // Parse and add the framework to the cache cachedResult = TargetFrameworkName_ParserCore(name); _frameworkCache.Add(name, cachedResult); } return(cachedResult); } // Let the framework parser handle null/empty and create the error message. return(TargetFrameworkName_ParserCore(name)); }
public void PatternTable_LookupWhenEmpty() { // Arrange var table = new PatternTable(); // Act object obj; var b = table.TryLookup("tfm", "any", out obj); // Assert Assert.False(b); Assert.Null(obj); }
private static object CodeLanguage_Parser(string name, PatternTable table) { if (table != null) { object val; if (table.TryLookup(PropertyNames.CodeLanguage, name, out val)) { return(val); } } // Code language values must be alpha numeric. return(name.All(c => char.IsLetterOrDigit(c)) ? name : null); }
public void PatternTable_LookupWithMiss() { // Arrange var data = new List <PatternTableEntry>() { new PatternTableEntry("tfm", "dotnet", NuGetFramework.Parse("dotnet")) }; var table = new PatternTable(data); // Act object obj; var b = table.TryLookup("tfm", "any", out obj); // Assert Assert.False(b); Assert.Null(obj); }
public void PatternTable_LookupWithValue() { // Arrange var dotnet = NuGetFramework.Parse("dotnet"); var data = new List <PatternTableEntry>() { new PatternTableEntry("tfm", "any", dotnet) }; var table = new PatternTable(data); // Act object obj; var b = table.TryLookup("tfm", "any", out obj); // Assert Assert.True(b); Assert.Equal(dotnet, obj); }
private static object Locale_Parser(string name, PatternTable table) { if (table != null) { object val; if (table.TryLookup(PropertyNames.Locale, name, out val)) { return(val); } } if (name.Length == 2) { return(name); } else if (name.Length >= 4 && name[2] == '-') { return(name); } return(null); }