Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the ThriftParameter class with the specified values.
 /// </summary>
 public ThriftParameter(short id, string name, TypeInfo typeInfo, ThriftConverter converter)
     : base(typeInfo, converter)
 {
     Id   = id;
     Name = name;
     UnderlyingTypeInfo = typeInfo;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the ThriftWireField class with the specified values.
        /// </summary>
        private ThriftWireField(short id, string name,
                                ThriftType wireType, TypeInfo underlyingTypeInfo,
                                ThriftWireFieldState state, object defaultValue,
                                ThriftConverter converter,
                                Expression getter, Func <Expression, Expression> setter)
        {
            Id                 = id;
            Name               = name;
            WireType           = wireType;
            UnderlyingTypeInfo = underlyingTypeInfo;
            Kind               = state;
            DefaultValue       = defaultValue;
            Converter          = converter;
            Getter             = getter;
            Setter             = setter;

            // NullChecker is required because UWP doesn't implement Equal/NotEqual on nullables.
            if (getter != null)
            {
                if (Nullable.GetUnderlyingType(underlyingTypeInfo.AsType()) == null)
                {
                    if (!underlyingTypeInfo.IsValueType)
                    {
                        NullChecker = Expression.Equal(
                            getter,
                            Expression.Constant(null)
                            );
                    }
                }
                else
                {
                    // Can't use HasValue, not supported by UWP's expression interpreter
                    NullChecker = Expression.Call(
                        typeof(object),
                        "ReferenceEquals",
                        Type.EmptyTypes,
                        Expression.Convert(
                            getter,
                            typeof(object)
                            ),
                        Expression.Constant(null)
                        );
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the ThriftField class with the specified values.
 /// </summary>
 public ThriftField(short id, string name, bool isRequired, object defaultValue, ThriftConverter converter, PropertyInfo backingProperty)
     : base(backingProperty.PropertyType.GetTypeInfo(), converter)
 {
     Id              = id;
     Name            = name;
     IsRequired      = isRequired;
     DefaultValue    = defaultValue;
     BackingProperty = backingProperty;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the ThriftConvertibleValue class with the specified underlying type and converter.
 /// </summary>
 protected ThriftConvertibleValue(TypeInfo typeInfo, ThriftConverter converter)
 {
     WireType  = ThriftType.Get(converter?.FromType ?? typeInfo.AsType());
     Converter = converter;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the ThriftReturnValue class with the specified values.
 /// </summary>
 public ThriftReturnValue(TypeInfo typeInfo, ThriftConverter converter)
     : base(typeInfo, converter)
 {
     UnderlyingTypeInfo = typeInfo;
 }