/// <summary> /// Converts the serializable named value into a normal named value /// </summary> /// <param name="serializableNamedValue">The serializable named value</param> /// <returns>The value, but in types common to the rest of Taupo</returns> public NamedValue Convert(SerializableNamedValue serializableNamedValue) { ExceptionUtilities.CheckArgumentNotNull(serializableNamedValue, "serializableNamedValue"); var value = serializableNamedValue.Value; #if WIN8 var dateTimeOffsetValue = value as Microsoft.Test.Taupo.Astoria.Contracts.WebServices.DataOracleService.Win8.DateTimeOffset; if (dateTimeOffsetValue != null) { value = new System.DateTimeOffset(dateTimeOffsetValue.DateTime.Year, dateTimeOffsetValue.DateTime.Month, dateTimeOffsetValue.DateTime.Day, dateTimeOffsetValue.DateTime.Hour, dateTimeOffsetValue.DateTime.Minute, dateTimeOffsetValue.DateTime.Second, TimeSpan.FromMinutes(dateTimeOffsetValue.OffsetMinutes)); } #endif var spatialValue = value as SerializableSpatialData; if (spatialValue != null) { ExceptionUtilities.CheckObjectNotNull(this.SpatialFormatter, "Cannot convert spatial data without SpatialFormatter dependency being set"); var spatialTypeKind = SpatialUtilities.InferSpatialTypeKind(spatialValue.BaseTypeName); value = this.SpatialFormatter.Parse(spatialTypeKind, spatialValue.WellKnownTextRepresentation); } else if (value is SerializableEmptyData) { value = EmptyData.Value; } return(new NamedValue(serializableNamedValue.Name, value)); }
/// <summary> /// Converts the serializable named value into a normal named value /// </summary> /// <param name="serializableNamedValue">The serializable named value</param> /// <returns>The value, but in types common to the rest of Taupo</returns> public NamedValue Convert(SerializableNamedValue serializableNamedValue) { ExceptionUtilities.CheckArgumentNotNull(serializableNamedValue, "serializableNamedValue"); var value = serializableNamedValue.Value; var spatialValue = value as SerializableSpatialData; if (spatialValue != null) { ExceptionUtilities.CheckObjectNotNull(this.SpatialFormatter, "Cannot convert spatial data without SpatialFormatter dependency being set"); var spatialTypeKind = SpatialUtilities.InferSpatialTypeKind(spatialValue.BaseTypeName); value = this.SpatialFormatter.Parse(spatialTypeKind, spatialValue.WellKnownTextRepresentation); } else if (value is SerializableEmptyData) { value = EmptyData.Value; } return(new NamedValue(serializableNamedValue.Name, value)); }
private void SynchronizeNavigationProperty(QueryEntityType entitySetBaseType, QueryStructuralValue entity, SerializableNamedValue namedValue, IDictionary <EntityDataKey, QueryStructuralValue> existingEntityGraph) { var reference = namedValue.Value as SerializableEntity; if (reference != null) { QueryStructuralValue synchronized; if (reference.EntitySetName == entitySetBaseType.EntitySet.Name) { // for self references, we don't need to rebuild the set of existing entities synchronized = this.FindAndSynchronizeEntity(entitySetBaseType, reference, existingEntityGraph); } else { synchronized = this.FindAndSynchronizeEntity(reference); } entity.SetValue(namedValue.Name, synchronized); return; } var collection = namedValue.Value as IEnumerable <SerializableEntity>; if (collection != null) { var oldCollection = entity.GetCollectionValue(namedValue.Name); // clear out the old collection, if it exists if (entity.MemberNames.Contains(namedValue.Name)) { oldCollection.Elements.Clear(); } else { // by default we set IsSorted to true, enabling ordering verification. oldCollection = QueryCollectionValue.Create(oldCollection.Type.ElementType, new QueryValue[0], true); } entity.SetValue(namedValue.Name, oldCollection); // go through the new elements, synchronize them, and add them foreach (var related in collection) { QueryStructuralValue synchronized; if (related.EntitySetName == entitySetBaseType.EntitySet.Name) { // for self references, we don't need to rebuild the set of existing entities synchronized = this.FindAndSynchronizeEntity(entitySetBaseType, related, existingEntityGraph); } else { synchronized = this.FindAndSynchronizeEntity(related); } oldCollection.Elements.Add(synchronized); } return; } ExceptionUtilities.Assert(namedValue.Value == null, "Value of navigation property '{0}' was not a reference, a collection of references, or null. Value was '{1}'", namedValue.Name, namedValue.Value); entity.SetValue(namedValue.Name, entity.Type.Properties.Single(p => p.Name == namedValue.Name).PropertyType.NullValue); }
/// <summary> /// Converts the serializable named value into a normal named value /// </summary> /// <param name="serializableNamedValue">The serializable named value</param> /// <returns>The value, but in types common to the rest of Taupo</returns> public NamedValue Convert(SerializableNamedValue serializableNamedValue) { ExceptionUtilities.CheckArgumentNotNull(serializableNamedValue, "serializableNamedValue"); var value = serializableNamedValue.Value; #if WIN8 var dateTimeOffsetValue = value as Microsoft.Test.Taupo.Astoria.Contracts.WebServices.DataOracleService.Win8.DateTimeOffset; if (dateTimeOffsetValue != null) { value = new System.DateTimeOffset(dateTimeOffsetValue.DateTime.Year, dateTimeOffsetValue.DateTime.Month, dateTimeOffsetValue.DateTime.Day, dateTimeOffsetValue.DateTime.Hour, dateTimeOffsetValue.DateTime.Minute, dateTimeOffsetValue.DateTime.Second, TimeSpan.FromMinutes(dateTimeOffsetValue.OffsetMinutes)); } #endif var spatialValue = value as SerializableSpatialData; if (spatialValue != null) { ExceptionUtilities.CheckObjectNotNull(this.SpatialFormatter, "Cannot convert spatial data without SpatialFormatter dependency being set"); var spatialTypeKind = SpatialUtilities.InferSpatialTypeKind(spatialValue.BaseTypeName); value = this.SpatialFormatter.Parse(spatialTypeKind, spatialValue.WellKnownTextRepresentation); } else if (value is SerializableEmptyData) { value = EmptyData.Value; } return new NamedValue(serializableNamedValue.Name, value); }