Пример #1
0
        private static void ThrowArgumentNullException(DomainLogger logger, string tag, string message)
        {
            var ex = new ArgumentNullException(message);

            logger.E(tag, ex.ToString() ?? "");
            throw ex;
        }
Пример #2
0
        private void CreateAndAddLogger(string domain, int index)
        {
            var logger = new DomainLogger(domain, true)
            {
                Level = Log.LogLevel.Base
            };

            _allLoggers[index] = logger;
        }
Пример #3
0
        public static unsafe void *MustNotBeNullPointer([NotNull] DomainLogger logger, [NotNull] string tag, [NotNull] string argumentName, void *argumentValue)
        {
            Debug.Assert(argumentValue != null);
            if (argumentValue == null)
            {
                ThrowArgumentNullException(logger, tag, argumentName);
            }

            return(argumentValue);
        }
Пример #4
0
        public static T MustNotBeNull <T>([NotNull] DomainLogger logger, [NotNull] string tag, [NotNull] string argumentName, T argumentValue) where T : class
        {
            Debug.Assert(argumentValue != null);
            if (argumentValue == null)
            {
                ThrowArgumentNullException(logger, tag, argumentName);
            }

            return(argumentValue);
        }
Пример #5
0
        public static unsafe void *MustNotBeNullPointer([NotNull] DomainLogger logger, [NotNull] string tag, [NotNull] string argumentName, void *argumentValue)
        {
            Debug.Assert(argumentValue != null);
            if (argumentValue == null)
            {
                var ex = new ArgumentNullException(argumentName);
                logger.E(tag, ex.ToString() ?? "");
                throw ex;
            }

            return(argumentValue);
        }
Пример #6
0
        public static T MustNotBeNull <T>([NotNull] DomainLogger logger, [NotNull] string tag, [NotNull] string argumentName, T argumentValue) where T : class
        {
            Debug.Assert(argumentValue != null);
            if (argumentValue == null)
            {
                var ex = new ArgumentNullException(argumentName);
                logger.E(tag, ex.ToString() ?? "");
                throw ex;
            }

            return(argumentValue);
        }
Пример #7
0
        public static void LogAndThrow([NotNull] DomainLogger logger, [NotNull] Exception e, [NotNull] string tag, [NotNull] string message, bool fatal)
        {
            if (fatal)
            {
                logger.E(tag, message, e);
            }
            else
            {
                logger.W(tag, message, e);
            }

            throw e;
        }
Пример #8
0
        public static IEnumerable <T> ItemsMustNotBeNull <T>([NotNull] DomainLogger logger, [NotNull] string tag, [NotNull] string argumentName, IEnumerable <T> argumentValues) where T : class
        {
            Debug.Assert(argumentValues != null);
            if (argumentValues == null)
            {
                ThrowArgumentNullException(logger, tag, argumentName);
            }
            else
            {
                int index = 0;
                foreach (var item in argumentValues)
                {
                    if (item == null)
                    {
                        ThrowArgumentNullException(logger, tag, $"{argumentName}[{index}]");
                    }
                    index++;
                }
            }

            return(argumentValues);
        }
Пример #9
0
 public OneShotEnumerator(DomainLogger parent)
 {
     _parent = parent;
 }
Пример #10
0
 public static void AssertAndLog([NotNull] DomainLogger logger, bool assertion, [NotNull] string tag, [NotNull] string message)
 {
     Debug.Assert(assertion, message);
     logger.W(tag, message);
 }