From fa62765daa1aa30d5b624d75506129073889a082 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 21 Sep 2022 11:01:49 +0200 Subject: [PATCH] Revert "Merge pull request #353 from LupusInferni315/master" This reverts commit 1b64a96d40a0b33b497259bcd680c73c3122c85b, reversing changes made to 75078edd20c6e28d9350b5aacc2a118977262192. --- Scripts/Node.cs | 8 +------- Scripts/NodePort.cs | 3 --- Scripts/TypeExtensions.cs | 16 ---------------- 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 Scripts/TypeExtensions.cs diff --git a/Scripts/Node.cs b/Scripts/Node.cs index b705627..704e99d 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -52,13 +52,7 @@ namespace XNode { /// Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject) InheritedInverse, /// Allow connections where output value type is assignable from input value or input value type is assignable from output value type - InheritedAny, - /// Allow connections where input value type is castable from output value type. - Castable, - /// Allow connections where output value type is castable from input value type. - CastableInverse, - /// Allow connections where input value type is castable from output value type or output value type is castable from input value type. - CastableAny + InheritedAny } #region Obsolete diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 14c3b7d..6bcc638 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -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.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.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 return true; } diff --git a/Scripts/TypeExtensions.cs b/Scripts/TypeExtensions.cs deleted file mode 100644 index ae49c31..0000000 --- a/Scripts/TypeExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Linq; -using System.Reflection; - -public static class TypeExtensions -{ - /// Determines whether an instance of a specified type can be assigned to a variable of the current type. - 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" ); - } ); - } -}