Ejemplo n.º 1
0
 public override object WrapValue(GraphEntityInfo entityInfo, GraphTypeInfo typeInfo, object value, bool isSpecified)
 {
     if (typeInfo.TypeRepresentation.IsGenericType(typeof(Optional <>)))
     {
         return(Optional.Construct(typeInfo, value, isSpecified));
     }
     return(value);
 }
Ejemplo n.º 2
0
        public void Can_Construct_WithNull()
        {
            var typeResolver  = new TypeResolver();
            var typeInfo      = typeof(Optional <int?>).GetTypeInfo();
            var graphTypeInfo = new GraphTypeInfo(typeResolver, typeInfo);
            var optional      = (Optional <int?>)Optional.Construct(graphTypeInfo, null, true);

            Assert.IsNotNull(optional);
            Assert.IsNull(optional.Value);
        }
Ejemplo n.º 3
0
        public void Can_Construct_WithNullable()
        {
            int?value         = 2;
            var typeResolver  = new TypeResolver();
            var typeInfo      = typeof(Optional <int?>).GetTypeInfo();
            var graphTypeInfo = new GraphTypeInfo(typeResolver, typeInfo);
            var optional      = (Optional <int?>)Optional.Construct(graphTypeInfo, value, true);

            Assert.IsNotNull(optional);
            Assert.IsNotNull(optional.Value);
            Assert.AreEqual(value, optional.Value);
        }