Esempio n. 1
0
 public void Encode(ref byte *data, ReadOnlyCollection <MemberBinding> value)
 {
     if (value == null)
     {
         intCodec.Encode(ref data, -1);
         return;
     }
     intCodec.Encode(ref data, value.Count);
     foreach (var memberBinding in value)
     {
         memberBindingCodec.Encode(ref data, memberBinding);
     }
 }
Esempio n. 2
0
        public void Encode(ref byte *data, T value)
        {
            if (value == null)
            {
                typeCodec.Encode(ref data, null);
                return;
            }
            Validate(value);

            typeCodec.Encode(ref data, value.ReflectedType);
            typeCodec.Encode(ref data, value.DeclaringType);
            stringCodec.Encode(ref data, value.Name);
            EncodeAdditional(ref data, value);
        }
Esempio n. 3
0
 protected override void EncodeTyped(ref byte *data, ConditionalExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Test);
     CommonCodec.Encode(ref data, expression.IfTrue);
     CommonCodec.Encode(ref data, expression.IfFalse);
     typeCodec.Encode(ref data, expression.Type);
 }
Esempio n. 4
0
        public void Encode(ref byte *data, MemberInfo value)
        {
            memberTypesCodec.Encode(ref data, value.MemberType);
            switch (value.MemberType)
            {
            case MemberTypes.Constructor:
                constructorInfoCodec.Encode(ref data, (ConstructorInfo)value);
                return;

            case MemberTypes.Event:
                eventInfoCodec.Encode(ref data, (EventInfo)value);
                return;

            case MemberTypes.Field:
                fieldInfoCodec.Encode(ref data, (FieldInfo)value);
                return;

            case MemberTypes.Method:
                methodInfoCodec.Encode(ref data, (MethodInfo)value);
                return;

            case MemberTypes.Property:
                propertyInfoCodec.Encode(ref data, (PropertyInfo)value);
                return;

            default:
                throw new NotSupportedException(string.Format("MemberType '{0}' is not spported for encoding/decoding", value.MemberType));
            }
        }
 protected override void EncodeTyped(ref byte *data, LambdaExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Body);
     stringCodec.Encode(ref data, expression.Name);
     boolCodec.Encode(ref data, expression.TailCall);
     expressionArrayCodec.Encode(ref data, expression.Parameters.Select(x => (Expression)x).ToArray());
 }
Esempio n. 6
0
        public void Encode(ref byte *data, T value)
        {
            var valueType  = value.GetType();
            var valueCodec = codecContainer.GetAbstractManualCodecFor(valueType);

            typeCodec.Encode(ref data, valueType);
            valueCodec.Encode(ref data, value);
        }
        protected override void EncodeTyped(ref byte *data, ConstantExpression expression)
        {
            var type       = expression.Type;
            var valueCodec = CodecContainer.GetAbstractManualCodecFor(type);

            typeCodec.Encode(ref data, type);
            valueCodec.Encode(ref data, expression.Value);
        }
Esempio n. 8
0
 protected override void EncodeTyped(ref byte *data, BinaryExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Left);
     CommonCodec.Encode(ref data, expression.Right);
     boolCodec.Encode(ref data, expression.IsLiftedToNull);
     methodInfoCodec.Encode(ref data, expression.Method);
     CommonCodec.Encode(ref data, expression.Conversion);
 }
Esempio n. 9
0
        public void Encode(ref byte *data, Expression value)
        {
            if (value == null)
            {
                expressionTypeCodec.Encode(ref data, NullExpressionType);
                return;
            }
            var subcodec = GetSubcodec(value.NodeType);

            subcodec.Encode(ref data, value);
        }
Esempio n. 10
0
        public static byte[] EncodeSingle <T>(this IManualCodec <T> codec, T value)
        {
            var data = new byte[codec.CalculateSize(value)];

            fixed(byte *pData = data)
            {
                var p = pData;

                codec.Encode(ref p, value);
            }

            return(data);
        }
Esempio n. 11
0
        public void Encode(ref byte *data, MemberBinding value)
        {
            memberBindingTypeCodec.Encode(ref data, value.BindingType);
            switch (value.BindingType)
            {
            case MemberBindingType.Assignment:
                memberAssignmentCodec.Encode(ref data, (MemberAssignment)value);
                return;

            case MemberBindingType.MemberBinding:
                memberMemberBindingCodec.Encode(ref data, (MemberMemberBinding)value);
                return;

            case MemberBindingType.ListBinding:
                memberListBindingCodec.Encode(ref data, (MemberListBinding)value);
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 12
0
 public void Encode(ref byte *data, MemberListBinding value)
 {
     memberInfoCodec.Encode(ref data, value.Member);
     elementInitArrayCodec.Encode(ref data, value.Initializers.ToArray());
 }
Esempio n. 13
0
 public void Encode(ref byte *data, MemberMemberBinding value)
 {
     memberInfoCodec.Encode(ref data, value.Member);
     memberBindingCollectionCodec.Encode(ref data, value.Bindings);
 }
Esempio n. 14
0
 public void Encode(ref byte *data, Exception value)
 {
     stringCodec.Encode(ref data, value.GetType().AssemblyQualifiedName);
     stringCodec.Encode(ref data, value.Message);
     stringCodec.Encode(ref data, value.StackTrace);
 }
 protected override void EncodeTyped(ref byte *data, UnaryExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Operand);
     typeCodec.Encode(ref data, expression.Type);
     methodInfoCodec.Encode(ref data, expression.Method);
 }
Esempio n. 16
0
 public void Encode(ref byte *data, object value)
 {
     realCodec.Encode(ref data, (T)value);
 }
 protected override void EncodeTyped(ref byte *data, ListInitExpression expression)
 {
     CommonCodec.Encode(ref data, expression.NewExpression);
     elementInitArrayCodec.Encode(ref data, expression.Initializers.ToArray());
 }
Esempio n. 18
0
 protected override void EncodeTyped(ref byte *data, NewExpression expression)
 {
     constructorInfoCodec.Encode(ref data, expression.Constructor);
     expressionArrayCodec.Encode(ref data, expression.Arguments.ToArray());
     memberInfoArrayCodec.Encode(ref data, expression.Members != null ? expression.Members.ToArray() : null);
 }
Esempio n. 19
0
 protected override void EncodeAdditional(ref byte *data, T value)
 {
     typeArrayCodec.Encode(ref data, value.IsGenericMethod ? value.GetGenericArguments() : null);
     typeArrayCodec.Encode(ref data, value.GetParameters().Select(x => x.ParameterType).ToArray());
 }
Esempio n. 20
0
 protected override void EncodeTyped(ref byte *data, MemberExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Expression);
     memberInfoCodec.Encode(ref data, expression.Member);
 }
 protected override void EncodeTyped(ref byte *data, NewArrayExpression expression)
 {
     typeCodec.Encode(ref data, expression.Type.GetElementType());
     expressionArrayCodec.Encode(ref data, expression.Expressions.ToArray());
 }
Esempio n. 22
0
 protected override void EncodeTyped(ref byte *data, BlockExpression expression)
 {
     typeCodec.Encode(ref data, expression.Type);
     expressionArrayCodec.Encode(ref data, expression.Variables.Select(x => (Expression)x).ToArray());
     expressionArrayCodec.Encode(ref data, expression.Expressions.ToArray());
 }
Esempio n. 23
0
 protected override void EncodeTyped(ref byte *data, TypeBinaryExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Expression);
     typeCodec.Encode(ref data, expression.TypeOperand);
 }
Esempio n. 24
0
 protected override unsafe void EncodeTyped(ref byte *data, InvocationExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Expression);
     expressionArrayCodec.Encode(ref data, expression.Arguments.ToArray());
 }
 protected override void EncodeTyped(ref byte *data, MethodCallExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Object);
     methodInfoCodec.Encode(ref data, expression.Method);
     expressionArrayCodec.Encode(ref data, expression.Arguments.ToArray());
 }
 protected override void EncodeTyped(ref byte *data, ParameterExpression expression)
 {
     typeCodec.Encode(ref data, expression.Type);
     stringCodec.Encode(ref data, expression.Name);
 }
Esempio n. 27
0
 public void Encode(ref byte *data, MemberAssignment value)
 {
     memberInfoCodec.Encode(ref data, value.Member);
     expressionCodec.Encode(ref data, value.Expression);
 }
Esempio n. 28
0
 protected override void EncodeTyped(ref byte *data, IndexExpression expression)
 {
     CommonCodec.Encode(ref data, expression.Object);
     propertyInfoCodec.Encode(ref data, expression.Indexer);
     expressionArrayCodec.Encode(ref data, expression.Arguments.ToArray());
 }
Esempio n. 29
0
 public void Encode(ref byte *data, ElementInit value)
 {
     methodInfoCodec.Encode(ref data, value.AddMethod);
     expressionArrayCodec.Encode(ref data, value.Arguments.ToArray());
 }