Elmah.ServiceCenter.GetService C# (CSharp) Méthode

GetService() public static méthode

Gets a service of a given type based on a given context. If the service is not available, an exception is thrown.
public static GetService ( object context, Type serviceType ) : object
context object
serviceType System.Type
Résultat object
        public static object GetService(object context, Type serviceType)
        {
            var service = FindService(context, serviceType);
            
            if (service == null)
                throw new Exception(string.Format("Service of the type {0} is not available.", serviceType));
            
            return service;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Gets the default error log implementation specified in the
        /// configuration file, or the in-memory log implemention if
        /// none is configured.
        /// </summary>

        public static ErrorLog GetDefault(HttpContextBase context)
        {
            return((ErrorLog)ServiceCenter.GetService(context, typeof(ErrorLog)));
        }