private bool TryMakeBubblingEvent(ViewManagerExportedBubblingEventTypeConstantAttribute 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 bubbleName  = attribute.BubbleCallbackName ?? "on" + memberInfo.Name;
                var captureName = attribute.CaptureCallbackName ?? bubbleName + "Capture";

                constantWriter.WritePropertyName(eventName);

                constantWriter.WriteObjectBegin();

                constantWriter.WritePropertyName("phasedRegistrationNames");
                constantWriter.WriteObjectBegin();
                constantWriter.WriteObjectProperty("bubbled", bubbleName);
                constantWriter.WriteObjectProperty("captured", captureName);
                constantWriter.WriteObjectEnd();

                constantWriter.WriteObjectEnd();

                memberValue = MakeEventDelegate(eventName, memberType, eventDataType);

                return(true);
            }

            memberValue = default(Delegate);

            return(false);
        }
Exemplo n.º 2
0
        private bool TryMakeBubblingEvent(ViewManagerExportedBubblingEventTypeConstantAttribute 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 bubbleName  = attribute.BubbleCallbackName ?? "on" + memberInfo.Name;
                var captureName = attribute.CaptureCallbackName ?? bubbleName + "Capture";

                var registration = new Dictionary <string, object>
                {
                    { "phasedRegistrationNames", new Dictionary <string, object>()
                      {
                          { "bubbled", bubbleName },
                          { "captured", captureName },
                      } }
                };

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

                return(true);
            }

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

            return(false);
        }