public static MspecRemoteTask GetRemoteTask(IMspecElement element) { return(element switch { IContextElement context => FromContext(context), IBehaviorElement behavior => FromBehavior(behavior), ISpecificationElement specification => FromSpecification(specification), _ => throw new ArgumentOutOfRangeException(nameof(element)) });
public static MspecReSharperId Create(IMspecElement element) { return(element switch { IContextElement context => new MspecReSharperId(context), ISpecificationElement specification => new MspecReSharperId(specification), IBehaviorElement behavior => new MspecReSharperId(behavior), _ => throw new ArgumentOutOfRangeException(nameof(element)) });
internal FormContextInstance(IContextElement createdWith) { if (createdWith == null) { throw new ArgumentNullException("createdWith"); } _createdWith = createdWith; }
public BehaviorElement(IContextElement context, string typeName, string fieldName, string?ignoreReason) { Id = $"{context.TypeName}.{fieldName}"; AggregateId = $"{context.TypeName}.{typeName}"; Context = context; TypeName = typeName; FieldName = fieldName; IgnoreReason = ignoreReason; }
public bool TrySetContextParent(IContextElement contextParent) { if (IsFrozen) { return(false); } this.ContextParent = contextParent; ParentResourceContainer = contextParent as IResourceContainer; return(true); }
public SpecificationElement(IContextElement context, string fieldName, string?ignoreReason = null, IBehaviorElement?behavior = null) { Id = behavior != null ? $"{context.TypeName}.{behavior.FieldName}.{fieldName}" : $"{context.TypeName}.{fieldName}"; AggregateId = behavior != null ? $"{context.TypeName}.{behavior.TypeName}.{fieldName}" : $"{context.TypeName}.{fieldName}"; IgnoreReason = ignoreReason; Context = context; FieldName = fieldName; Behavior = behavior; }
public static object GetAncestor(DependencyObject target, Type ancestorType, int ancestorLevel) { if (!(target is IContextElement)) { return(ObservableValue.UnsetValue); } IContextElement contextElement = ((IContextElement)target).ContextParent; int level = ancestorLevel - 1; while (contextElement != null && (level > 0 || ancestorType != null && !ancestorType.IsInstanceOfType(contextElement))) { if (ancestorType == null || ancestorType.IsInstanceOfType(contextElement)) { level--; } contextElement = contextElement.ContextParent; } return((object)contextElement ?? ObservableValue.UnsetValue); }
public MspecReSharperId(IContextElement context) { Id = context.TypeName; }
public static string Self(IContextElement context) { return(new MspecReSharperId(context).Id); }
bool IContextElement.TrySetContextParent(IContextElement contextParent) { return(false); }
public IEnumerable <ISpecificationElement> GetSpecifications(IContextElement element) { return(specificationsByContext[element]); }
public IEnumerable <IBehaviorElement> GetBehaviors(IContextElement element) { return(behaviorsByContext[element]); }
public static void Clear() { Context.Clear(); _last = null; }
public static ISpecificationElement ToElement(this SpecificationInfo specification, IContextElement context, string?ignoreReason, IBehaviorElement?behavior = null) { return(new SpecificationElement(context, specification.FieldName, ignoreReason, behavior)); }