Example #1
0
        internal override HandleGraph <FilterHandle> Build(Encoding encoding)
        {
            HandleGraph <FilterHandle> child = null;
            FilterHandle primaryFilter       = null;

            // There can be a maximum of 3 exceptions if filter initialization fails:
            // * Initial exception that caused the initialization to fail.
            // * Exception raised when calling primaryFilter.Dispose ().
            // * Exception raised when calling child.Dispose ().
            var cleanupErrors = new List <Exception> (3);

            try
            {
                child = Child.Build(encoding);

                Log4JParserC.Log4JFilterInitNot(out primaryFilter, child.Handle);

                return(HandleGraph.Composite(primaryFilter, child));
            }
            catch (Exception initEx)
            {
                cleanupErrors.Add(initEx);
                Disposable.TryDispose(primaryFilter, cleanupErrors);
                Disposable.TryDispose(child, cleanupErrors);

                if (cleanupErrors.Count > 1)
                {
                    throw new AggregateException(cleanupErrors);
                }

                throw;
            }
        }
Example #2
0
            private static IteratorHandle Init(IteratorHandle inner, HandleGraph <FilterHandle> filterHandle)
            {
                IteratorHandle result;

                Log4JParserC.Log4JIteratorInitFilter(out result, inner, filterHandle.Handle);

                return(result);
            }
Example #3
0
            public SingleChildHandle(THandle impl, HandleGraph <THandle> child)
                : base(impl)
            {
                if (child == null)
                {
                    throw new ArgumentNullException(nameof(child));
                }

                child_ = child;
            }
Example #4
0
        internal override HandleGraph <FilterHandle> Build(Encoding encoding)
        {
            FilterHandle result = null;

            try
            {
                Log4JParserC.Log4JFilterInitTimestamp(out result, Min, Max);
                return(HandleGraph.Simple(result));
            }
            catch (Exception ex)
            {
                Disposable.DisposeAggregateErrors(result, ex);
                throw;
            }
        }
Example #5
0
        internal EnumeratorBase GetEnumerator()
        {
            HandleGraph <FilterHandle> filterHandle = null;

            try
            {
                filterHandle = filter_.Build(Encoding);
                return(new Enumerator(source_.GetEnumerator(), filterHandle));
            }
            catch
            {
                filterHandle?.Dispose();
                throw;
            }
        }
Example #6
0
        internal override HandleGraph <FilterHandle> Build(Encoding encoding)
        {
            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }

            var logger     = encoding.GetBytes(Logger);
            var loggerSize = new UIntPtr((uint)logger.Length);

            FilterHandle result = null;

            try
            {
                Log4JParserC.Log4JFilterInitLoggerFs(out result, logger, loggerSize);
                return(HandleGraph.Simple(result));
            }
            catch (Exception ex)
            {
                Disposable.DisposeAggregateErrors(result, ex);
                throw;
            }
        }
Example #7
0
 public Enumerator(EnumeratorBase inner, HandleGraph <FilterHandle> filterHandle)
     : base(Init(inner.Handle, filterHandle), inner.Owner)
 {
     inner_        = inner;
     filterHandle_ = filterHandle;
 }
Example #8
0
 internal static HandleGraph <THandle> Composite(THandle impl, HandleGraph <THandle> child)
 => new SingleChildHandle(impl, child);