Skip to content

Commit d73d3af

Browse files
add datamodificationexception class
1 parent ea4e79c commit d73d3af

File tree

10 files changed

+651
-0
lines changed

10 files changed

+651
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
//-----------------------------------------------------------------------------
2+
// <copyright file="DataModificationExceptionType.cs" company=".NET Foundation">
3+
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
4+
// See License.txt in the project root for license information.
5+
// </copyright>
6+
//------------------------------------------------------------------------------
7+
8+
using System;
9+
10+
namespace Org.OData.Core.V1
11+
{
12+
/// <summary>
13+
/// Represents a message type.
14+
/// </summary>
15+
public class MessageType
16+
{
17+
/// <summary>
18+
/// Code of message.
19+
/// </summary>
20+
public string Code { get; set; }
21+
22+
/// <summary>
23+
/// Actual message.
24+
/// </summary>
25+
public string Message { get; set; }
26+
27+
/// <summary>
28+
/// Severity of message.
29+
/// </summary>
30+
public string Severity { get; set; }
31+
32+
/// <summary>
33+
/// Target of message.
34+
/// </summary>
35+
public string Target { get; set; }
36+
37+
/// <summary>
38+
/// Details of message.
39+
/// </summary>
40+
public string Details { get; set; }
41+
}
42+
43+
/// <summary>
44+
/// Represents an exception type.
45+
/// </summary>
46+
public abstract class ExceptionType
47+
{
48+
/// <summary>
49+
/// Represents a message type.
50+
/// </summary>
51+
public MessageType MessageType { get; set; }
52+
}
53+
54+
/// <summary>
55+
/// Represents the type of exception thrown during a data modification operation.
56+
/// </summary>
57+
public class DataModificationExceptionType : ExceptionType
58+
{
59+
/// <summary>
60+
/// Initializes a new instance of the <see cref="DataModificationExceptionType"/> class.
61+
/// </summary>
62+
public DataModificationExceptionType(DataModificationOperationKind failedOperation)
63+
{
64+
this.FailedOperation = failedOperation;
65+
}
66+
67+
/// <summary>
68+
/// Represents the kind of data modification operation.
69+
/// </summary>
70+
public DataModificationOperationKind FailedOperation { get; }
71+
72+
/// <summary>
73+
/// Represents the response code.
74+
/// </summary>
75+
public Int16 ResponseCode { get; set; }
76+
}
77+
78+
/// <summary>
79+
/// Enumerates the kind of data modification operations.
80+
/// </summary>
81+
public enum DataModificationOperationKind
82+
{
83+
/// <summary>
84+
/// Represents an insert operation.
85+
/// </summary>
86+
Insert,
87+
88+
/// <summary>
89+
/// Represents an update operation.
90+
/// </summary>
91+
Update,
92+
93+
/// <summary>
94+
/// Represents an insert or update operation if item already exists.
95+
/// </summary>
96+
Upsert,
97+
98+
/// <summary>
99+
/// Represents a delete data modification operation.
100+
/// </summary>
101+
Delete,
102+
103+
/// <summary>
104+
/// Represents an action or function invocation.
105+
/// </summary>
106+
Invoke,
107+
108+
/// <summary>
109+
/// Represents adding a link between entities.
110+
/// </summary>
111+
Link,
112+
113+
/// <summary>
114+
/// Represents removing a link between entities.
115+
/// </summary>
116+
Unlink
117+
}
118+
}

src/Microsoft.AspNetCore.OData/Deltas/Delta.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public abstract class Delta : DynamicObject, IDelta
2121
/// </summary>
2222
public abstract DeltaItemKind Kind { get; }
2323

24+
/// <inheritdoc/>
25+
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
26+
2427
/// <summary>
2528
/// Clears the Delta and resets the underlying Entity.
2629
/// </summary>

src/Microsoft.AspNetCore.OData/Deltas/DeltaLinkBaseOfT.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@ protected DeltaLinkBase(Type structuralType)
6868
/// The name of the relationship property on the parent object.
6969
/// </summary>
7070
public string Relationship { get; set; }
71+
72+
/// <inheritdoc/>
73+
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
7174
}
7275
}

src/Microsoft.AspNetCore.OData/Deltas/IDeltaSetItem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ public interface IDeltaSetItem
1616
/// Gets the delta item kind.
1717
/// </summary>
1818
DeltaItemKind Kind { get; }
19+
20+
/// <summary>
21+
/// Gets or sets the annotation container to hold transient instance annotations.
22+
/// </summary>
23+
IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }
1924
}
2025
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//-----------------------------------------------------------------------------
2+
// <copyright file="IODataInstanceAnnotationContainer.cs" company=".NET Foundation">
3+
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
4+
// See License.txt in the project root for license information.
5+
// </copyright>
6+
//------------------------------------------------------------------------------
7+
8+
using System.Collections.Generic;
9+
10+
namespace Microsoft.AspNetCore.OData
11+
{
12+
/// <summary>
13+
/// Identifies a container for holding instance annotations. A default implementation is provided.
14+
/// Customers can have their own implementation.
15+
/// </summary>
16+
public interface IODataInstanceAnnotationContainer
17+
{
18+
/// <summary>
19+
/// Method to Add an Instance Annotation to the CLR type
20+
/// </summary>
21+
/// <param name="annotationName">Name of Annotation</param>
22+
/// <param name="value">Value of Annotation</param>
23+
void AddResourceAnnotation(string annotationName, object value);
24+
25+
/// <summary>
26+
/// Method to Add an Instance Annotation to a property
27+
/// </summary>
28+
/// <param name="propertyName">Name of the property</param>
29+
/// <param name="annotationName">Name of Annotation</param>
30+
/// <param name="value">Value of Annotation</param>
31+
void AddPropertyAnnotation(string propertyName, string annotationName, object value);
32+
33+
/// <summary>
34+
/// Get an Instance Annotation from CLR Type
35+
/// </summary>
36+
/// <param name="annotationName">Name of Annotation</param>
37+
/// <returns>Get Annotation value for the given annotation</returns>
38+
object GetResourceAnnotation(string annotationName);
39+
40+
/// <summary>
41+
/// Get an Instance Annotation from the Property
42+
/// </summary>
43+
/// <param name="propertyName">Name of the Property</param>
44+
/// <param name="annotationName">Name of the Annotation</param>
45+
/// <returns>Get Annotation value for the given annotation and property</returns>
46+
object GetPropertyAnnotation(string propertyName, string annotationName);
47+
48+
/// <summary>
49+
/// Get All Annotations from CLR Type
50+
/// </summary>
51+
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns>
52+
IDictionary<string, object> GetResourceAnnotations();
53+
54+
/// <summary>
55+
/// Get all Annotations for a Property
56+
/// </summary>
57+
/// <param name="propertyName">Name of Property</param>
58+
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns>
59+
IDictionary<string, object> GetPropertyAnnotations(string propertyName);
60+
}
61+
}

0 commit comments

Comments
 (0)