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)); }
public ModifierFacade(IProfileModifier modifier) : this(modifier, ModifierKind.Profile, modifier.Stringify) { }
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); }
private static ICharacteristic GetTargetCharacteristic(this IProfileModifier m) { return (m.GetParentProfile() .Characteristics.FirstOrDefault(characteristic => characteristic.TypeId.Value == m.Field.Value)); }