-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support function object types in Ocl
- Loading branch information
Showing
12 changed files
with
432 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Octopus.Ocl.FunctionCalls | ||
{ | ||
public interface IFunctionCall | ||
{ | ||
string Name {get;} | ||
object? ToValue(OclFunctionCall functionCall); | ||
OclFunctionCall? ToOclFunctionCall(object obj, PropertyInfo propertyInfo); | ||
|
||
OclFunctionCall? ToOclFunctionCall(object[] arguments); | ||
} | ||
} |
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
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,52 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
||
namespace Octopus.Ocl | ||
{ | ||
[DebuggerDisplay("{Name}({Arguments})", Name = "OclFunctionCall")] | ||
public class OclFunctionCall : IOclElement | ||
{ | ||
string name; | ||
IEnumerable<object?> arguments; | ||
|
||
public OclFunctionCall(string name, IEnumerable<object?> arguments) | ||
{ | ||
this.name = Name = name; // Make the compiler happy | ||
this.arguments = arguments; | ||
} | ||
|
||
public string Name | ||
{ | ||
get => name; | ||
set | ||
{ | ||
if (string.IsNullOrWhiteSpace(value)) | ||
throw new OclException("FunctionCalls must have an identifier name"); | ||
name = value; | ||
} | ||
} | ||
|
||
/// <remarks> | ||
/// The attribute value is given as an expression, which is retained literally for later evaluation by the calling application. | ||
/// </remarks> | ||
public IEnumerable<object?> Arguments | ||
{ | ||
get => arguments; | ||
set | ||
{ | ||
var invalidArg = arguments.Where(a => a != null && !OclAttribute.IsSupportedValueType(a.GetType())) | ||
.Select(t => t?.GetType().FullName).Distinct().ToArray(); | ||
if(invalidArg.Any()) | ||
{ | ||
var msg = (invalidArg.Length == 1) ? | ||
$"The type {invalidArg} is not a supported value type for an OCL function call argument" : | ||
$"The types {string.Join(',', invalidArg)} are not a supported value types for an OCL function call argument"; | ||
throw new OclException(msg); | ||
} | ||
|
||
this.arguments = value; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.