示例#1
0
 /// <summary>
 /// Configure model type display
 /// </summary>
 /// <param name="displayConfigurationCollection">Model type display configurations</param>
 public static void Configure(DisplayConfigurationCollection displayConfigurationCollection)
 {
     if (displayConfigurationCollection?.Types.IsNullOrEmpty() ?? true)
     {
         return;
     }
     foreach (var typeDisplay in displayConfigurationCollection.Types)
     {
         if (typeDisplay == null || string.IsNullOrWhiteSpace(typeDisplay.ModelTypeFullName) || typeDisplay.Propertys.IsNullOrEmpty())
         {
             continue;
         }
         Type modelType = Type.GetType(typeDisplay.ModelTypeFullName);
         if (modelType == null)
         {
             continue;
         }
         foreach (var propertyDisplay in typeDisplay.Propertys)
         {
             if (propertyDisplay == null || string.IsNullOrWhiteSpace(propertyDisplay.Name) || propertyDisplay.Display == null)
             {
                 continue;
             }
             SetPropertyDisplay(modelType, propertyDisplay.Name, propertyDisplay.Display.DisplayName);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Configure display from json
        /// </summary>
        /// <param name="json">json data</param>
        public static void ConfigureByJson(string json)
        {
            if (string.IsNullOrWhiteSpace(json))
            {
                return;
            }
            DisplayConfigurationCollection typeConfigurationCollection = JsonSerializeHelper.JsonToObject <DisplayConfigurationCollection>(json);

            Configure(typeConfigurationCollection);
        }