Esempio 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;
 }
Esempio 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)
                        );
                }
            }
        }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
 }