mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Fixed TypeConstraint.Inherited, and added TypeConstraint.InheritedInverse (#205)
* Added TypeConstraint to check inheritance but inverted. * Flipped output inherited type constraints, edited comments
This commit is contained in:
parent
be0d452d12
commit
63c3ae2f7d
@ -45,10 +45,12 @@ namespace XNode {
|
|||||||
public enum TypeConstraint {
|
public enum TypeConstraint {
|
||||||
/// <summary> Allow all types of input</summary>
|
/// <summary> Allow all types of input</summary>
|
||||||
None,
|
None,
|
||||||
/// <summary> Allow similar and inherited types </summary>
|
/// <summary> Allow connections where input value type is assignable from output value type (eg. ScriptableObject --> Object)</summary>
|
||||||
Inherited,
|
Inherited,
|
||||||
/// <summary> Allow only similar types </summary>
|
/// <summary> Allow only similar types </summary>
|
||||||
Strict,
|
Strict,
|
||||||
|
/// <summary> Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject)</summary>
|
||||||
|
InheritedInverse,
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Obsolete
|
#region Obsolete
|
||||||
|
|||||||
@ -263,9 +263,11 @@ namespace XNode {
|
|||||||
// Check input type constraints
|
// Check input type constraints
|
||||||
if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
|
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.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
|
// Check output type constraints
|
||||||
if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
|
if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
|
||||||
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && output.ValueType != input.ValueType) return false;
|
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false;
|
||||||
|
if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
|
||||||
// Success
|
// Success
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user