示例#1
0
 private SettingJsonNode(SettingJsonNode node, SettingTranslateJsonNode translateNode)
     : base(node.Key)
 {
     if (!node.IsKeyEqual(translateNode.Key))
     {
         throw new InvalidOperationException($"translate node key {translateNode.Key} is not equal to {node.Key}");
     }
     if ((node.Values.List == null || node.Values.List.Length == 0) && translateNode.Values != null)
     {
         throw new InvalidOperationException($"translate node {translateNode.Key} should not contains values");
     }
     Name        = translateNode.Name;
     Category    = node.Category;
     Description = translateNode.Description ?? node.Description;
     Values      = node.Values.TranslateWith(translateNode.Values);
 }
 private SettingValuesJsonNode(SettingValuesJsonNode node, ValueJsonNode[]?translateNodes)
 {
     Type         = node.Type;
     DefaultValue = node.DefaultValue;
     Step         = node.Step;
     if (node.List != null)
     {
         List = ArrayHelper.Clone(node.List);
         if (translateNodes != null)
         {
             foreach (var translateNode in translateNodes)
             {
                 int index = node.GetValueIndex(translateNode.Value);
                 if (index != -1)
                 {
                     List[index] = node.List[index].TranslateWith(translateNode);
                 }
             }
         }
     }
 }
示例#3
0
 public Builder(string key, string name, string category, SettingValuesJsonNode values) : base(key)
 {
     Name     = name;
     Category = category;
     Values   = values;
 }