Beispiel #1
0
 public Pref(
     string name   = null,
     string target = null,
     PresetReferenceType prefType = default(PresetReferenceType)
     ) : base(name, JsonObjectType.Pref)
 {
     this.prefType = prefType;
     this.target   = target;
 }
Beispiel #2
0
        public static object Read(string target, PresetReferenceType prefType = default(PresetReferenceType))
        {
            var json      = File.ReadAllText(PresetsSource);
            var presets   = JsonConvert.DeserializeObject <IEnumerable <Preset> >(json);
            var selection = presets.First(p => p.name == target);

            switch (prefType)
            {
            case PresetReferenceType.Value: return(selection.value);

            case PresetReferenceType.Name: return(selection.name);

            case PresetReferenceType.Property: return(string.Format("{0}: {1}", selection.name, selection.value));

            default: throw new NotImplementedException();
            }
        }