static ItemBuilder RegistryValue(this ItemBuilder dsl, string key, string valueName, int dominatedValue, int submissiveValue, DominatorState? optionNotFound = null, Func<int, bool> alsoTreatAsSubmissive = null) { Func<int, bool> isTreatedAsSubmissive = v => v == submissiveValue || (alsoTreatAsSubmissive != null && alsoTreatAsSubmissive(v)); return dsl .Setter( action => Registry.SetValue(key, valueName, action == DominationAction.Dominate ? dominatedValue : submissiveValue, RegistryValueKind.DWord)) .Getter(() => { var value = Registry.GetValue(key, valueName, null); if (!(value is int)) return optionNotFound ?? DominatorState.Indetermined(OptionNotFoundMessage); var v = (int)value; if (v == dominatedValue) return DominatorState.Dominated(); if (isTreatedAsSubmissive(v)) return DominatorState.Submissive(); return DominatorState.Indetermined(string.Format(ValueNotRecognizedMessage, v)); }); }
public DominationState(DominatorState groupState, IEnumerable<DominationState> nested) : this(groupState, null, nested) { }
DominationState(DominatorState? state, Exception error_, IEnumerable<DominationState> nested) { State_ = state; Error_ = error_; Nested = nested; }
public DominationState(DominatorState itemState) : this(itemState, null, Enumerable.Empty<DominationState>()) { }