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))
     });
Пример #2
0
 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;
 }
Пример #5
0
        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;
 }
Пример #7
0
        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);
        }
Пример #8
0
 public MspecReSharperId(IContextElement context)
 {
     Id = context.TypeName;
 }
Пример #9
0
 public static string Self(IContextElement context)
 {
     return(new MspecReSharperId(context).Id);
 }
Пример #10
0
 bool IContextElement.TrySetContextParent(IContextElement contextParent)
 {
     return(false);
 }
Пример #11
0
 public IEnumerable <ISpecificationElement> GetSpecifications(IContextElement element)
 {
     return(specificationsByContext[element]);
 }
Пример #12
0
 public IEnumerable <IBehaviorElement> GetBehaviors(IContextElement element)
 {
     return(behaviorsByContext[element]);
 }
Пример #13
0
 public static void Clear()
 {
     Context.Clear();
     _last = null;
 }
Пример #14
0
 public static ISpecificationElement ToElement(this SpecificationInfo specification, IContextElement context, string?ignoreReason, IBehaviorElement?behavior = null)
 {
     return(new SpecificationElement(context, specification.FieldName, ignoreReason, behavior));
 }