Example #1
0
        public override TypeCodec GetCodec(Operator op, bool optional)
        {
            if (op == Operator.Delta)
                return optional ? TypeCodec.NullableStringDelta : TypeCodec.StringDelta;

            return base.GetCodec(op, optional);
        }
        public override TypeCodec GetCodec(Operator op, bool optional)
        {
            if (op.Equals(Operator.Delta))
                return optional ? TypeCodec.NullableInteger : TypeCodec.Integer;

            return base.GetCodec(op, optional);
        }
Example #3
0
 static Operator()
 {
     None = new NoneOperator("none");
     Constant = new ConstantOperator("constant");
     Default = new DefaultOperator("default");
     Copy = new CopyOperator("copy");
     Delta = new DeltaOperator("delta");
 }
Example #4
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;
 }
Example #5
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);
        }
Example #7
0
 internal bool Equals(Operator other)
 {
     return _name.Equals(other._name);
 }
 internal IncrementIntegerOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 internal DeltaIntegerOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 protected internal AlwaysPresentOperatorCodec(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");
        }
Example #13
0
 public Scalar(string name, FastType fastType, Operator op, ScalarValue defaultValue,
               bool optional)
     : this(new QName(name), fastType, op, defaultValue, optional)
 {
 }
Example #14
0
 protected internal AlwaysPresentOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 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);
 }
 protected internal OptionallyPresentOperatorCodec(Operator op, IEnumerable<FastType> types)
     : base(op, types)
 {
 }
Example #20
0
 public override TypeCodec GetCodec(Operator op, bool optional)
 {
     return optional ? _nullableCodec : _codec;
 }
Example #21
0
 public abstract TypeCodec GetCodec(Operator op, bool optional);
Example #22
0
 public Scalar(QName name, FastType fastType, Operator op, ScalarValue defaultValue,
               bool optional)
     : this(name, fastType, op, op.GetCodec(fastType), defaultValue, optional)
 {
 }
 internal ConstantOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 internal TailOperatorCodec(Operator op, FastType[] types)
     : base(op, types)
 {
 }
 protected internal OperatorCodec(Operator op, IEnumerable<FastType> types)
 {
     _operator = op;
     foreach (FastType t in types)
         OperatorMap[Tuple.Create(op, t)] = this;
 }