diff --git a/src/TensorFlowNET.Core/Binding.Util.cs b/src/TensorFlowNET.Core/Binding.Util.cs index d723283f..ff383642 100644 --- a/src/TensorFlowNET.Core/Binding.Util.cs +++ b/src/TensorFlowNET.Core/Binding.Util.cs @@ -277,39 +277,6 @@ namespace Tensorflow return (__memberobject__.Length > 0) ? true : false; } - public delegate object __object__(params object[] args); - - public static __object__ getattr(object obj, string key, params Type[] ___parameter_type__) - { - var __dyn_obj__ = obj.GetType().GetMember(key); - if (__dyn_obj__.Length == 0) - throw new Exception("The object \"" + nameof(obj) + "\" doesnot have a defination \"" + key + "\""); - var __type__ = __dyn_obj__[0]; - if (__type__.MemberType == System.Reflection.MemberTypes.Method) - { - try - { - var __method__ = (___parameter_type__.Length > 0) ? obj.GetType().GetMethod(key, ___parameter_type__) : obj.GetType().GetMethod(key); - return (object[] args) => __method__.Invoke(obj, args); - } - catch (System.Reflection.AmbiguousMatchException ex) - { - throw new Exception("AmbigousFunctionMatchFound : (Probable cause : Function Overloading) Please add parameter types of the function."); - } - } - else if (__type__.MemberType == System.Reflection.MemberTypes.Field) - { - var __field__ = obj.GetType().GetField(key).GetValue(obj); - return (object[] args) => { return __field__; }; - } - else if (__type__.MemberType == System.Reflection.MemberTypes.Property) - { - var __property__ = obj.GetType().GetProperty(key).GetValue(obj); - return (object[] args) => { return __property__; }; - } - return (object[] args) => { return "NaN"; }; - } - public static IEnumerable TupleToEnumerable(object tuple) { Type t = tuple.GetType(); diff --git a/test/TensorFlowNET.UnitTest/PythonBaseTests.cs b/test/TensorFlowNET.UnitTest/PythonBaseTests.cs index 6fd0d7c3..8dfbdeef 100644 --- a/test/TensorFlowNET.UnitTest/PythonBaseTests.cs +++ b/test/TensorFlowNET.UnitTest/PythonBaseTests.cs @@ -49,27 +49,6 @@ namespace TensorFlowNET.UnitTest Assert.IsFalse(false2); Assert.IsFalse(false3); } - - [TestMethod] - public void hasattr_getattr() - { - var s1 = "Tensorflow v0.1"; - var f = "Tensorflow"; - var r = "Tensorflow.NET"; - var res = s1.Replace(f, r); - - // Test 1 - Assert.IsTrue(hasattr(s1, "Replace")); - - // Test 2 - var o = getattr( s1, "Replace", typeof(string), typeof(string)); - Assert.AreEqual(res, o(f, r)); - - // Test 3 - var l = getattr(s1, "Length"); - Assert.AreEqual(s1.Length, l()); - - } } }