Beispiel #1
0
        private static bool PerformInitialization()
        {
            // We will now try to load the "right" version of System.Diagnostics.DiagnosticSource.dll
            // (henceforth we'll use the abbreviation DiagnosticSource.dll).
            // Here, "right" is defined as: if the app is using DiagnosticSource.dll we prefer to load that version.
            // Otherwise we prefer the version included with this library, which should be a relatively recent one.

            Assembly diagnosticSourceAssembly = LoadDiagnosticSourceAssembly();

            if (diagnosticSourceAssembly == null)
            {
                return(false);
            }

            Type activityType = diagnosticSourceAssembly.GetType(ActivityType_FullName, throwOnError: true);

            if (activityType == null)
            {
                return(false);
            }

            var supportedFeatures = new SupportedFeatures()
            {
            };

            s_invoker = new DynamicInvokerOld(supportedFeatures, activityType, null, null);
            return(true);
        }
        internal DynamicInvokerOld(
            SupportedFeatures supportedFeatures,
            Type activityType,
            Type activityListenerType,
            Type activitySourceType)
        {
            Validate.NotNull(supportedFeatures, nameof(supportedFeatures));
            _supportedFeatures = supportedFeatures;

            Activity           = new DynamicActivityInvoker(activityType);
            DiagnosticListener = new DynamicDiagnosticListenerInvoker(activityListenerType);
            ActivitySource     = (activitySourceType == null) ? null : new DynamicActivitySourceInvoker(activitySourceType);
        }