Exemplo n.º 1
0
        public static string Stringify(this IProfileModifier m)
        {
            switch (m.Action)
            {
            case ProfileModifierAction.Hide:
            case ProfileModifierAction.Show:
                return(m.Action.ToString());

            case ProfileModifierAction.Increment:
            case ProfileModifierAction.Decrement:
                return($"{m.Action} '{m.GetTargetCharacteristic()?.Name ?? m.Field.RawValue}' by '{m.Value}'");

            case ProfileModifierAction.Append:
                return($"{m.Action} '{m.GetTargetCharacteristic()?.Name ?? m.Field.RawValue}' with '{m.Value}'");

            case ProfileModifierAction.Set:
                return($"{m.Action} '{m.GetTargetCharacteristic()?.Name ?? m.Field.RawValue}' to '{m.Value}'");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public static ModifierFacade ToFacade(this IProfileModifier modifier)
 {
     return(new ModifierFacade(modifier));
 }
Exemplo n.º 3
0
 public ModifierFacade(IProfileModifier modifier) : this(modifier, ModifierKind.Profile, modifier.Stringify)
 {
 }
Exemplo n.º 4
0
 public static IProfile GetParentProfile(this IProfileModifier modifier)
 {
     return(modifier.Context.Profiles.FirstOrDefault(profile => profile.Modifiers.Contains(modifier)) ??
            modifier.Context.ProfileLinks.First(link => link.Modifiers.Contains(modifier)).Target);
 }
Exemplo n.º 5
0
 private static ICharacteristic GetTargetCharacteristic(this IProfileModifier m)
 {
     return
         (m.GetParentProfile()
          .Characteristics.FirstOrDefault(characteristic => characteristic.TypeId.Value == m.Field.Value));
 }