public RollbarClient(RollbarConfig config, HttpClient httpClient)
        {
            Assumption.AssertNotNull(config, nameof(config));
            Assumption.AssertNotNull(httpClient, nameof(httpClient));

            this._config = config;

            this._payloadPostUri = new Uri($"{this._config.EndPoint}item/");


            this._httpClient = httpClient;

            var header = new MediaTypeWithQualityHeaderValue("application/json");

            if (!this._httpClient.DefaultRequestHeaders.Accept.Contains(header))
            {
                this._httpClient.DefaultRequestHeaders.Accept.Add(header);
            }

            var sp = ServicePointManager.FindServicePoint(new Uri(this._config.EndPoint));

            sp.ConnectionLeaseTimeout = 60 * 1000; // 1 minute


            this._payloadTruncationStrategy = new IterativeTruncationStrategy();
        }
Example #2
0
        public RollbarLoggerBlockingWrapper(RollbarLogger asyncLogger, TimeSpan timeout)
        {
            Assumption.AssertNotNull(asyncLogger, nameof(asyncLogger));

            this._asyncLogger = asyncLogger;
            this._timeout     = timeout;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Exception"/> class.
        /// </summary>
        /// <param name="exception">The exception.</param>
        public Exception(System.Exception exception)
        {
            Assumption.AssertNotNull(exception, nameof(exception));

            this.Class   = exception.GetType().FullName;
            this.Message = exception.Message;
        }
Example #4
0
        /// <summary>
        /// Handles the Reconfigured event of the Config control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void Config_Reconfigured(object sender, EventArgs e)
        {
            RollbarConfig config = (RollbarConfig)sender;

            Assumption.AssertNotNull(config, nameof(config));

            string newStorePath = config.GetLocalPayloadStoreFullPathName();

            if (this._useLocalPayloadStore && string.Compare(newStorePath, StoreContext.RollbarStoreDbFullName, false) != 0)
            {
                this.Stop(true);
                StoreContext.RollbarStoreDbFullName = newStorePath;
                this.Start();
            }

            lock (this._syncLock)
            {
                this.ReevaluateUseOfLocalPayloadStore();

                PayloadQueue queue = config.Logger.Queue;
                Assumption.AssertNotNull(queue, nameof(queue));

                //refresh indexing:
                this.DropIndexByToken(queue);
                this.IndexByToken(queue);
                Debug.WriteLine(this.GetType().Name + ": Re-indexed a reconfigured queue. Total queues count: " + this._allQueues.Count + ".");
            }
        }
Example #5
0
        ///// <summary>
        ///// Initializes a new instance of the <see cref="Body"/> class.
        ///// </summary>
        ///// <param name="exception">The exception.</param>
        //public Body(AggregateException exception)
        //    : this(exception.InnerExceptions)
        //{
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="Body"/> class.
        /// </summary>
        /// <param name="exception">The exception.</param>
        public Body(System.Exception exception)
        {
            Assumption.AssertNotNull(exception, nameof(exception));

            AggregateException aggregateException = exception as AggregateException;

            if (aggregateException != null)
            {
                TraceChain = aggregateException.InnerExceptions.Select(e => new Trace(e)).ToArray();
            }
            else if (exception.InnerException != null)
            {
                var exceptionList  = new List <System.Exception>();
                var outerException = exception;
                while (outerException != null)
                {
                    exceptionList.Add(outerException);
                    outerException = outerException.InnerException;
                }
                TraceChain = exceptionList.Select(e => new Trace(e)).ToArray();
            }
            else
            {
                Trace = new Trace(exception);
            }

            Validate();
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequestPackageDecorator"/> class.
        /// </summary>
        /// <param name="packageToDecorate">The package to decorate.</param>
        /// <param name="httpRequest">The HTTP request.</param>
        /// <param name="mustApplySynchronously">if set to <c>true</c> [must apply synchronously].</param>
        public HttpRequestPackageDecorator(IRollbarPackage packageToDecorate, HttpRequestBase httpRequest, bool mustApplySynchronously)
            : base(packageToDecorate, mustApplySynchronously)
        {
            Assumption.AssertNotNull(httpRequest, nameof(httpRequest));

            this._httpRequest = httpRequest;
        }
Example #7
0
        /// <summary>
        /// Gets the recommended timeout.
        /// </summary>
        /// <returns>TimeSpan.</returns>
        public TimeSpan GetRecommendedTimeout()
        {
            TimeSpan timeout = TimeSpan.Zero;

            string[] accessTokens;
            lock (this._syncLock)
            {
                Assumption.AssertNotNull(this._config, nameof(this._config));

                accessTokens = this._queuesByAccessToken.Keys.ToArray();
            }

            if (accessTokens == null)
            {
                return(timeout);
            }

            foreach (var token in accessTokens)
            {
                TimeSpan tokenTimeout = this.GetRecommendedTimeout(token);
                if (timeout < tokenTimeout)
                {
                    timeout = tokenTimeout;
                }
            }
            return(timeout);
        }
Example #8
0
        /// <summary>
        /// Validates this instance.
        /// </summary>
        public override void Validate()
        {
            base.Validate();

            Assumption.AssertNotNull(this.Body, nameof(this.Body));
            Assumption.AssertTrue(this.Body.GetType().Name.Contains(this.Type.ToString()), nameof(this.Body));
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Data" /> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="body">The body.</param>
        /// <param name="custom">The custom.</param>
        /// <param name="request">The request.</param>
        public Data(IRollbarConfig config, Body body, IDictionary <string, object> custom = null, Request request = null)
        {
            Assumption.AssertNotNull(config, nameof(config));
            Assumption.AssertNotNull(body, nameof(body));

            // snap config values:
            this.Environment = config.Environment;
            this.Level       = config.LogLevel;
            this.Person      = config.Person;
            this.Server      = config.Server;

            // set explicit values:
            this.Body    = body;
            this.Request = request;
            this.Custom  = custom;

            // set calculated values:
            this.Platform  = Data.DefaultPlatform;
            this.Framework = Data.DefaultFrameworkValue;
            this.Language  = Data.DefaultLanguage;
            this.Notifier  = new Dictionary <string, string>
            {
                { "name", "Rollbar.NET" },
                { "version", Data.NotifierAssemblyVersion },
            };
            this.GuidUuid  = Guid.NewGuid();
            this.Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
        }
Example #10
0
        private static ExtendableDtoMetadata Build(Type extendableDtoType)
        {
            Assumption.AssertNotNull(extendableDtoType, nameof(extendableDtoType));

            ExtendableDtoMetadata result = new ExtendableDtoMetadata();

            result.ExtendableDtoType = extendableDtoType;

            List <Type> reservedPropertiesNestedTypes = new List <Type>();
            Type        extendableDtoHierarchyType    = extendableDtoType;

            while (extendableDtoHierarchyType != null)
            {
                Type reservedPropertiesNestedType = ReflectionUtility.GetNestedTypeByName(
                    extendableDtoHierarchyType,
                    ExtendableDtoBase.reservedPropertiesNestedTypeName,
                    BindingFlags.Public | BindingFlags.Static
                    );
                if (reservedPropertiesNestedType != null)
                {
                    reservedPropertiesNestedTypes.Add(reservedPropertiesNestedType);
                }
                if (extendableDtoHierarchyType.BaseType == typeof(ExtendableDtoBase))
                {
                    break;
                }
                if (extendableDtoHierarchyType.BaseType != null)
                {
                    extendableDtoHierarchyType = extendableDtoHierarchyType.BaseType;
                }
            }

            List <FieldInfo> reservedAttributes = new List <FieldInfo>();

            foreach (Type reservedPropertiesNestedType in reservedPropertiesNestedTypes)
            {
                reservedAttributes.AddRange(
                    ReflectionUtility.GetAllPublicStaticFields(reservedPropertiesNestedType)
                    );
            }

            Dictionary <string, PropertyInfo> reservedPropertyInfoByName =
                new Dictionary <string, PropertyInfo>(reservedAttributes.Count);

            result.ReservedPropertyInfoByReservedKey = reservedPropertyInfoByName;

            foreach (var reservedAttribue in reservedAttributes)
            {
                var property =
                    extendableDtoType.GetProperty(reservedAttribue.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
                Assumption.AssertNotNull(property, nameof(property));

                string reservedKey = ReflectionUtility.GetStaticFieldValue <string>(reservedAttribue);
                Assumption.AssertNotNullOrWhiteSpace(reservedKey, nameof(reservedKey));

                reservedPropertyInfoByName.Add(reservedKey, property);
            }

            return(result);
        }
Example #11
0
        private void SnapProperties(HttpRequestMessage httpRequest, IRollbarConfig rollbarConfig)
        {
            Assumption.AssertNotNull(httpRequest, nameof(httpRequest));

            this.Url         = httpRequest.RequestUri?.AbsoluteUri;
            this.QueryString = httpRequest.RequestUri?.Query;
            this.Params      = null;

            this.Headers = new Dictionary <string, string>(httpRequest.Headers.Count());
            foreach (var header in httpRequest.Headers)
            {
                this.Headers.Add(header.Key, StringUtility.Combine(header.Value, ", "));
            }

            this.Method = httpRequest.Method.Method;
            switch (this.Method.ToUpperInvariant())
            {
            case "POST":
                var task = httpRequest.Content.ReadAsStringAsync();
                task.Wait();
                this.PostBody   = task.Result;
                this.PostParams = null;
                break;

            case "GET":
                this.GetParams = null;
                break;

            default:
                System.Diagnostics.Trace.WriteLine(
                    $"No-op processing {this.Method.ToUpperInvariant()} HTTP method."
                    );
                break;
            }

#if (NETFX)
            string       userIP = null;
            const string HttpContextProperty          = "MS_HttpContext";
            const string RemoteEndpointMessagePropery = "System.ServiceModel.Channels.RemoteEndpointMessageProperty";
            if (httpRequest.Properties.ContainsKey(HttpContextProperty))
            {
                HttpContextBase ctx = httpRequest.Properties[HttpContextProperty] as HttpContextBase;
                if (ctx != null)
                {
                    userIP = ctx.Request.UserHostAddress;
                }
            }
            else if (httpRequest.Properties.ContainsKey(RemoteEndpointMessagePropery))
            {
                RemoteEndpointMessageProperty remoteEndpoint =
                    httpRequest.Properties[RemoteEndpointMessagePropery] as RemoteEndpointMessageProperty;
                if (remoteEndpoint != null)
                {
                    userIP = remoteEndpoint.Address;
                }
            }
            this.UserIp =
                Request.DecideCollectableUserIPValue(userIP, rollbarConfig.IpAddressCollectionPolicy);
#endif
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpResponsePackageDecorator"/> class.
        /// </summary>
        /// <param name="packageToDecorate">The package to decorate.</param>
        /// <param name="httpResponse">The HTTP response.</param>
        /// <param name="mustApplySynchronously">if set to <c>true</c> [must apply synchronously].</param>
        public HttpResponsePackageDecorator(IRollbarPackage packageToDecorate, HttpResponseBase httpResponse, bool mustApplySynchronously)
            : base(packageToDecorate, mustApplySynchronously)
        {
            Assumption.AssertNotNull(httpResponse, nameof(httpResponse));

            this._httpResponse = httpResponse;
        }
Example #13
0
        private static string GetMethod(StackFrame frame)
        {
            Assumption.AssertNotNull(frame, nameof(frame));

            MethodBase method = frame.GetMethod();

            if (method == null)
            {
                return(frame.ToString());
            }

            var methodName = method.Name;

            if (method.ReflectedType != null)
            {
                methodName = string.Format("{0}.{1}", method.ReflectedType.FullName, methodName);
            }

            var parameters = method.GetParameters();

            if (parameters.Length > 0)
            {
                return(string.Format("{0}({1})", methodName, string.Join(", ", parameters.Select(p => string.Format("{0} {1}", p.ParameterType, p.Name)))));
            }

            return(string.Format("{0}()", methodName));
        }
Example #14
0
        private static string GetFileName(StackFrame frame)
        {
            Assumption.AssertNotNull(frame, nameof(frame));

            string returnVal = defaultFileName;

            if (frame == null)
            {
                return(returnVal);
            }

            returnVal = frame.GetFileName();
            if (!string.IsNullOrWhiteSpace(returnVal))
            {
                return(returnVal);
            }

            MethodBase method = frame.GetMethod();

            if (method != null && method.ReflectedType != null)
            {
                returnVal = method.ReflectedType.FullName;
            }
            if (!string.IsNullOrWhiteSpace(returnVal))
            {
                return(returnVal);
            }

            return(defaultFileName);
        }
Example #15
0
        /// <summary>
        /// Validates this instance.
        /// </summary>
        public override void Validate()
        {
            Assumption.AssertNotNullOrWhiteSpace(this.AccessToken, nameof(this.AccessToken));
            Assumption.AssertNotNull(this.Data, nameof(this.Data));

            this.Data.Validate();
        }
Example #16
0
        public RollbarClient(RollbarConfig config, HttpClient httpClient)
        {
            Assumption.AssertNotNull(config, nameof(config));
            Assumption.AssertNotNull(httpClient, nameof(httpClient));

            this._config = config;

            this._payloadPostUri = new Uri($"{this._config.EndPoint}item/");


            this._httpClient = httpClient;

            var header = new MediaTypeWithQualityHeaderValue("application/json");

            if (!this._httpClient.DefaultRequestHeaders.Accept.Contains(header))
            {
                this._httpClient.DefaultRequestHeaders.Accept.Add(header);
            }

            var sp = ServicePointManager.FindServicePoint(new Uri(this._config.EndPoint));

            try
            {
                sp.ConnectionLeaseTimeout = 60 * 1000; // 1 minute
            }
            catch (NotImplementedException ex)
            {
                // just a crash prevention.
                // this is a work around the unimplemented property within Mono runtime...
            }

            this._payloadTruncationStrategy = new IterativeTruncationStrategy();
        }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarPackageDecoratorBase" /> class.
        /// </summary>
        /// <param name="packageToDecorate">The package to decorate.</param>
        /// <param name="mustApplySynchronously">if set to <c>true</c> the strategy must be apply synchronously.</param>
        protected RollbarPackageDecoratorBase(IRollbarPackage packageToDecorate, bool mustApplySynchronously)
            : base(mustApplySynchronously)
        {
            Assumption.AssertNotNull(packageToDecorate, nameof(packageToDecorate));

            this._packageToDecorate = packageToDecorate;
        }
Example #18
0
        /// <summary>
        /// Truncates the string values.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="encoding">The encoding.</param>
        /// <param name="stringBytesLimit">The string bytes limit.</param>
        protected void TruncateStringValues(IDictionary <string, object> dictionary, Encoding encoding, int stringBytesLimit)
        {
            Assumption.AssertNotNull(dictionary, nameof(dictionary));

            var keys = dictionary.Keys.ToArray();

            foreach (var key in keys)
            {
                string originalString = dictionary[key] as string;
                if (originalString != null)
                {
                    string truncatedString = StringUtility.Truncate(originalString, encoding, stringBytesLimit);
                    if (!object.ReferenceEquals(originalString, truncatedString))
                    {
                        dictionary[key] = truncatedString;
                    }
                    continue;
                }

                var objectDictionary = dictionary[key] as IDictionary <string, object>;
                if (objectDictionary != null)
                {
                    TruncateStringValues(objectDictionary, encoding, stringBytesLimit);
                    continue;
                }

                var stringDictionary = dictionary[key] as IDictionary <string, string>;
                if (stringDictionary != null)
                {
                    TruncateStringValues(stringDictionary, encoding, stringBytesLimit);
                    continue;
                }
            }
        }
Example #19
0
        /// <summary>
        /// Gets the recommended timeout.
        /// </summary>
        /// <param name="accessToken">The Rollbar access token.</param>
        /// <returns>TimeSpan.</returns>
        public TimeSpan GetRecommendedTimeout(string?accessToken)
        {
            TimeSpan payloadTimeout = TimeSpan.Zero;

            if (string.IsNullOrWhiteSpace(accessToken))
            {
                return(payloadTimeout);
            }

            int totalPayloads = 0;

            lock (this._syncLock)
            {
                Assumption.AssertNotNull(this._config, nameof(this._config));

                if (this._queuesByAccessToken.TryGetValue(accessToken !, out AccessTokenQueuesMetadata? tokenMetadata))
                {
                    foreach (var queue in tokenMetadata.GetPayloadQueues())
                    {
                        totalPayloads += queue.GetPayloadCount();
                        TimeSpan queueTimeout =
                            this._config !.RollbarInfrastructureOptions.MaxReportsPerMinute.HasValue ?
                            TimeSpan.FromTicks(TimeSpan.FromMinutes(1).Ticks / this._config.RollbarInfrastructureOptions.MaxReportsPerMinute.Value)
                            : TimeSpan.Zero;
                        if (payloadTimeout < queueTimeout)
                        {
                            payloadTimeout = queueTimeout;
                        }
                    }
                }
            }

            return(TimeSpan.FromTicks((totalPayloads + 1) * payloadTimeout.Ticks));
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Data" /> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="body">The body.</param>
        /// <param name="custom">The custom.</param>
        /// <param name="request">The request.</param>
        public Data(
            IRollbarConfig config,
            Body body,
            IDictionary <string, object> custom,
            Request request
            )
        {
            Assumption.AssertNotNull(body, nameof(body));

            // snap config values:
            if (config != null)
            {
                this.Environment = config.Environment;
                this.Level       = config.LogLevel;
                this.Person      = config.Person;
                this.Server      = config.Server;
            }

            // set explicit values:
            this.Body    = body;
            this.Request = request;
            this.Custom  = custom;

            // set calculated values:
            this.Platform  = Data.DefaultPlatform;
            this.Framework = Data.DefaultFrameworkValue;
            this.Language  = Data.DefaultLanguage;
            this.Notifier  = new Dictionary <string, string>
            {
                { "name", "Rollbar.NET" },
                { "version", Data.NotifierAssemblyVersion },
            };
            this.GuidUuid  = Guid.NewGuid();
            this.Timestamp = DateTimeUtil.ConvertToUnixTimestampInSeconds(DateTime.UtcNow);
        }
Example #21
0
        /// <summary>
        /// Flushes the queues.
        /// All current payloads in every queue get removed (without transmitting them to the Rollbar API).
        /// </summary>
        public void FlushQueues()
        {
            lock (this._syncLock)
            {
                Assumption.AssertNotNull(this._config, nameof(this._config));

                foreach (var queue in this._allQueues)
                {
                    foreach (var flushedBundle in queue.Flush())
                    {
                        Payload?payload = null;
                        try
                        {
                            payload = flushedBundle?.GetPayload();
                        }
                        catch
                        {
                            payload = null;
                        }
                        finally
                        {
                            this.OnRollbarEvent(
                                new PayloadDropEventArgs(
                                    queue.Logger,
                                    payload,
                                    PayloadDropEventArgs.DropReason.RollbarQueueControllerFlushedQueues
                                    )
                                );
                        }
                    }
                }
            }
        }
        public IRollbar Configure(IRollbarConfig settings)
        {
            Assumption.AssertNotNull(settings, nameof(settings));
            this._asyncLogger.Config.Reconfigure(settings);

            return(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequestPackageDecorator" /> class.
        /// </summary>
        /// <param name="packageToDecorate">The package to decorate.</param>
        /// <param name="httpRequest">The HTTP request.</param>
        public HttpRequestPackageDecorator(IRollbarPackage packageToDecorate, HttpRequestBase httpRequest)
            : base(packageToDecorate, false)
        {
            Assumption.AssertNotNull(httpRequest, nameof(httpRequest));

            this._httpRequest = httpRequest;
        }
Example #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Data" /> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="body">The body.</param>
        /// <param name="custom">The custom.</param>
        /// <param name="request">The request.</param>
        public Data(
            IRollbarLoggerConfig?config,
            Body body,
            IDictionary <string, object?>?custom,
            Request?request
            )
        {
            Assumption.AssertNotNull(body, nameof(body));

            // snap config values:
            if (config != null)
            {
                this.Environment = config.RollbarDestinationOptions.Environment;
                this.Level       = config.RollbarDeveloperOptions.LogLevel;
                this.Person      = config.RollbarPayloadAdditionOptions.Person;
                this.Server      = config.RollbarPayloadAdditionOptions.Server;
            }

            // set explicit values:
            this.Body    = body;
            this.Request = request;
            this.Custom  = custom;

            // set calculated values:
            this.Platform  = Data.DefaultPlatform;
            this.Framework = Data.DefaultFrameworkValue;
            this.Language  = Data.DefaultLanguage;
            this.Notifier  = new Notifier();
            this.GuidUuid  = Guid.NewGuid();
            this.Timestamp = DateTimeUtil.ConvertToUnixTimestampInSeconds(DateTime.UtcNow);
        }
Example #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Body"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public Body(Message message)
        {
            Assumption.AssertNotNull(message, nameof(message));

            Message = message;
            Validate();
        }
Example #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarBlazorClient"/> class.
        /// </summary>
        /// <param name="rollbarLogger">The rollbar logger.</param>
        /// <param name="httpClient">The HTTP client.</param>
        public RollbarBlazorClient(IRollbar rollbarLogger, HttpClient httpClient)
            : base(rollbarLogger)
        {
            Assumption.AssertNotNull(httpClient, nameof(httpClient));

            this.Set(httpClient);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbarExceptionDto"/> class.
        /// </summary>
        /// <param name="exception">The exception.</param>
        public RollbarExceptionDto(System.Exception exception)
        {
            Assumption.AssertNotNull(exception, nameof(exception));

            Class   = exception.GetType().FullName;
            Message = exception.Message;
        }
        /// <summary>
        /// Deduces the rollbar configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public static IRollbarConfig DeduceRollbarConfig(IConfiguration configuration)
        {
            if (RollbarLocator.RollbarInstance.Config.AccessToken != null)
            {
                return(RollbarLocator.RollbarInstance.Config);
            }

            // Here we assume that the Rollbar singleton was not explicitly preconfigured
            // anywhere in the code (Program.cs or Startup.cs),
            // so we are trying to configure it from IConfiguration:

            Assumption.AssertNotNull(configuration, nameof(configuration));

            const string  defaultAccessToken = "none";
            RollbarConfig rollbarConfig      = new RollbarConfig(defaultAccessToken);

            AppSettingsUtility.LoadAppSettings(rollbarConfig, configuration);

            if (rollbarConfig.AccessToken == defaultAccessToken)
            {
                const string error = "Rollbar.NET notifier is not configured properly. A valid access token needs to be specified.";
                throw new Exception(error);
            }

            RollbarLocator.RollbarInstance
            .Configure(rollbarConfig);

            return(rollbarConfig);
        }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Trace"/> class.
        /// </summary>
        /// <param name="frames">The frames.</param>
        /// <param name="exception">The exception.</param>
        public Trace(Frame[] frames, Exception exception)
        {
            Assumption.AssertNotNull(frames, nameof(frames));
            Assumption.AssertNotNull(exception, nameof(exception));

            Frames    = frames;
            Exception = exception;
        }
Example #30
0
        /// <summary>
        /// Does the type implement interface.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <returns><c>true</c> if implements, <c>false</c> otherwise.</returns>
        public static bool DoesTypeImplementInterface(Type type, Type interfaceType)
        {
            Assumption.AssertNotNull(type, nameof(type));
            Assumption.AssertNotNull(interfaceType, nameof(interfaceType));
            Assumption.AssertTrue(interfaceType.IsInterface, nameof(interfaceType));

            return(type.GetInterfaces().Any(i => i.FullName == interfaceType.FullName));
        }