Skip to content

Commit

Permalink
Small logic change and update some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chinadragon0515 committed Aug 23, 2016
1 parent 535ec39 commit 9d055f2
Show file tree
Hide file tree
Showing 54 changed files with 276 additions and 397 deletions.
5 changes: 5 additions & 0 deletions src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.OData.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OData.Edm, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -85,6 +89,7 @@
<Compile Include="Operation\IOperationAuthorizer.cs" />
<Compile Include="Operation\IOperationExecutor.cs" />
<Compile Include="Operation\OperationContext.cs" />
<Compile Include="RestierContainerBuilder.cs" />
<Compile Include="ServiceCollectionExtensions.cs" />
<Compile Include="Model\IModelBuilder.cs" />
<Compile Include="Model\IModelMapper.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Web.OData.Formatter.Deserialization;
using Microsoft.OData.Edm;

Expand All @@ -11,30 +12,17 @@ namespace Microsoft.Restier.Publishers.OData.Formatter
/// </summary>
public class DefaultRestierDeserializerProvider : DefaultODataDeserializerProvider
{
private static readonly DefaultRestierDeserializerProvider SingletonInstanceField
= new DefaultRestierDeserializerProvider();

private RestierEnumDeserializer enumDeserializer;

/// <summary>
/// Initializes a new instance of the <see cref="DefaultRestierDeserializerProvider" /> class.
/// </summary>
public DefaultRestierDeserializerProvider()
/// <param name="rootContainer">The container to get the service</param>
public DefaultRestierDeserializerProvider(IServiceProvider rootContainer) : base(rootContainer)
{
this.enumDeserializer = new RestierEnumDeserializer();
}

/// <summary>
/// Gets the default instance of the <see cref="DefaultRestierDeserializerProvider"/>.
/// </summary>
internal static DefaultRestierDeserializerProvider SingletonInstance
{
get
{
return SingletonInstanceField;
}
}

/// <inheritdoc />
public override ODataEdmTypeDeserializer GetEdmTypeDeserializer(IEdmTypeReference edmType)
{
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override void WriteObject(
ODataMessageWriter messageWriter,
ODataSerializerContext writeContext)
{
NonEntityCollectionResult collectionResult = graph as NonEntityCollectionResult;
NonResourceCollectionResult collectionResult = graph as NonResourceCollectionResult;
if (collectionResult != null)
{
graph = collectionResult.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Web.OData.Extensions;
using System.Web.OData.Formatter.Serialization;
using Microsoft.OData.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OData;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Library;

namespace Microsoft.Restier.Publishers.OData.Formatter
{
Expand Down Expand Up @@ -93,7 +94,8 @@ internal static object ConvertToPayloadValue(object value, ODataSerializerContex
}
}

var payloadValueConverter = writeContext.Model.GetPayloadValueConverter();
var payloadValueConverter
= writeContext.Request.GetRequestContainer().GetService<ODataPayloadValueConverter>();
return payloadValueConverter.ConvertToPayloadValue(value, edmTypeReference);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@

using System;
using System.Web.OData.Formatter.Serialization;
using Microsoft.OData.Core;
using Microsoft.OData;

namespace Microsoft.Restier.Publishers.OData.Formatter
{
/// <summary>
/// The serializer for complex result.
/// The serializer for resource result, and now for complex only,
/// for entity type, WebApi OData resource serializer will be used.
/// </summary>
public class RestierComplexTypeSerializer : ODataComplexTypeSerializer
public class RestierResourceSerializer : ODataResourceSerializer
{
/// <summary>
/// Initializes a new instance of the <see cref="RestierComplexTypeSerializer" /> class.
/// Initializes a new instance of the <see cref="RestierResourceSerializer" /> class.
/// </summary>
/// <param name="provider">The serializer provider.</param>
public RestierComplexTypeSerializer(ODataSerializerProvider provider)
: base(provider)
public RestierResourceSerializer(ODataSerializerProvider provider)
: base(provider)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void WriteObject(
ODataMessageWriter messageWriter,
ODataSerializerContext writeContext)
{
EntityCollectionResult collectionResult = graph as EntityCollectionResult;
ResourceSetResult collectionResult = graph as ResourceSetResult;
if (collectionResult != null)
{
graph = collectionResult.Query;
Expand All @@ -63,9 +63,9 @@ private bool TryWriteAggregationResult(
IEdmTypeReference elementType = feedType.AsCollection().ElementType();
if (elementType.IsEntity())
{
IEdmEntitySetBase entitySet = writeContext.NavigationSource as IEdmEntitySetBase;
IEdmEntityTypeReference entityType = elementType.AsEntity();
ODataWriter writer = messageWriter.CreateODataResourceSetWriter(entitySet, entityType.EntityDefinition());
var entitySet = writeContext.NavigationSource as IEdmEntitySetBase;
var entityType = elementType.AsEntity();
var writer = messageWriter.CreateODataResourceSetWriter(entitySet, entityType.EntityDefinition());
WriteObjectInline(graph, feedType, writer, writeContext);
return true;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Web.OData, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160815\lib\net45\System.Web.OData.dll</HintPath>
<HintPath>..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -85,8 +85,7 @@
<Compile Include="Batch\RestierChangeSetProperty.cs" />
<Compile Include="Batch\RestierBatchChangeSetRequestItem.cs" />
<Compile Include="Formatter\Deserialization\DeserializationHelpers.cs" />
<Compile Include="Formatter\Deserialization\RestierDeserializerProviderProxy.cs" />
<Compile Include="Formatter\Serialization\RestierSerializerProviderProxy.cs" />
<Compile Include="Formatter\Serialization\RestierResourceSerializer.cs" />
<Compile Include="Model\ApiConfigurationExtensions.cs" />
<Compile Include="Model\ModelMapper.cs" />
<Compile Include="Model\OperationAttribute.cs" />
Expand All @@ -99,17 +98,17 @@
<Compile Include="Formatter\Serialization\DefaultRestierSerializerProvider.cs" />
<Compile Include="Formatter\Serialization\RestierCollectionSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierEnumSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierComplexTypeSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierRawSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierPrimitiveSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierFeedSerializer.cs" />
<Compile Include="Formatter\Serialization\RestierResourceSetSerializer.cs" />
<Compile Include="Operation\OperationExecutor.cs" />
<Compile Include="Results\NonResourceCollectionResult.cs" />
<Compile Include="Results\ResourceSetResult.cs" />
<Compile Include="Routing\HttpConfigurationExtensions.cs" />
<Compile Include="HttpRequestMessageExtensions.cs" />
<Compile Include="Query\RestierQueryExecutor.cs" />
<Compile Include="Query\RestierQueryBuilder.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Formatter\RestierFormattingAttribute.cs" />
<Compile Include="Filters\RestierExceptionFilterAttribute.cs" />
<Compile Include="RestierPayloadValueConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -121,14 +120,11 @@
<Compile Include="RestierController.cs" />
<Compile Include="Results\BaseCollectionResult.cs" />
<Compile Include="Results\EnumResult.cs" />
<Compile Include="Results\NonEntityCollectionResult.cs" />
<Compile Include="Results\EntityCollectionResult.cs" />
<Compile Include="Results\ComplexResult.cs" />
<Compile Include="Results\RawResult.cs" />
<Compile Include="Results\PrimitiveResult.cs" />
<Compile Include="Results\BaseSingleResult.cs" />
<Compile Include="Results\BaseResult.cs" />
<Compile Include="Routing\RestierContainerBuilder.cs" />
<Compile Include="Routing\RestierRoutingConvention.cs" />
<Compile Include="Filters\ValidationResultDto.cs" />
<Compile Include="..\Shared\SharedResources\SharedResources.OData.Designer.cs">
Expand Down
Loading

0 comments on commit 9d055f2

Please sign in to comment.