Ejemplo n.º 1
0
        /// <summary>
        /// Return an IFormatter by invoking the factory function associated
        /// with the given FormatterUsage or FormatterUsage.Default if not registered.
        /// </summary>
        /// <param name="formatterUsage">The specific formatter</param>
        /// <returns>An IFormatter instance provided by the </returns>
        public virtual IFormatter CreateFormatter(FormatterUsage formatterUsage)
        {
            var formatter = _registry.CanResolve <IFormatter>(formatterUsage.ToString())
                ? _registry.Resolve <IFormatter>(formatterUsage.ToString())
                : _registry.Resolve <IFormatter>(FormatterUsage.Default.ToString());

            if (formatterUsage == FormatterUsage.Journal && PacketOptions != null)
            {
                formatter = new PacketingFormatter(formatter, PacketOptions.Value);
            }

            return(formatter);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return an IFormatter by invoking the factory function associated
        /// with the given FormatterUsage or FormatterUsage.Default if not registered.
        /// </summary>
        /// <param name="formatterUsage">The specific formatter</param>
        /// <returns>An IFormatter instance provided by the </returns>
        public virtual IFormatter CreateFormatter(FormatterUsage formatterUsage)
        {
            var formatter = Registry.CanResolve <IFormatter>(formatterUsage.ToString())
                ? Registry.Resolve <IFormatter>(formatterUsage.ToString())
                : Registry.Resolve <IFormatter>(FormatterUsage.Default.ToString());

            if (_binder != null && formatter is BinaryFormatter)
            {
                ((BinaryFormatter)formatter).Binder = _binder;
            }

            if (formatterUsage == FormatterUsage.Journal && PacketOptions != null)
            {
                formatter = new PacketingFormatter(formatter, PacketOptions.Value);
            }
            return(formatter);
        }