/// <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); }
/// <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); }
/// <summary> /// Inject a custom IFormatter factory. /// </summary> /// <param name="factory">Function that provides an IFormatter</param> /// <param name="formatterUsage">What type of objects to format</param> public void SetFormatterFactory(Func <EngineConfiguration, FormatterUsage, IFormatter> factory, FormatterUsage formatterUsage = FormatterUsage.Default) { Register(args => factory.Invoke(this, formatterUsage), formatterUsage.ToString()); }
public void UseFormatter <T>() where T : IFormatter { _formatterUsage = FormatterUsage.selected; _selectedFormatterTypes.Fill(typeof(T)); }
public void UseNoFormatters() { _formatterUsage = FormatterUsage.none; _selectedFormatterTypes.Clear(); }
public void UseAllFormatters() { _formatterUsage = FormatterUsage.all; _selectedFormatterTypes.Clear(); }