Skip to content

Commit

Permalink
add datamodificationexception class
Browse files Browse the repository at this point in the history
  • Loading branch information
ElizabethOkerio committed May 25, 2023
1 parent ea4e79c commit d73d3af
Show file tree
Hide file tree
Showing 10 changed files with 651 additions and 0 deletions.
118 changes: 118 additions & 0 deletions src/Microsoft.AspNetCore.OData/DataModificationExceptionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//-----------------------------------------------------------------------------
// <copyright file="DataModificationExceptionType.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;

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 message type.
/// </summary>
public MessageType MessageType { get; set; }
}

/// <summary>
/// Represents the type of exception thrown during a 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 the kind of data modification operation.
/// </summary>
public DataModificationOperationKind FailedOperation { get; }

/// <summary>
/// Represents the response code.
/// </summary>
public Int16 ResponseCode { get; set; }
}

/// <summary>
/// Enumerates the kind of data modification operations.
/// </summary>
public enum DataModificationOperationKind
{
/// <summary>
/// Represents an insert operation.
/// </summary>
Insert,

/// <summary>
/// Represents an update operation.
/// </summary>
Update,

/// <summary>
/// Represents an insert or update operation if item already exists.
/// </summary>
Upsert,

/// <summary>
/// Represents a delete data modification operation.
/// </summary>
Delete,

/// <summary>
/// Represents an action or function invocation.
/// </summary>
Invoke,

/// <summary>
/// Represents adding a link between entities.
/// </summary>
Link,

/// <summary>
/// Represents removing a link between entities.
/// </summary>
Unlink
}
}
3 changes: 3 additions & 0 deletions src/Microsoft.AspNetCore.OData/Deltas/Delta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public abstract class Delta : DynamicObject, IDelta
/// </summary>
public abstract DeltaItemKind Kind { get; }

/// <inheritdoc/>
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

/// <summary>
/// Clears the Delta and resets the underlying Entity.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.AspNetCore.OData/Deltas/DeltaLinkBaseOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@ protected DeltaLinkBase(Type structuralType)
/// The name of the relationship property on the parent object.
/// </summary>
public string Relationship { get; set; }

/// <inheritdoc/>
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
}
5 changes: 5 additions & 0 deletions src/Microsoft.AspNetCore.OData/Deltas/IDeltaSetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ public interface IDeltaSetItem
/// Gets the delta item kind.
/// </summary>
DeltaItemKind Kind { get; }

/// <summary>
/// Gets or sets the annotation container to hold transient instance annotations.
/// </summary>
IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//-----------------------------------------------------------------------------
// <copyright file="IODataInstanceAnnotationContainer.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;

namespace Microsoft.AspNetCore.OData
{
/// <summary>
/// Identifies a container for holding instance annotations. A default implementation is provided.
/// Customers can have their own implementation.
/// </summary>
public interface IODataInstanceAnnotationContainer
{
/// <summary>
/// Method to Add an Instance Annotation to the CLR type
/// </summary>
/// <param name="annotationName">Name of Annotation</param>
/// <param name="value">Value of Annotation</param>
void AddResourceAnnotation(string annotationName, object value);

/// <summary>
/// Method to Add an Instance Annotation to a property
/// </summary>
/// <param name="propertyName">Name of the property</param>
/// <param name="annotationName">Name of Annotation</param>
/// <param name="value">Value of Annotation</param>
void AddPropertyAnnotation(string propertyName, string annotationName, object value);

/// <summary>
/// Get an Instance Annotation from CLR Type
/// </summary>
/// <param name="annotationName">Name of Annotation</param>
/// <returns>Get Annotation value for the given annotation</returns>
object GetResourceAnnotation(string annotationName);

/// <summary>
/// Get an Instance Annotation from the Property
/// </summary>
/// <param name="propertyName">Name of the Property</param>
/// <param name="annotationName">Name of the Annotation</param>
/// <returns>Get Annotation value for the given annotation and property</returns>
object GetPropertyAnnotation(string propertyName, string annotationName);

/// <summary>
/// Get All Annotations from CLR Type
/// </summary>
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns>
IDictionary<string, object> GetResourceAnnotations();

/// <summary>
/// Get all Annotations for a Property
/// </summary>
/// <param name="propertyName">Name of Property</param>
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns>
IDictionary<string, object> GetPropertyAnnotations(string propertyName);
}
}
Loading

0 comments on commit d73d3af

Please sign in to comment.