Example #1
0
        public void MaterializeEnumTypeShouldWork()
        {
            OData.ODataEnumValue enumValue = new OData.ODataEnumValue("blue");
            OData.ODataProperty  property  = new OData.ODataProperty {
                Name = "enumProperty", Value = enumValue
            };
            var enumPolicy = new EnumValueMaterializationPolicy(new TestMaterializerContext());
            var result     = enumPolicy.MaterializeEnumTypeProperty(typeof(Color), property);

            property.GetMaterializedValue().Should().Be(Color.Blue);
            result.Should().Be(Color.Blue);
        }
        public override Microsoft.OData.ODataProperty CreateStructuralProperty(IEdmStructuralProperty structuralProperty, ResourceContext resourceContext)
        {
            Microsoft.OData.ODataProperty property = base.CreateStructuralProperty(structuralProperty, resourceContext);

            // find the class of the current property if it's in the list
            //List<string> classPropertiesToHide;
            //if (propertiesToHide.TryGetValue(resourceContext.StructuredType.FullTypeName(), out classPropertiesToHide))
            //{
            //    // if the current property is in the list of properties to hide
            //    if (classPropertiesToHide.Contains(property.Name))
            //    {
            //        // return null to not serialize the property
            //        // for future reference, if the desire was to set the field as null, you'd do "property.Value = null"
            //        return null;
            //    }
            //}
            return(property);
        }
Example #3
0
 /// <summary>
 /// Asynchronously writes an <see cref="ODataProperty"/> as message payload.
 /// </summary>
 /// <param name="odataProperty">The OData property to write</param>
 /// <returns>A task representing the asynchronous operation of writing the OData property.</returns>
 /// <remarks>It is the responsibility of this method to flush the output before the task finishes.</remarks>
 public virtual Task WritePropertyAsync(ODataProperty odataProperty)
 {
     throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Property);
 }
Example #4
0
 /// <summary>
 /// Writes an <see cref="ODataProperty"/> as message payload.
 /// </summary>
 /// <param name="property">The property to write.</param>
 /// <remarks>It is the responsibility of this method to flush the output before the method returns.</remarks>
 public virtual void WriteProperty(ODataProperty property)
 {
     throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.Property);
 }
Example #5
0
 /// <summary> Asynchronously write a primitive property within a resource. </summary>
 /// <returns>A task instance that represents the asynchronous write operation.</returns>
 /// <param name="primitiveProperty">The primitive property to write.</param>
 public virtual Task WriteStartAsync(ODataProperty primitiveProperty)
 {
     return(TaskUtils.GetTaskForSynchronousOperation(() => this.WriteStart(primitiveProperty)));
 }
Example #6
0
 public ODataWriter Write(ODataProperty primitiveProperty)
 {
     WriteStart(primitiveProperty);
     WriteEnd();
     return(this);
 }
 public void ValidatePropertyUniqueness(ODataProperty property)
 {
     // nop
 }
 /// <summary>
 /// Provide additional serialization information to the <see cref="ODataWriter"/> for <paramref name="property"/>.
 /// </summary>
 /// <param name="property">The instance to set the serialization info.</param>
 /// <param name="serializationInfo">The serialization info to set.</param>
 public static void SetSerializationInfo(this ODataProperty property, ODataPropertySerializationInfo serializationInfo)
 {
     ExceptionUtils.CheckArgumentNotNull(property, "property");
     property.SerializationInfo = serializationInfo;
 }