/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Mvc/shared/Mvc.Views.TestCommon/TestRazorCompiledItem.cs
58 строк
2 KB
Weihan Li
Update TestRazorCompiledItem.cs (#54211)
05 мар 2024, 00:07
Не верифицирован
05 мар 2024, 00:07
958c8a7
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Security.Cryptography; using System.Text; namespace Microsoft.AspNetCore.Razor.Hosting; public class TestRazorCompiledItem : RazorCompiledItem { public static RazorCompiledItem CreateForPage(string identifier, object[] metadata = null) { return CreateForPage(type: null, identifier, metadata); } public static RazorCompiledItem CreateForPage(Type type, string identifier, object[] metadata = null) { return new TestRazorCompiledItem(type, "mvc.1.0.razor-page", identifier, metadata); } public static RazorCompiledItem CreateForView(string identifier, object[] metadata = null) { return CreateForView(type: null, identifier, metadata); } public static RazorCompiledItem CreateForView(Type type, string identifier, object[] metadata = null) { return new TestRazorCompiledItem(type, "mvc.1.0.razor-page", identifier, metadata); } public TestRazorCompiledItem(Type type, string kind, string identifier, object[] metadata) { Type = type; Kind = kind; Identifier = identifier; Metadata = metadata ?? Array.Empty<object>(); } public override string Identifier { get; } public override string Kind { get; } public override IReadOnlyList<object> Metadata { get; } public override Type Type { get; } public static string GetChecksum(string content) { var bytes = SHA1.HashData(Encoding.UTF8.GetBytes(content)); return Convert.ToHexStringLower(bytes); } public static string GetChecksumSHA256(string content) { var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(content)); return Convert.ToHexStringLower(bytes); } }