Beispiel #1
0
 public static void ActiveCorePreferencesRenderers()
 {
     PreferencesRenderersManager.AddPreferencesRenderer <DateRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerMemberNameRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerFilePathRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerLineNumberRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventIdRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventNameRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <ExceptionRenderer>();
 }
 public static void ActiveCorePreferencesRenderers()
 {
     PreferencesRenderersManager.AddPreferencesRenderer <DateRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerMemberNameRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerFilePathRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <CallerLineNumberRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventIdRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <ParentEventIdRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventIdChainsRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <ScopeTraceIdRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <BusinessTraceIdRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventLevelRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <EventNameRenderer>();
     PreferencesRenderersManager.AddPreferencesRenderer <ExceptionRenderer>();
 }
Beispiel #3
0
 private static void Core(IEnumerable <Type> givenTypes)
 {
     foreach (var type in givenTypes)
     {
         var reflector       = type.GetReflector();
         var sinkMode        = PreferencesSinkRendererType.IsAssignableFrom(type);
         var declareInfos    = reflector.GetCustomAttributes <RendererAttribute>().Where(x => !string.IsNullOrWhiteSpace(x.Name)).ToList();
         var constructorInfo = type.GetConstructors().FirstOrDefault(x => !x.GetParameters().Any());
         if (constructorInfo == null)
         {
             throw new InvalidOperationException("Preferences renderer must has a args-less constructor.");
         }
         var instance = constructorInfo.GetReflector().Invoke();
         if (declareInfos.Any())
         {
             if (sinkMode && instance is IPreferencesSinkRenderer sinkRenderer)
             {
                 PreferencesRenderersManager.AddPreferencesSinkRenderer(declareInfos.Select(x => (x.SinkPrefix, x.Name)).ToList(), sinkRenderer);
             }
             else if (instance is IPreferencesRenderer renderer)
             {
                 PreferencesRenderersManager.AddPreferencesRenderer(declareInfos.Select(x => x.Name).ToList(), renderer);
             }
             else
             {
                 throw new InvalidOperationException("Unknown renderer.");
             }
         }
         else
         {
             if (sinkMode && instance is IPreferencesSinkRenderer sinkRenderer)
             {
                 PreferencesRenderersManager.AddPreferencesSinkRenderer(sinkRenderer);
             }
             else if (instance is IPreferencesRenderer renderer)
             {
                 PreferencesRenderersManager.AddPreferencesRenderer(renderer);
             }
             else
             {
                 throw new InvalidOperationException("Unknown renderer.");
             }
         }
     }
 }