Пример #1
0
        void TrySetCallbacksThroughReflection <TValue>(ref TValue value)
        {
            var type          = Element.GetType();
            var baseFieldType = GetBaseFieldType(type);

            if (null == baseFieldType)
            {
                return;
            }

            var fieldType = baseFieldType.GenericTypeArguments[0];
            var key       = new TypePairKey(fieldType, typeof(TValue));

            if (!s_RegistrationMethods.TryGetValue(key, out var method))
            {
                s_RegistrationMethods[key] = method = BaseBinderMethod.MakeGenericMethod(fieldType, typeof(TValue));
            }

            method.Invoke(this, new object[] { value, Element });
        }
        static void TrySetCallbacksThroughReflection <TValue>(VisualElement element, ref TValue value, PropertyPath path, BindingContextElement root)
        {
            var type          = element.GetType();
            var baseFieldType = GetBaseFieldType(type);

            if (null == baseFieldType)
            {
                return;
            }

            var fieldType = baseFieldType.GenericTypeArguments[0];
            var key       = new TypePairKey(fieldType, typeof(TValue));

            if (!s_RegistrationMethods.TryGetValue(key, out var method))
            {
                s_RegistrationMethods[key] = method = BaseBinderMethod.MakeGenericMethod(fieldType, typeof(TValue));
            }

            method.Invoke(null, new object[] { value, element, path, root });
        }