Beispiel #1
0
        private static void SemanticObjectUnsafe(this TraceSource trace, SemanticTrace id, TraceEventType type, object objectId, string message, object data = null)
        {
            Contract.Requires(trace != null);

#if TRACING
            new PermissionSet(PermissionState.Unrestricted).Assert();

            try
            {
#endif
            SemanticObject(trace, id, type, objectId, message, data);
#if TRACING
        }

        finally
        {
            PermissionSet.RevertAssert();
        }
#endif
        }
Beispiel #2
0
        /*
         * private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, string message, object data)
         * {
         * Contract.Requires(trace != null);
         *
         * trace.TraceEvent(type, (int)id, message + " = " + data);
         * }
         *
         * private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, object data)
         * {
         * Contract.Requires(trace != null);
         *
         * trace.TraceEvent(type, (int)id, data?.ToString());
         * }
         *
         * private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, string message)
         * {
         * Contract.Requires(trace != null);
         *
         * trace.TraceEvent(type, (int)id, message);
         * }
         *
         * private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, string format, params object[] args)
         * {
         * Contract.Requires(trace != null);
         *
         * if (format == null || args == null)
         * {
         *  trace.Semantic(id, type, format);
         * }
         * else
         * {
         *  trace.TraceEvent(type, (int)id, format, args);
         * }
         * }
         *
         * private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, FormattableString message)
         * {
         * Contract.Requires(trace != null);
         *
         * trace.TraceEvent(type, (int)id, message?.ToString(CultureInfo.InvariantCulture));
         * }
         */

        private static void SemanticObject(this TraceSource trace, SemanticTrace id, TraceEventType type, object objectId, string message, object data = null)
        {
            Contract.Requires(trace != null);

            trace.TraceEvent(type, (int)id, FormatObjectId(objectId) + " " + message + (data == null ? string.Empty : " = " + data));
        }