Пример #1
0
        public void LoadCross(FudgeMsg message)
        {
            var values = new Dictionary <Tuple <Currency, Currency>, CurrencyMatrixValue>();

            foreach (IFudgeField field in message)
            {
                CurrencyMatrixValue cross = CurrencyMatrixValue.Create(Currency.Create(field.Name));
                var value = field.Value;
                foreach (IFudgeField field2 in (IFudgeFieldContainer)value)
                {
                    Currency source = Currency.Create(field2.Name);
                    var      value2 = field2.Value;
                    if (value2 is IFudgeFieldContainer)
                    {
                        Currency target = Currency.Create(((IFudgeFieldContainer)value2).First().Name);
                        values.Add(Tuple.Create(source, target), cross);
                    }
                    else
                    {
                        Currency target = Currency.Create((string)value2);
                        values.Add(Tuple.Create(source, target), cross);
                        values.Add(Tuple.Create(target, source), cross);
                    }
                }
                foreach (var valueEntry in values)
                {
                    AddConversion(valueEntry.Key.Item1, valueEntry.Key.Item1, valueEntry.Value);
                }
            }
        }
Пример #2
0
        public void LoadReq(FudgeMsg message, IFudgeDeserializer deserializer)
        {
            var values = new Dictionary <Tuple <Currency, Currency>, CurrencyMatrixValue>();

            foreach (var field in message)
            {
                Currency source = Currency.Create(field.Name);
                foreach (var field2 in (IFudgeFieldContainer)field.Value)
                {
                    Currency target = Currency.Create(field2.Name);

                    if (field2.Value is IFudgeFieldContainer)
                    {
                        CurrencyMatrixValue value = deserializer.FromField <CurrencyMatrixValue.CurrencyMatrixValueRequirement>(field2);
                        values.Add(Tuple.Create(source, target), value);
                        values.Add(Tuple.Create(target, source), value.Reciprocal);
                    }
                    else
                    {
                        values.Remove(Tuple.Create(target, source));
                    }
                }
            }
            foreach (var valueEntry in values)
            {
                AddConversion(valueEntry.Key.Item1, valueEntry.Key.Item2, valueEntry.Value);
            }
        }
Пример #3
0
        public CurrencyMatrixValue GetConversion(Currency source, Currency target)
        {
            if (source.Equals(target))
            {
                // This shouldn't happen in sensible code
                return(CurrencyMatrixValue.Create(1.0));
            }
            Dictionary <Currency, CurrencyMatrixValue> targets;

            if (_values.TryGetValue(source, out targets))
            {
                CurrencyMatrixValue ret;
                if (targets.TryGetValue(target, out ret))
                {
                    return(ret);
                }
            }
            return(null);
        }
Пример #4
0
        private void AddConversion(Currency source, Currency target, CurrencyMatrixValue rate)
        {
            Dictionary <Currency, CurrencyMatrixValue> conversions = _values.GetOrAdd(source, new Dictionary <Currency, CurrencyMatrixValue>());

            conversions[target] = rate;
        }
Пример #5
0
 protected override bool EqualsInner(CurrencyMatrixValue other)
 {
     return(((CurrencyMatrixCross)other)._crossCurrency == _crossCurrency);
 }
Пример #6
0
 protected override bool EqualsInner(CurrencyMatrixValue other)
 {
     return(((CurrencyMatrixFixed)other)._fixedValue == _fixedValue); // TODO : this is an odd thing to do, since == on doubles rarely does what you want.  But it's what the Java side does
 }
Пример #7
0
            protected override bool EqualsInner(CurrencyMatrixValue other)
            {
                var otherReq = (CurrencyMatrixValueRequirement)other;

                return(otherReq._valueRequirement == ValueRequirement && otherReq._reciprocal == _reciprocal);
            }