mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Added TypeConstraint to check inheritance but inverted.
This commit is contained in:
parent
a825af8192
commit
7f009e1829
@ -49,6 +49,8 @@ namespace XNode {
|
||||
Inherited,
|
||||
/// <summary> Allow only similar types </summary>
|
||||
Strict,
|
||||
/// <summary> Allow similar and inherited types but checks inheritance in reverse </summary>
|
||||
InheritedInverse,
|
||||
}
|
||||
|
||||
#region Obsolete
|
||||
|
||||
@ -259,9 +259,11 @@ namespace XNode {
|
||||
// Check input type constraints
|
||||
if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
|
||||
if (input.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false;
|
||||
if (input.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
|
||||
// Check output type constraints
|
||||
if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
|
||||
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && output.ValueType != input.ValueType) return false;
|
||||
if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user