1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 01:06:01 +08:00

Revert "Merge pull request #353 from LupusInferni315/master"

This reverts commit 1b64a96d40a0b33b497259bcd680c73c3122c85b, reversing
changes made to 75078edd20c6e28d9350b5aacc2a118977262192.
This commit is contained in:
Thor Brigsted 2022-09-21 11:01:49 +02:00
parent 1b64a96d40
commit fa62765daa
3 changed files with 1 additions and 26 deletions

View File

@ -52,13 +52,7 @@ namespace XNode {
/// <summary> Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject)</summary> /// <summary> Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject)</summary>
InheritedInverse, InheritedInverse,
/// <summary> Allow connections where output value type is assignable from input value or input value type is assignable from output value type</summary> /// <summary> Allow connections where output value type is assignable from input value or input value type is assignable from output value type</summary>
InheritedAny, InheritedAny
/// <summary> Allow connections where input value type is castable from output value type. </summary>
Castable,
/// <summary> Allow connections where output value type is castable from input value type. </summary>
CastableInverse,
/// <summary> Allow connections where input value type is castable from output value type or output value type is castable from input value type. </summary>
CastableAny
} }
#region Obsolete #region Obsolete

View File

@ -279,9 +279,6 @@ namespace XNode {
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.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; if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedAny && !input.ValueType.IsAssignableFrom(output.ValueType) && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedAny && !input.ValueType.IsAssignableFrom(output.ValueType) && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.Castable && !input.ValueType.IsCastableFrom(output.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.CastableInverse && !output.ValueType.IsCastableFrom(input.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.CastableAny && !input.ValueType.IsCastableFrom(output.ValueType) && !output.ValueType.IsCastableFrom(input.ValueType)) return false;
// Success // Success
return true; return true;
} }

View File

@ -1,16 +0,0 @@
using System.Linq;
using System.Reflection;
public static class TypeExtensions
{
/// <summary> Determines whether an instance of a specified type can be assigned to a variable of the current type. </summary>
public static bool IsCastableFrom(this Type to, Type from)
{
if ( to.IsAssignableFrom ( from ) )
return true;
return from.GetMethods ( BindingFlags.Public | BindingFlags.Static ).Any ( m =>
{
return m.ReturnType == to && ( m.Name == "op_Implicit" || m.Name == "op_Explicit" );
} );
}
}