本文整理匯總了C#中System.Language.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Language.GetHashCode方法的具體用法?C# Language.GetHashCode怎麽用?C# Language.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Language
的用法示例。
在下文中一共展示了Language.GetHashCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoadXSLT
public XslCompiledTransform LoadXSLT(ResourceType resourceType, Language language, string platform)
{
var currentDir = m_WorkingDirectoryProvider.GetPath();
if (!m_CachedTransforms.ContainsKey(currentDir))
{
m_CachedTransforms[currentDir] = new Dictionary<int, XslCompiledTransform>();
}
var cache = m_CachedTransforms[currentDir];
int hash;
unchecked
{
hash = 17 *
resourceType.GetHashCode() * 31 +
language.GetHashCode() * 31 +
platform.GetHashCode() * 31;
}
if (cache.ContainsKey(hash))
{
return cache[hash];
}
var source = this.LoadOverriddableResource(resourceType, language, platform);
var reader2 = new StreamReader(source);
var readerInspect = reader2.ReadToEnd();
source.Seek(0, SeekOrigin.Begin);
var resolver = new EmbeddedResourceResolver();
var result = new XslCompiledTransform();
using (var reader = XmlReader.Create(source))
{
try
{
result.Load(
reader,
XsltSettings.TrustedXslt,
resolver
);
}
catch (XsltException ex)
{
var lines = readerInspect.Split(new[] {"\r\n", "\n"}, StringSplitOptions.None);
var line = ex.LineNumber;
var minLine = Math.Max(line - 10, 0);
var maxLine = Math.Min(line + 10, lines.Length - 1);
var selectedLines = new List<string>();
for (var l = minLine; l <= maxLine; l++)
{
if (l == line)
{
selectedLines.Add(">> " + lines[l]);
}
else
{
selectedLines.Add(" " + lines[l]);
}
}
var context = string.Join(Environment.NewLine, selectedLines);
throw new XsltCompileException(
ex.Message + "\r\n" + context,
ex);
}
}
cache[hash] = result;
return result;
}