public ComposedScalar(ComposedScalar other)
     : base(other)
 {
     _fastType = other._fastType;
     _fields = other._fields.CloneArray();
     _valueConverter = other._valueConverter;
 }
 public ComposedScalar(QName name, FastType fastType, Scalar[] fields, bool optional,
                       IComposedValueConverter valueConverter)
     : base(name, optional)
 {
     _fields = fields;
     _valueConverter = valueConverter;
     _fastType = fastType;
 }
Beispiel #3
0
 public Scalar(Scalar other)
     : base(other)
 {
     _defaultValue = (ScalarValue) other._defaultValue.Clone();
     _fastType = other._fastType;
     _initialValue = (ScalarValue) other._initialValue.Clone();
     _operator = other._operator;
     _operatorCodec = other._operatorCodec;
     _typeCodec = other._typeCodec;
     _dictionary = other._dictionary;
 }
Beispiel #4
0
 private Scalar(QName name, FastType fastType, Operator op, OperatorCodec operatorCodec,
                ScalarValue defaultValue, bool optional)
     : base(name, optional)
 {
     _operator = op;
     _operatorCodec = operatorCodec;
     _dictionary = DictionaryFields.Global;
     _defaultValue = defaultValue ?? ScalarValue.Undefined;
     _fastType = fastType;
     _typeCodec = fastType.GetCodec(op, optional);
     _initialValue = (defaultValue == null || defaultValue.IsUndefined) ? _fastType.DefaultValue : defaultValue;
     op.Validate(this);
 }
        protected static void AssertComposedScalarField(ComposedScalar field, FastType type, String name,
                                                        Operator exponentOp,
                                                        ScalarValue exponentValue, Operator mantissaOp,
                                                        ScalarValue mantissaValue)
        {
            Assert.AreEqual(type, field.FastType);
            Assert.AreEqual(name, field.Name);
            Scalar[] fields = field.Fields;
            Assert.AreEqual(exponentOp, fields[0].Operator);
            Assert.AreEqual(exponentValue, fields[0].DefaultValue);

            Assert.AreEqual(mantissaOp, fields[1].Operator);
            Assert.AreEqual(mantissaValue, fields[1].DefaultValue);
        }
Beispiel #6
0
 public override OperatorCodec GetCodec(FastType type)
 {
     return OperatorCodec.CopyAll;
 }
Beispiel #7
0
 private static void ValidateDecodedValueIsCorrectForType(ScalarValue value, FastType type)
 {
     if (value == null)
         return;
     type.ValidateValue(value);
 }
 internal IncrementIntegerOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
Beispiel #9
0
 public virtual OperatorCodec GetCodec(FastType type)
 {
     return OperatorCodec.GetCodec(this, type);
 }
 protected internal AlwaysPresentOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 internal DeltaIntegerOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 protected static void AssertScalarField(IFieldSet fieldSet, int fieldIndex, FastType type, String name,
                                         OperatorCodec operatorCodec,
                                         ScalarValue defaultValue)
 {
     var field = (Scalar) fieldSet.GetField(fieldIndex);
     AssertScalarField(field, type, name);
     Assert.AreEqual(operatorCodec, field.OperatorCodec);
     Assert.AreEqual(defaultValue, field.DefaultValue);
 }
 public ComposedScalar(string name, FastType fastType, Scalar[] fields, bool optional,
                       IComposedValueConverter valueConverter)
     : this(new QName(name), fastType, fields, optional, valueConverter)
 {
 }
Beispiel #14
0
 private static void ValidateDictionaryTypeAgainstFieldType(ScalarValue priorValue, FastType type)
 {
     if (priorValue == null || priorValue.IsUndefined)
         return;
     if (!type.IsValueOf(priorValue))
     {
         Global.ErrorHandler.OnError(null, DynError.InvalidType,
                                     "The value '{0}' is not valid for the type {1}", priorValue, type);
     }
 }
Beispiel #15
0
 public Scalar(QName name, FastType fastType, Operator op, ScalarValue defaultValue,
               bool optional)
     : this(name, fastType, op, op.GetCodec(fastType), defaultValue, optional)
 {
 }
 private static void AssertScalarField(Scalar field, FastType type, string name)
 {
     Assert.AreEqual(name, field.Name);
     Assert.AreEqual(type, field.FastType);
 }
 protected static void AssertSequenceLengthField(Sequence sequence, String name, FastType type, Operator op)
 {
     Assert.AreEqual(type, sequence.Length.FastType);
     Assert.AreEqual(name, sequence.Length.Name);
     Assert.AreEqual(op, sequence.Length.Operator);
 }
 protected static void AssertScalarField(Scalar scalar, FastType type, String name, String id, String ns,
                                         String dictionary, String key, String keyNamespace, Operator op,
                                         ScalarValue defaultVal, bool optional)
 {
     var qname = new QName(name, ns);
     Assert.AreEqual(type, scalar.FastType);
     Assert.AreEqual(op, scalar.Operator);
     Assert.AreEqual(qname, scalar.QName);
     var keyName = new QName(key, keyNamespace);
     Assert.AreEqual(keyName, scalar.Key);
     if (id == null)
     {
         Assert.True(scalar.IsIdNull());
     }
     else
     {
         Assert.AreEqual(id, scalar.Id);
     }
     Assert.AreEqual(dictionary, scalar.Dictionary);
     Assert.AreEqual(defaultVal, scalar.DefaultValue);
     Assert.AreEqual(optional, scalar.IsOptional);
 }
 protected static void AssertScalarField(Scalar scalar, FastType type, String name, String id, String ns,
                                         String dictionary, String key, Operator op,
                                         ScalarValue defaultVal, bool optional)
 {
     AssertScalarField(scalar, type, name, id, ns, dictionary, key, ns, op, defaultVal, optional);
 }
 protected static void AssertScalarField(IFieldSet fieldSet, int fieldIndex, FastType type, String name, Operator op)
 {
     var field = (Scalar) fieldSet.GetField(fieldIndex);
     AssertScalarField(field, type, name);
     Assert.AreEqual(op, field.Operator);
 }
Beispiel #21
0
 public Scalar(string name, FastType fastType, Operator op, ScalarValue defaultValue,
               bool optional)
     : this(new QName(name), fastType, op, defaultValue, optional)
 {
 }
 internal ConstantOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
Beispiel #23
0
 public Scalar(QName name, FastType fastType, OperatorCodec operatorCodec, ScalarValue defaultValue,
               bool optional)
     : this(name, fastType, operatorCodec.Operator, operatorCodec, defaultValue, optional)
 {
 }
 internal TailOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 internal DefaultOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
        public static OperatorCodec GetCodec(Operator op, FastType type)
        {
            Tuple<Operator, FastType> key = Tuple.Create(op, type);

            OperatorCodec codec;
            if (OperatorMap.TryGetValue(key, out codec))
                return codec;

            Global.ErrorHandler.OnError(null, StaticError.OperatorTypeIncomp,
                                        "The operator '{0}' is not compatible with type '{1}'", op, type);
            throw new ArgumentOutOfRangeException("op" + ",type", key, "Not found");
        }