コード例 #1
0
 public int GetHashCode(IXor2 <TAType, TBType> obj)
 {
     if (obj.IsA)
     {
         return(_comparerA.GetHashCode(obj.A));
     }
     else
     {
         return(_comparerB.GetHashCode(obj.B));
     }
 }
コード例 #2
0
 static public TValue Property <TOwner, TValue>(IXor2 <IPropertyDescription <TOwner, TValue>, IPropertyDescriptionChain <TOwner, TValue> > propertyDescription, TOwner owner)
     where TOwner : class
 {
     if (propertyDescription.IsA)
     {
         return(Property(propertyDescription.A, owner));
     }
     else
     {
         return((TValue)_ValueOf_PropertyByDescriptionPathRec(propertyDescription.B.Nodes, owner));
     }
 }
コード例 #3
0
 public TCommonValue From <TAType, TBType>(IXor2 <TAType, TBType> xor2)
     where TAType : TCommonValue
     where TBType : TCommonValue
 {
     if (xor2.IsA)
     {
         return(xor2.A);
     }
     else
     {
         return(xor2.B);
     }
 }
コード例 #4
0
 public Xor2 <TBaseAType, TBaseBType> From <TTypeA, TTypeB>(IXor2 <TTypeA, TTypeB> xor)
     where TTypeA : TBaseAType
     where TTypeB : TBaseBType
 {
     if (xor.IsA)
     {
         return((Xor2 <TBaseAType, TBaseBType>)xor.A);
     }
     else
     {
         return((Xor2 <TBaseAType, TBaseBType>)xor.B);
     }
 }
コード例 #5
0
        static public TResult Dispatch <TA, TB, TResult>(this IXor2 <TA, TB> _this, Func <TA, TResult> oxFunc1, Func <TB, TResult> oxFunc2)
        {
            switch (_this.Kind)
            {
            case Xor2Enum.A:
                return(oxFunc1(_this.A));

            case Xor2Enum.B:
                return(oxFunc2(_this.B));

            default:
                throw NotPreparedForThatCase.CannotHappenException;
            }
        }
コード例 #6
0
            public bool Equals(IXor2 <TAType, TBType> x, IXor2 <TAType, TBType> y)
            {
                if (x.IsA && y.IsA)
                {
                    return(_comparerA.Equals(x.A, y.A));
                }

                if (x.IsB && y.IsB)
                {
                    return(_comparerB.Equals(x.B, y.B));
                }

                return(false);
            }
コード例 #7
0
 public SynchObservableAction(Action oxBodyAction, IObservableProperty <bool> isAllowedObservable, string commandName)
     : base(oxBodyAction, isAllowedObservable.GetValue, commandName)
 {
     _oxBodyAction = oxBodyAction;
     _Cached_IsExecutingPropertyDescription = PropertyDescription.FromExpression <ISynchAction, bool>(x => x.IsExecuting);
 }
コード例 #8
0
 public PropertyChanged(IXor2 <IPropertyDescription <TOwner, TValue>, IPropertyDescriptionChain <TOwner, TValue>, IPropertyOrChainDescription> propertyDescription, TValue oldValue, TValue newValue)
 {
     this.PropertyDescription = propertyDescription;
     OldValue = oldValue;
     NewValue = newValue;
 }
コード例 #9
0
 public Xor2(IXor2 <TAType, TBType, TCommon> xor)
     : this()
 {
     _obj = xor.Common;
 }
コード例 #10
0
            public EqualityResult <IXor2 <TAType, TBType>, Xor3 <TReasonA, TReasonB, DifferentTypesEnum> > AreEqual(IXor2 <TAType, TBType> x, IXor2 <TAType, TBType> y)
            {
                if (x.IsA && y.IsA)
                {
                    var res = _comparerA.AreEqual(x.A, y.A);
                    if (res)
                    {
                        return(EqualityResult.Ok);
                    }
                    else
                    {
                        return((Xor3 <TReasonA, TReasonB, DifferentTypesEnum>)res.NotEqualReason.Value);
                    }
                }

                if (x.IsB && y.IsB)
                {
                    var res = _comparerB.AreEqual(x.B, y.B);
                    if (res)
                    {
                        return(EqualityResult.Ok);
                    }
                    else
                    {
                        return((Xor3 <TReasonA, TReasonB, DifferentTypesEnum>)res.NotEqualReason.Value);
                    }
                }


                return((Xor3 <TReasonA, TReasonB, DifferentTypesEnum>)DifferentTypesEnum.DifferentTypes);
            }
コード例 #11
0
        static public IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> Add <TOwner, TIntermediateValue, TFinalValue>(this IXor2 <IPropertyDescription <TOwner, TIntermediateValue>, IPropertyDescriptionChain <TOwner, TIntermediateValue>, IPropertyOrChainDescription> _this, IXor2 <IPropertyDescription <TIntermediateValue, TFinalValue>, IPropertyDescriptionChain <TIntermediateValue, TFinalValue>, IPropertyOrChainDescription> other)
            where TOwner : class
            where TIntermediateValue : class
        {
            if (_this.IsA)
            {
                var singleProp = _this.A;
                var chain      = new PropertyDescriptionChain <TOwner, TFinalValue>(singleProp, other.Common.Nodes);

                return(new Xor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription>(chain));
            }
            else
            {
                var chain         = _this.B;
                var others        = chain.Nodes.Skip(1).Concat(other.Common.Nodes).ToList();
                var chainExpanded = new PropertyDescriptionChain(chain.FirstNode, others);

                return(new Xor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription>(chainExpanded));
            }
        }
コード例 #12
0
        private static IXor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription> _ExtendXor <TOwner>(IXor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription> _this, IReadOnlyList <IPropertyDescription> otherNodes)
            where TOwner : class
        {
            if (_this.IsA)
            {
                var singleProp = _this.A;
                var chain      = new PropertyDescriptionChain <TOwner>(singleProp, otherNodes);

                return(new Xor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription>(chain));
            }
            else
            {
                var chain         = _this.B;
                var others        = chain.Nodes.Skip(1).Concat(otherNodes).ToList();
                var chainExpanded = new PropertyDescriptionChain <TOwner>(chain.FirstNode, others);

                return(new Xor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription>(chainExpanded));
            }
        }
コード例 #13
0
 static public IXor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription> Add <TOwner>(this IXor2 <IPropertyDescription <TOwner>, IPropertyDescriptionChain <TOwner>, IPropertyOrChainDescription> _this, IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> other)
     where TOwner : class
 {
     return(_ExtendXor(_this, other.Common.Nodes));
 }
コード例 #14
0
 static public IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> Add(this IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> _this, IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> other)
 {
     return(_ExtendXor(_this, other.Common.Nodes));
 }
コード例 #15
0
 static public IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> Add(this IXor2 <IPropertyDescription, IPropertyDescriptionChain, IPropertyOrChainDescription> _this, IPropertyDescription other)
 {
     return(_ExtendXor(_this, new[] { other }));
 }