本文整理汇总了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;
}