-
Notifications
You must be signed in to change notification settings - Fork 473
/
UnqualifiedCallAndEnumPrefixFreeResolver.cs
81 lines (71 loc) · 3.24 KB
/
UnqualifiedCallAndEnumPrefixFreeResolver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//-----------------------------------------------------------------------------
// <copyright file="UnqualifiedCallAndEnumPrefixFreeResolver.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
namespace Microsoft.AspNet.OData
{
/// <summary>
/// The OData uri resolver wrapper for Enum prefix free and unqualified function call.
/// </summary>
public class UnqualifiedCallAndEnumPrefixFreeResolver : ODataUriResolver
{
private readonly StringAsEnumResolver _stringAsEnum = new StringAsEnumResolver();
private readonly UnqualifiedODataUriResolver _unqualified = new UnqualifiedODataUriResolver();
private bool _enableCaseInsensitive;
/// <inheritdoc/>
public override bool EnableCaseInsensitive
{
get
{
return _enableCaseInsensitive;
}
set
{
_enableCaseInsensitive = value;
_stringAsEnum.EnableCaseInsensitive = this._enableCaseInsensitive;
_unqualified.EnableCaseInsensitive = this._enableCaseInsensitive;
}
}
/// <inheritdoc/>
public override IEnumerable<IEdmOperation> ResolveUnboundOperations(IEdmModel model, string identifier)
{
return _unqualified.ResolveUnboundOperations(model, identifier);
}
/// <inheritdoc/>
public override IEnumerable<IEdmOperation> ResolveBoundOperations(IEdmModel model, string identifier,
IEdmType bindingType)
{
return _unqualified.ResolveBoundOperations(model, identifier, bindingType);
}
/// <inheritdoc/>
public override void PromoteBinaryOperandTypes(BinaryOperatorKind binaryOperatorKind,
ref SingleValueNode leftNode, ref SingleValueNode rightNode, out IEdmTypeReference typeReference)
{
_stringAsEnum.PromoteBinaryOperandTypes(binaryOperatorKind, ref leftNode, ref rightNode, out typeReference);
}
/// <inheritdoc/>
public override IEnumerable<KeyValuePair<string, object>> ResolveKeys(IEdmEntityType type,
IDictionary<string, string> namedValues, Func<IEdmTypeReference, string, object> convertFunc)
{
return _stringAsEnum.ResolveKeys(type, namedValues, convertFunc);
}
/// <inheritdoc/>
public override IEnumerable<KeyValuePair<string, object>> ResolveKeys(IEdmEntityType type,
IList<string> positionalValues, Func<IEdmTypeReference, string, object> convertFunc)
{
return _stringAsEnum.ResolveKeys(type, positionalValues, convertFunc);
}
/// <inheritdoc/>
public override IDictionary<IEdmOperationParameter, SingleValueNode> ResolveOperationParameters(
IEdmOperation operation, IDictionary<string, SingleValueNode> input)
{
return _stringAsEnum.ResolveOperationParameters(operation, input);
}
}
}