private static bool TryParseUri(string uriInput, out string clrNs, out string assemblyName, out string error, bool returnErrors) { clrNs = null; assemblyName = null; error = null; int index = KS.IndexOf(uriInput, ":"); if (-1 == index) { if (returnErrors) { error = System.Xaml.SR.Get("MissingTagInNamespace", new object[] { ":", uriInput }); } return(false); } if (!KS.Eq(uriInput.Substring(0, index), "clr-namespace")) { if (returnErrors) { error = System.Xaml.SR.Get("MissingTagInNamespace", new object[] { "clr-namespace", uriInput }); } return(false); } int startIndex = index + 1; int num3 = KS.IndexOf(uriInput, ";"); if (-1 == num3) { clrNs = uriInput.Substring(startIndex); assemblyName = null; return(true); } int length = num3 - startIndex; clrNs = uriInput.Substring(startIndex, length); int num5 = num3 + 1; int num6 = KS.IndexOf(uriInput, "="); if (-1 == num6) { if (returnErrors) { error = System.Xaml.SR.Get("MissingTagInNamespace", new object[] { "=", uriInput }); } return(false); } if (!KS.Eq(uriInput.Substring(num5, num6 - num5), "assembly")) { if (returnErrors) { error = System.Xaml.SR.Get("AssemblyTagMissing", new object[] { "assembly", uriInput }); } return(false); } assemblyName = uriInput.Substring(num6 + 1); return(true); }
public static bool TryParseUri(string uriInput, out string clrNs, out string assemblyName) { clrNs = null; assemblyName = null; // xmlns:foo="clr-namespace:System.Windows;assembly=myassemblyname" // xmlns:bar="clr-namespace:MyAppsNs" // xmlns:spam="clr-namespace:MyAppsNs;assembly=" int colonIdx = KS.IndexOf(uriInput, ":"); if (colonIdx == -1) { return(false); } string keyword = uriInput.Substring(0, colonIdx); if (!KS.Eq(keyword, KnownStrings.UriClrNamespace)) { return(false); } int clrNsStartIdx = colonIdx + 1; int semicolonIdx = KS.IndexOf(uriInput, ";"); if (semicolonIdx == -1) { clrNs = uriInput.Substring(clrNsStartIdx); assemblyName = null; return(true); } else { int clrnsLength = semicolonIdx - clrNsStartIdx; clrNs = uriInput.Substring(clrNsStartIdx, clrnsLength); } int assemblyKeywordStartIdx = semicolonIdx + 1; int equalIdx = KS.IndexOf(uriInput, "="); if (equalIdx == -1) { return(false); } keyword = uriInput.Substring(assemblyKeywordStartIdx, equalIdx - assemblyKeywordStartIdx); if (!KS.Eq(keyword, KnownStrings.UriAssembly)) { return(false); } assemblyName = uriInput.Substring(equalIdx + 1); return(true); }
private static bool TryParseUri(string uriInput, out string clrNs, out string assemblyName, out string error, bool returnErrors) { clrNs = null; assemblyName = null; error = null; // xmlns:foo="clr-namespace:System.Windows;assembly=myassemblyname" // xmlns:bar="clr-namespace:MyAppsNs" // xmlns:spam="clr-namespace:MyAppsNs;assembly=" int colonIdx = KS.IndexOf(uriInput, ":"); if (-1 == colonIdx) { if (returnErrors) { error = SR.Get(SRID.MissingTagInNamespace, ":", uriInput); } return(false); } string keyword = uriInput.Substring(0, colonIdx); if (!KS.Eq(keyword, KnownStrings.UriClrNamespace)) { if (returnErrors) { error = SR.Get(SRID.MissingTagInNamespace, KnownStrings.UriClrNamespace, uriInput); } return(false); } int clrNsStartIdx = colonIdx + 1; int semicolonIdx = KS.IndexOf(uriInput, ";"); if (-1 == semicolonIdx) { clrNs = uriInput.Substring(clrNsStartIdx); assemblyName = null; return(true); } else { int clrnsLength = semicolonIdx - clrNsStartIdx; clrNs = uriInput.Substring(clrNsStartIdx, clrnsLength); } int assemblyKeywordStartIdx = semicolonIdx + 1; int equalIdx = KS.IndexOf(uriInput, "="); if (-1 == equalIdx) { if (returnErrors) { error = SR.Get(SRID.MissingTagInNamespace, "=", uriInput); } return(false); } keyword = uriInput.Substring(assemblyKeywordStartIdx, equalIdx - assemblyKeywordStartIdx); if (!KS.Eq(keyword, KnownStrings.UriAssembly)) { if (returnErrors) { error = SR.Get(SRID.AssemblyTagMissing, KnownStrings.UriAssembly, uriInput); } return(false); } assemblyName = uriInput.Substring(equalIdx + 1); return(true); }