// Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        /// <param name="provider">Arithmetic provider this arithmetic is bound to.</param>
        /// <param name="rules">Arithmetic rules.</param>
        public ArithmeticBase(IArithmeticProvider provider, ArithmeticRules rules)
        {
            ArgumentValidator.EnsureArgumentNotNull(provider, "provider");
            this.provider   = provider;
            Rules           = rules;
            OverflowAllowed = (rules.OverflowBehavior == OverflowBehavior.AllowOverflow);
            NullIsZero      = (rules.NullBehavior == NullBehavior.ThreatNullAsZero);
        }
 /// <summary>
 /// Performs post-deserialization actions.
 /// </summary>
 /// <param name="sender"></param>
 public virtual void OnDeserialization(object sender)
 {
     if (provider == null || provider.GetType() == typeof(ArithmeticProvider))
     {
         provider = ArithmeticProvider.Default;
     }
     OverflowAllowed   = (Rules.OverflowBehavior == OverflowBehavior.AllowOverflow);
     NullIsZero        = (Rules.NullBehavior == NullBehavior.ThreatNullAsZero);
     cachedArithmetics = ThreadSafeDictionary <ArithmeticRules, Arithmetic <T> > .Create(new object());
 }
Exemple #3
0
 /// <summary>
 /// Initializes new instance of this type.
 /// </summary>
 /// <param name="implementation"><see cref="MethodCacheBase{TImplementation}.Implementation"/> property value.</param>
 public Arithmetic(IArithmetic <T> implementation)
     : base(implementation)
 {
     Provider   = Implementation.Provider;
     Zero       = Implementation.Zero;
     One        = Implementation.One;
     MaxValue   = Implementation.MaxValue;
     MinValue   = Implementation.MinValue;
     IsSigned   = Implementation.IsSigned;
     Add        = Implementation.Add;
     Subtract   = Implementation.Subtract;
     Multiply   = Implementation.Multiply;
     Divide     = Implementation.Divide;
     Negation   = Implementation.Negation;
     ApplyRules = Implementation.ApplyRules;
 }
Exemple #4
0
        // Constructors

        /// <summary>
        /// Initializes new instance of this type.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="context">The context.</param>
        public Arithmetic(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            Provider   = Implementation.Provider;
            Zero       = Implementation.Zero;
            One        = Implementation.One;
            MaxValue   = Implementation.MaxValue;
            MinValue   = Implementation.MinValue;
            IsSigned   = Implementation.IsSigned;
            Add        = Implementation.Add;
            Subtract   = Implementation.Subtract;
            Multiply   = Implementation.Multiply;
            Divide     = Implementation.Divide;
            Negation   = Implementation.Negation;
            ApplyRules = Implementation.ApplyRules;
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        public NullableArithmetic(IArithmeticProvider provider, ArithmeticRules rule)
            : base(provider, rule)
        {
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        public UInt32Arithmetic(IArithmeticProvider provider, ArithmeticRules rule)
            : base(provider, rule)
        {
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        public CharArithmetic(IArithmeticProvider provider, ArithmeticRules rule)
            : base(provider, rule)
        {
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        public SByteArithmetic(IArithmeticProvider provider, ArithmeticRules rule)
            : base(provider, rule)
        {
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        public DecimalArithmetic(IArithmeticProvider provider, ArithmeticRules rule)
            : base(provider, rule)
        {
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        /// <param name="provider">Arithmetic provider this instance is bound to.</param>
        /// <param name="rules">Arithmetic rules.</param>
        public WrappingArithmetic(IArithmeticProvider provider, ArithmeticRules rules)
            : base(provider, rules)
        {
            ArgumentValidator.EnsureArgumentNotNull(provider, "provider");
            BaseArithmetic = provider.GetArithmetic <TBase>();
        }