Пример #1
0
        public bool CanBeImplicitlyConvertedTo(StatePrimitive type)
        {
            var a = this.Order;
            var b = type.Order;

            return(Equals(LcaMap[a, b], type));
        }
Пример #2
0
 public void AddAncestor(StatePrimitive type)
 {
     if (!TryAddAncestor(type))
     {
         throw new InvalidOperationException();
     }
 }
Пример #3
0
        public StatePrimitive GetLastCommonPrimitiveAncestor(StatePrimitive other)
        {
            var a = this.Order;
            var b = other.Order;

            return(LcaMap[a, b]);
        }
Пример #4
0
        public void AddDescedant(StatePrimitive type)
        {
            if (type == null)
            {
                return;
            }

            if (Descedant == null)
            {
                Descedant = type;
            }
            else
            {
                var ancestor = Descedant.GetLastCommonAncestorOrNull(type);
                if (ancestor != null)
                {
                    Descedant = ancestor;
                }
            }
        }
Пример #5
0
        public bool TryAddAncestor(StatePrimitive type)
        {
            if (type == null)
            {
                return(true);
            }

            if (Ancestor == null)
            {
                Ancestor = type;
            }
            else
            {
                var res = Ancestor.GetFirstCommonDescendantOrNull(type);
                if (res == null)
                {
                    return(false);
                }
                Ancestor = res;
            }

            return(true);
        }
Пример #6
0
        public bool Fits(StatePrimitive primitiveState)
        {
            if (HasAncestor)
            {
                if (!primitiveState.CanBeImplicitlyConvertedTo(Ancestor))
                {
                    return(false);
                }
            }

            if (HasDescendant)
            {
                if (!Descedant.CanBeImplicitlyConvertedTo(primitiveState))
                {
                    return(false);
                }
            }

            if (IsComparable && !primitiveState.IsComparable)
            {
                return(false);
            }
            return(true);
        }
Пример #7
0
 public bool CanBeImplicitlyConvertedTo(StatePrimitive type)
 => type.Equals(StatePrimitive.Any);
Пример #8
0
 public bool Apply(IStateCombination2dimensionalVisitor visitor, TicNode ancestorNode, TicNode descendantNode,
                   StatePrimitive ancestor)
 => visitor.Apply(ancestor, this, ancestorNode, descendantNode);
Пример #9
0
 public StatePrimitive GetFirstCommonDescendantOrNull(StatePrimitive other)
 => FcdMap[this.Order, other.Order];
Пример #10
0
 public ConstrainsState(ITypeState desc = null, StatePrimitive anc = null)
 {
     Descedant = desc;
     Ancestor  = anc;
 }