src/EasyFrameWork/Mvc/DataAnnotations/DataAnnotationsMetadataProvider.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.AspNetCore.Mvc;
using Easy.MetaData;
using Easy.Extend;
using Easy.ViewPort.Validator;
using Easy.Serializer;
namespace Easy.Mvc.DataAnnotations
{
public class DataAnnotationsMetadataProvider :
IDisplayMetadataProvider,
IValidationMetadataProvider
{
public void CreateDisplayMetadata(DisplayMetadataProviderContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (context.Key.ContainerType != null && !context.Key.ContainerType.IsValueType)
{
var viewConfig = ServiceLocator.GetViewConfigure(context.Key.ContainerType);
var displayMetadata = context.DisplayMetadata;
if (viewConfig != null && context.Key.Name.IsNotNullAndWhiteSpace())
{
var descriptor = viewConfig.GetViewPortDescriptor(context.Key.Name);
if (descriptor != null)
{
displayMetadata.AdditionalValues.Add("ViewPortDescriptor", descriptor);
if (displayMetadata.DisplayName == null)
{
displayMetadata.DisplayName = () => descriptor.DisplayName;
}
displayMetadata.Order = descriptor.OrderIndex;
displayMetadata.TemplateHint = descriptor.TemplateName;
displayMetadata.ShowForDisplay = descriptor.IsShowForDisplay;
displayMetadata.ShowForEdit = descriptor.IsShowForEdit;
if (descriptor.IsHidden)
{
displayMetadata.TemplateHint = "HiddenInput";
displayMetadata.ShowForDisplay = false;
displayMetadata.ShowForEdit = false;
}
if (descriptor.IsIgnore)
{
displayMetadata.ShowForDisplay = false;
displayMetadata.ShowForEdit = false;
后面还有 81 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。