Ejemplo n.º 1
0
        public virtual void GetDefaultMetaInfoTest()
        {
            ConverterProperties properties = new ConverterProperties();
            IMetaInfo           metaInfo   = properties.GetEventMetaInfo();

            NUnit.Framework.Assert.IsTrue(metaInfo.GetType().FullName.StartsWith(NamespaceConstant.PDF_HTML + "."));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Triggers all registered
        /// <see cref="IEventCounterFactory"/>
        /// to produce
        /// <see cref="EventCounter"/>
        /// instance
        /// and count the event.
        /// </summary>
        /// <param name="event">
        ///
        /// <see cref="iText.Kernel.Counter.Event.IEvent"/>
        /// to be counted
        /// </param>
        /// <param name="metaInfo">
        ///
        /// <see cref="iText.Kernel.Counter.Event.IMetaInfo"/>
        /// object that can holds information about instance that throws the event
        /// </param>
        /// <param name="caller">the class that throws the event</param>
        public virtual void OnEvent(IEvent @event, IMetaInfo metaInfo, Type caller)
        {
            IContext context            = null;
            bool     contextInitialized = false;

            foreach (IEventCounterFactory factory in factories.Keys)
            {
                EventCounter counter = factory.GetCounter(caller);
                if (counter != null)
                {
                    if (!contextInitialized)
                    {
                        if (metaInfo != null)
                        {
                            context = ContextManager.GetInstance().GetContext(metaInfo.GetType());
                        }
                        if (context == null)
                        {
                            context = ContextManager.GetInstance().GetContext(caller);
                        }
                        if (context == null)
                        {
                            context = ContextManager.GetInstance().GetContext(@event.GetType());
                        }
                        contextInitialized = true;
                    }
                    if ((context != null && context.Allow(@event)) || (context == null && counter.fallback.Allow(@event)))
                    {
                        counter.OnEvent(@event, metaInfo);
                    }
                }
            }
        }