public static string Replace(this string template, ComponentData data, string contextName, EventData eventData) { var eventListener = data.EventListener(contextName, eventData); return(template .Replace(data, contextName) .Replace("${EventComponentName}", data.EventComponentName(eventData)) .Replace("${EventListenerComponent}", eventListener.AddComponentSuffix()) .Replace("${Event}", data.Event(contextName, eventData)) .Replace("${EventListener}", eventListener) .Replace("${eventListener}", eventListener.LowercaseFirst()) .Replace("${EventType}", GetEventTypeSuffix(eventData))); }
ComponentData[] createDataForEvents(ComponentData data) { return(data.GetContextNames() .SelectMany(contextName => data.GetEventData().Select(eventData => { var dataForEvent = new ComponentData(data); dataForEvent.IsEvent(false); dataForEvent.IsUnique(false); dataForEvent.ShouldGenerateComponent(false); var eventComponentName = data.EventComponentName(eventData); var eventTypeSuffix = eventData.GetEventTypeSuffix(); var optionalContextName = dataForEvent.GetContextNames().Length > 1 ? contextName : string.Empty; var listenerComponentName = optionalContextName + eventComponentName + eventTypeSuffix.AddListenerSuffix(); dataForEvent.SetTypeName(listenerComponentName.AddComponentSuffix()); dataForEvent.SetMemberData(new[] { new MemberData("System.Collections.Generic.List<I" + listenerComponentName + ">", "value") }); dataForEvent.SetContextNames(new[] { contextName }); return dataForEvent; }).ToArray() ).ToArray()); }