/// <summary>
 /// Serializes the object to JSON.
 /// </summary>
 /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
 /// <param name="obj">The object to serialize to JSON.</param>
 internal static void Serialize(JsonWriter writer, BinaryPropertyValue obj)
 {
     // Required properties are always serialized, optional properties are serialized when not null.
     writer.WriteStartObject();
     writer.WriteProperty(obj.Kind, "Kind", PropertyValueKindConverter.Serialize);
     writer.WriteProperty(obj.Data, "Data", ByteArrayConverter.Serialize);
     writer.WriteEndObject();
 }
Example #2
0
        /// <inheritdoc/>
        protected override void ProcessRecordInternal()
        {
            PropertyValue propertyValue = null;

            if (this.Binary.IsPresent)
            {
                propertyValue = new BinaryPropertyValue(
                    data: this.BinaryData);
            }
            else if (this.Int64.IsPresent)
            {
                propertyValue = new Int64PropertyValue(
                    data: this.Data);
            }
            else if (this.Double.IsPresent)
            {
                propertyValue = new DoublePropertyValue(
                    data: double.Parse(this.Data));
            }
            else if (this.String.IsPresent)
            {
                propertyValue = new StringPropertyValue(
                    data: this.Data);
            }
            else if (this.Guid.IsPresent)
            {
                propertyValue = new GuidPropertyValue(
                    data: new Guid(this.Data));
            }

            var propertyDescription = new PropertyDescription(
                propertyName: this.PropertyName,
                value: propertyValue,
                customTypeId: this.CustomTypeId);

            this.ServiceFabricClient.Properties.PutPropertyAsync(
                nameId: this.NameId,
                propertyDescription: propertyDescription,
                serverTimeout: this.ServerTimeout,
                cancellationToken: this.CancellationToken).GetAwaiter().GetResult();

            Console.WriteLine("Success!");
        }