예제 #1
0
        private bool TryMakeDirectEvent(ViewManagerExportedDirectEventTypeConstantAttribute attribute, MemberInfo memberInfo, Type memberType, out string constantKey, out object constantValue, out Delegate memberValue)
        {
            if (null != attribute && null != memberInfo && TryGetEventDataType(memberType, out Type eventDataType))
            {
                var eventName    = attribute.EventName ?? "top" + memberInfo.Name;
                var callbackName = attribute.CallbackName ?? "on" + memberInfo.Name;

                var registration = new Dictionary <string, object>
                {
                    { "registrationName", callbackName }
                };

                constantKey   = eventName;
                constantValue = registration;
                memberValue   = MakeEventDelegate(eventName, memberType, eventDataType);

                return(true);
            }

            constantKey   = default;
            constantValue = default;
            memberValue   = default;

            return(false);
        }
        private bool TryMakeDirectEvent(ViewManagerExportedDirectEventTypeConstantAttribute attribute, MemberInfo memberInfo, Type memberType, IJSValueWriter constantWriter, out Delegate memberValue)
        {
            if (null != attribute && null != memberInfo && TryGetEventDataType(memberType, out Type eventDataType))
            {
                var eventName    = attribute.EventName ?? "top" + memberInfo.Name;
                var callbackName = attribute.CallbackName ?? "on" + memberInfo.Name;

                constantWriter.WritePropertyName(eventName);
                constantWriter.WriteObjectBegin();
                constantWriter.WriteObjectProperty("registrationName", callbackName);
                constantWriter.WriteObjectEnd();

                memberValue = MakeEventDelegate(eventName, memberType, eventDataType);

                return(true);
            }

            memberValue = default(Delegate);

            return(false);
        }