예제 #1
0
		public ShaolinqErrorLog(IDictionary config)
		{
			var dataAccessModelTypeName = config.Find("dataAccessModelType", string.Empty);

			if (string.IsNullOrEmpty(dataAccessModelTypeName))
			{
				throw new ApplicationException("DataAccessModelType not specified");
			}

			var modelType = Type.GetType(dataAccessModelTypeName);

			if (modelType == null)
			{
				throw new ApplicationException($"Could not find type {dataAccessModelTypeName}");
			}

			if (!modelType.GetInterfaces().Contains(typeof(IElmahDataAccessModel)))
			{
				throw new ApplicationException("DataAccessModelType must implement IElmahDataAccessModel");
			}

			var dataAccessModelConfigSection = config.Find("dataAccessModelConfigSection", modelType.Name);

			var dataAccessModelConfiguration = ConfigurationBlock<DataAccessModelConfiguration>.Load(dataAccessModelConfigSection);

			this.dataModel = (IElmahDataAccessModel)DataAccessModel.BuildDataAccessModel(
				Type.GetType(dataAccessModelTypeName),
				dataAccessModelConfiguration);

			// Set the application name as this implementation provides per-application isolation over a single store.
			// Use application name of "*" to disable per-application isolation.
			var appName = config.Find("applicationName", string.Empty);

			if (appName.Length > MaxAppNameLength)
			{
				throw new ApplicationException($"Application name is too long. Maximum length allowed is {MaxAppNameLength.ToString("N0")} characters.");
			}

			ApplicationName = appName;
		}
예제 #2
0
        public ShaolinqErrorLog(IDictionary config)
        {
            var dataAccessModelTypeName = config.Find("dataAccessModelType", string.Empty);

            if (string.IsNullOrEmpty(dataAccessModelTypeName))
            {
                throw new ApplicationException("DataAccessModelType not specified");
            }

            var modelType = Type.GetType(dataAccessModelTypeName);

            if (modelType == null)
            {
                throw new ApplicationException($"Could not find type {dataAccessModelTypeName}");
            }

            if (!modelType.GetInterfaces().Contains(typeof(IElmahDataAccessModel)))
            {
                throw new ApplicationException("DataAccessModelType must implement IElmahDataAccessModel");
            }

            var dataAccessModelConfigSection = config.Find("dataAccessModelConfigSection", modelType.Name);

            var dataAccessModelConfiguration = ConfigurationBlock <DataAccessModelConfiguration> .Load(dataAccessModelConfigSection);

            this.dataModel = (IElmahDataAccessModel)DataAccessModel.BuildDataAccessModel(
                Type.GetType(dataAccessModelTypeName),
                dataAccessModelConfiguration);

            // Set the application name as this implementation provides per-application isolation over a single store.
            // Use application name of "*" to disable per-application isolation.
            var appName = config.Find("applicationName", string.Empty);

            if (appName.Length > MaxAppNameLength)
            {
                throw new ApplicationException($"Application name is too long. Maximum length allowed is {MaxAppNameLength.ToString("N0")} characters.");
            }

            ApplicationName = appName;
        }