public Kernel(IConfigurationContainer configuration, GraphiteSystemConfiguration systemConfiguration) { this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD); foreach (var listener in systemConfiguration.EventlogListeners.Cast<EventlogListenerElement>()) { this.CreateEventlogListener(listener); } this.scheduler = new Scheduler(); foreach (var listener in systemConfiguration.CounterListeners.Cast<CounterListenerElement>()) { Action action; try { action = this.CreateReportingAction(listener); this.scheduler.Add(action, listener.Interval); } catch (InvalidOperationException) { if (!listener.Retry) throw; this.retryCreation.Add(listener); } } if (this.retryCreation.Any()) { this.scheduler.Add(this.RetryCounterCreation, RetryInterval); } foreach (var appPool in systemConfiguration.AppPool.Cast<AppPoolElement>()) { AppPoolListener element; var action = this.CreateReportingAction(appPool, out element); this.scheduler.Add(action, appPool.Interval); // Reread counter instance name every 90 seconds this.scheduler.Add(() => element.LoadCounterName(), 90); } this.scheduler.Start(); }
internal MetricsPipe(IConfigurationContainer configuration, IMetricsPipeProvider provider, Func<IStopwatch> watch) { if (configuration == null) throw new ArgumentNullException("configuration"); if (provider == null) throw new ArgumentNullException("provider"); if (watch == null) throw new ArgumentNullException("watch"); this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD); MetricsPipe.provider = provider; this.watch = watch(); }
/// <summary> /// Configures the provided configuration container to create a serializer that automatically formats its contents /// into attributes and elements. When a serializer encounters a primitive type (or more accurately, a type that has /// an <see cref="IConverter"/> registered to handle it), it will automatically serialize its resulting (string) data /// as an Xml attribute. The only exception is when a <see cref="String"/> is encountered, where it will check its /// length. Strings greater than the provided max-length will be emitted as inner content. Otherwise, it will be /// emitted as an Xml attribute. /// </summary> /// <param name="this">The configuration container to configure.</param> /// <param name="maxTextLength">The max length a string can be before it is rendered as inner content. Any string /// shorter than this amount will be rendered as an Xml attribute.</param> /// <returns>The configured configuration container.</returns> public static IConfigurationContainer UseAutoFormatting(this IConfigurationContainer @this, int maxTextLength) => @this.Extend(new AutoMemberFormatExtension(maxTextLength));
public static ITypeConfiguration <T> CustomSerializer <T, TSerializer>(this IConfigurationContainer @this) where TSerializer : IExtendedXmlCustomSerializer <T> => @this.CustomSerializer <T>(typeof(TSerializer));
public static ITypeConfiguration <T> Type <T>(this IConfigurationContainer @this) => @this.Root.Types.Get(Support <T> .Key) .AsValid <TypeConfiguration <T> >();
public static IConfigurationContainer AllowExistingInstances(this IConfigurationContainer @this) { @this.Root.With <ExistingInstanceExtension>(); return(@this); }
public static IConfigurationContainer EnableUnknownContentHandling(this IConfigurationContainer @this, Action <IFormatReader> onMissing) => @this.Extend(new UnknownContentHandlingExtension(onMissing));
/*public static IConfigurationContainer EnableSingletons(this IConfigurationContainer @this) * => @this.Extend(SingletonActivationExtension.Default);*/ public static IConfigurationContainer EnableAllConstructors(this IConfigurationContainer @this) => @this.Extend(AllConstructorsExtension.Default);
public IConfigurationContainer Get(IConfigurationContainer parameter) => parameter.Type <Subject>() .Name("ConfiguredSubject");
/// <summary> /// Allows content to be read as parameters for a constructor call to activate an object, rather than the more /// traditional route of activating an object and its content read as property assignments. This is preferred -- /// required, even -- if your model is comprised of immutable objects. /// /// Note that there are several requirements for a class to be successfully processed: /// /// 1. only public fields / properties are considered /// 1. any public fields (spit) must be readonly /// 1. any public properties must have a get but not a set (on the public API, at least) /// 1. there must be exactly one interesting constructor, with parameters that are a case-insensitive match for /// each field/property in some order (i.e. there must be an obvious 1:1 mapping between members and constructor /// parameter names) /// </summary> /// <param name="this">The container to configure.</param> /// <returns>The configured container.</returns> /// <seealso href="https://github.com/ExtendedXmlSerializer/home/wiki/Features#immutable-classes-and-content"/> public static IConfigurationContainer EnableParameterizedContent(this IConfigurationContainer @this) => @this.Extend(ParameterizedMembersExtension.Default);
/// <summary> /// This is a less strict version of <see cref="EnableParameterizedContent"/>. Using this version, parameterized /// content works the same as <see cref="EnableParameterizedContent"/> but in addition, all properties defined in the /// deserialized document are also considered and assigned to the target instance if the property is writable. /// </summary> /// <param name="this">The container to configure.</param> /// <returns>The configured container.</returns> public static IConfigurationContainer EnableParameterizedContentWithPropertyAssignments( this IConfigurationContainer @this) => @this.Extend(AllParameterizedMembersExtension.Default);
public static ICollection <TypeInfo> IgnoredReferenceTypes(this IConfigurationContainer @this) => @this.Root.With <DefaultReferencesExtension>() .Blacklist;
/*public static ITypeConfiguration Type(this IConfiguration @this, TypeInfo type) => @this.Get(type);*/ public static IConfigurationContainer Configured <T>(this IConfigurationContainer @this) where T : class, IConfigurationProfile => Support <T> .NewOrSingleton().Get(@this);
public static ICollection <TypeInfo> AllowedReferenceTypes(this IConfigurationContainer @this) => @this.Root.With <DefaultReferencesExtension>() .Whitelist;
public static IConfigurationContainer EnableDeferredReferences(this IConfigurationContainer @this) { @this.Root.Extend(ReaderContextExtension.Default, DeferredReferencesExtension.Default); return(@this); }
public static IConfigurationContainer EnableReferences(this IConfigurationContainer @this) { @this.Root.EnableReferences(); return(@this); }
/// <summary> /// Configures the container to create a serializer that consolidates all namespaces so that they emit at the root of /// the document, rather than throughout the document when they are first encountered (which can lead to a lot of /// unnecessary overhead and larger documents). /// </summary> /// <param name="this">The configuration container to configure.</param> /// <returns>The configured configuration container.</returns> public static IConfigurationContainer UseOptimizedNamespaces(this IConfigurationContainer @this) => @this.Extend(RootInstanceExtension.Default) .Extend(OptimizedNamespaceExtension.Default);
/// <summary> /// Intended for extension authors, and enables a reader context on the deserialization process. Extension authors /// can use <seealso cref="ContentsHistory"/> to retrieve this history of objects being parsed and activated to the /// current point of the graph. This is valuable when parsing object graphs with many internal properties which in /// turn have their own set of complex properties. /// </summary> /// <param name="this">The container to configure.</param> /// <returns>The configured container.</returns> public static IConfigurationContainer EnableReaderContext(this IConfigurationContainer @this) => @this.Extend(ReaderContextExtension.Default);
public SerializationSupport(IConfigurationContainer configuration) : this(configuration.Create()) { }
/// <summary> /// This is intended to circumvent default behavior which throws an exception for primitive data types when there is /// no content provided for their elements. /// /// For example, say you have a boolean element defined as such: `<Boolean />` or, perhaps its long-form equivalent ` /// <Boolean></Boolean>`. /// /// Either one of these by default will throw a <seealso cref="FormatException"/>. Configuring the container with /// <seealso cref="EnableImplicitlyDefinedDefaultValues"/> will allow the use of empty values within document /// elements such as the above without throwing an exception. /// </summary> /// <param name="this">The container to configure.</param> /// <returns>The configured container.</returns> public static IConfigurationContainer EnableImplicitlyDefinedDefaultValues(this IConfigurationContainer @this) => @this.Alter(ImplicitlyDefinedDefaultValueAlteration.Default);
/// <summary> /// Provides a way to alter converters when they are accessed by the serializer. This provides a mechanism to /// decorate converters. Alterations only occur once per converter per serializer. /// </summary> /// <param name="this">The container to configure.</param> /// <param name="alteration">The alteration to perform on each converter when it is accessed by the serializer.</param> /// <returns>The configured container.</returns> public static IConfigurationContainer Alter(this IConfigurationContainer @this, IAlteration <IConverter> alteration) => @this.Root.With <ConverterAlterationsExtension>() .Alterations.Apply(alteration) .Return(@this);
/* Emit: */ /// <summary> /// Used to control and determine when content is emitted during serialization. This is a general-purpose /// configuration that works across every type encountered by the serializer. Use the <seealso cref="EmitBehaviors" /> /// class to utilize one of the built-in (and identified 😁) behaviors, or implement your own /// <see cref="IEmitBehavior"/>. /// </summary> /// <param name="this">The container to configure.</param> /// <param name="behavior">The behavior to apply to the container.</param> /// <returns>The configured container.</returns> public static IConfigurationContainer Emit(this IConfigurationContainer @this, IEmitBehavior behavior) => behavior.Get(@this);
public IConfigurationContainer Get(IConfigurationContainer parameter) => parameter.Type <Subject>() .Member(x => x.Message) .Ignore();
/* Extension Model: */ /// <summary> /// Assigns a default serialization monitor for a configuration container. A serialization monitor is a component /// that gets notified whenever there is a serialization such as OnSerializing, OnSerialized, as well as /// deserialization events such as OnDeserializing, OnDeserialized, etc. /// /// The default serialization monitor is applied for every type that is serialized with the serializer that the /// configured container creates. Use <see cref="WithMonitor{T}"/> on a type configuration to /// apply a monitor to a specific type. /// </summary> /// <param name="this">The configuration container to configure.</param> /// <param name="monitor">The monitor to assign as the default monitor.</param> /// <returns>The configured container.</returns> /// <seealso href="https://github.com/ExtendedXmlSerializer/home/issues/264"/> public static IConfigurationContainer WithDefaultMonitor(this IConfigurationContainer @this, ISerializationMonitor monitor) => @this.Extend(new SerializationMonitorExtension(monitor));
public static IConfigurationContainer EnableMemberExceptionHandling(this IConfigurationContainer @this) => @this.Extend(MemberExceptionHandlingExtension.Default);
public static IConfigurationContainer WithValidCharacters(this IConfigurationContainer @this) => @this.Type <string>() .Alter(ValidContentCharacters.Default.Get);
public static IConfigurationContainer EnableThreadProtection(this IConfigurationContainer @this) => @this.Extend(ThreadProtectionExtension.Default);
public static ITypeConfiguration <T> Register <T, TSerializer>(this IConfigurationContainer @this) where TSerializer : ISerializer <T> => @this.Type <T>() .Register(typeof(TSerializer));
public static ITypeConfiguration <T> CustomSerializer <T>(this IConfigurationContainer @this, Type serializerType) => @this.Type <T>() .CustomSerializer(new ActivatedXmlSerializer(serializerType, Support <T> .Key));
public static ITypeConfiguration <T> ConfigureType <T>(this IConfigurationContainer @this) => @this.Type <T>();
public static IConfigurationContainer UseAutoFormatting(this IConfigurationContainer @this) => @this.Extend(AutoMemberFormatExtension.Default);
/// <summary> /// Starts a new MetricsPipe instance. /// </summary> /// <returns></returns> public MetricsPipe Start() { IConfigurationContainer configurationContainer = GraphiteConfigurationProvider.Get(); return(this.Start(configurationContainer)); }