-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66e6ab0
commit 45b9b72
Showing
107 changed files
with
10,731 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/Microsoft.AspNet.OData.Shared/Common/ODataPathHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//----------------------------------------------------------------------------- | ||
// <copyright file="ODataPathHelper.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.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.OData.UriParser; | ||
|
||
namespace Microsoft.AspNet.OData.Common | ||
{ | ||
/// <summary> | ||
/// Helper methods for <see cref="ODataPath"/>. | ||
/// </summary> | ||
internal static class ODataPathHelper | ||
{ | ||
/// <summary> | ||
/// Get the keys from a <see cref="KeySegment"/>. | ||
/// </summary> | ||
/// <param name="keySegment">The <see cref="KeySegment"/> to extract the keys.</param> | ||
/// <returns>Dictionary of keys.</returns> | ||
public static Dictionary<string, object> KeySegmentAsDictionary(KeySegment keySegment) | ||
{ | ||
if (keySegment == null) | ||
{ | ||
throw Error.ArgumentNull(nameof(keySegment)); | ||
} | ||
|
||
return keySegment.Keys.ToDictionary(d => d.Key, d => d.Value); | ||
} | ||
|
||
/// <summary> | ||
/// Get the position of the next <see cref="KeySegment"/> in a list of <see cref="ODataPathSegment"/>. | ||
/// </summary> | ||
/// <param name="pathSegments">List of <see cref="ODataPathSegment"/>.</param> | ||
/// <param name="currentPosition">Current position in the list of <see cref="ODataPathSegment"/>.</param> | ||
/// <returns>Position of the next <see cref="KeySegment"/> if it exists, or -1 otherwise.</returns> | ||
public static int GetNextKeySegmentPosition(IReadOnlyList<ODataPathSegment> pathSegments, int currentPosition) | ||
{ | ||
if (pathSegments == null) | ||
{ | ||
throw Error.ArgumentNull(nameof(pathSegments)); | ||
} | ||
|
||
if (currentPosition < 0 || currentPosition >= pathSegments.Count) | ||
{ | ||
return -1; | ||
} | ||
|
||
if (pathSegments[currentPosition] is KeySegment) | ||
{ | ||
currentPosition++; | ||
} | ||
|
||
for (int i = currentPosition; i < pathSegments.Count; i++) | ||
{ | ||
ODataPathSegment currentSegment = pathSegments[i]; | ||
|
||
if (currentSegment is KeySegment) | ||
{ | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/Microsoft.AspNet.OData.Shared/DataModificationExceptionType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//----------------------------------------------------------------------------- | ||
// <copyright file="MessageType.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 Microsoft.AspNet.OData.Builder; | ||
|
||
namespace Org.OData.Core.V1 | ||
{ | ||
/// <summary> | ||
/// Represents a Message Type | ||
/// </summary> | ||
public class MessageType | ||
{ | ||
/// <summary> | ||
/// Code of message | ||
/// </summary> | ||
public string Code { get; set; } | ||
|
||
/// <summary> | ||
/// Actual message | ||
/// </summary> | ||
public string Message { get; set; } | ||
|
||
/// <summary> | ||
/// Severity of message | ||
/// </summary> | ||
public string Severity { get; set; } | ||
|
||
/// <summary> | ||
/// Target of message | ||
/// </summary> | ||
public string Target { get; set; } | ||
|
||
/// <summary> | ||
/// Details of message | ||
/// </summary> | ||
public string Details { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Represents an Exception Type | ||
/// </summary> | ||
public abstract class ExceptionType | ||
{ | ||
/// <summary> | ||
/// Represents a MessageType | ||
/// </summary> | ||
public MessageType MessageType { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Represents an Exception for Data modification Operation. | ||
/// </summary> | ||
public class DataModificationExceptionType : ExceptionType | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DataModificationExceptionType"/> class. | ||
/// </summary> | ||
public DataModificationExceptionType(DataModificationOperationKind failedOperation) | ||
{ | ||
this.FailedOperation = failedOperation; | ||
} | ||
|
||
/// <summary> | ||
/// Represents kind of <see cref="DataModificationOperationKind"/> type of operation | ||
/// </summary> | ||
public DataModificationOperationKind FailedOperation { get; } | ||
|
||
/// <summary> | ||
/// Represents response code | ||
/// </summary> | ||
public Int16 ResponseCode { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Enumerates the DataModificationOperation for the operation kind | ||
/// </summary> | ||
public enum DataModificationOperationKind | ||
{ | ||
/// <summary> | ||
/// Insert new Instance | ||
/// </summary> | ||
Insert, | ||
|
||
/// <summary> | ||
/// Update existing Instance | ||
/// </summary> | ||
Update, | ||
|
||
/// <summary> | ||
/// Insert new instance or update it if it already exists | ||
/// </summary> | ||
Upsert, | ||
|
||
/// <summary> | ||
/// Delete existing instance | ||
/// </summary> | ||
Delete, | ||
|
||
/// <summary> | ||
/// Invoke action or function | ||
/// </summary> | ||
Invoke, | ||
|
||
/// <summary> | ||
/// Add link between entities | ||
/// </summary> | ||
Link, | ||
|
||
/// <summary> | ||
/// Remove link between entities | ||
/// </summary> | ||
Unlink | ||
} | ||
} |
Oops, something went wrong.