public CommandHandler(ILogPolicy logService, IErrorPolicy errorService, IEventBus eventBus) { this.LogService = logService; this.ErrorService = errorService; this.EventBus = eventBus; }
/// <summary> /// Creates a new policy of the given type, with the passed args, and opens it. All messages logged after /// a policy is registered will be passed to it. Throws an exception if there is no constructor for the type /// that matches the passed arguments. /// </summary> /// <typeparam name="T">The type of policy to create and open.</typeparam> /// <param name="args">The args to pass to the policy constructor.</param> /// <returns>A unique identifier for the policy.</returns> public static uint RegisterPolicy <T>(params object[] args) where T : class, ILogPolicy { // Find a valid constructor Type[] argtypes = args.Select(o => o.GetType()).ToArray(); var cinfo = typeof(T).GetConstructor(argtypes); if (cinfo == null) { throw new ArgumentException($"There is no public constructor for the type '{typeof(T).Name}' that " + $"matches the passed argument list.", nameof(args)); } // Attempt to call the constructor ILogPolicy policy = null; try { policy = cinfo.Invoke(args) as ILogPolicy; } catch (Exception e) { throw new InvalidOperationException($"Unable to create ILogPolicy of type {typeof(T)}, reason: " + $"'{(e.InnerException == null ? e.Message : e.InnerException.Message)}'"); } // Open, save, return policy.Open(); lock (s_policyLock) { s_policies.Add(s_policyId, policy); return(s_policyId++); } }
/// <summary> /// Initializes a new instance of the <see cref="DeviceController" /> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> /// <param name="deviceRepository">The device repository.</param> public DeviceController( IConfiguration configService, ILogPolicy logService, IErrorPolicy errorService, IDeviceRepository deviceRepository) : base(configService, logService, errorService) { this.DeviceRepository = deviceRepository; }
/// <summary> /// Initializes a new instance of the <see cref="DeviceController" /> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> /// <param name="deviceService">The device service.</param> public DeviceController( IConfiguration configService, ILogPolicy logService, IErrorPolicy errorService, IDeviceService deviceService) : base(configService, logService, errorService) { this.DeviceService = deviceService; }
/// <summary> /// Creates a new default set of application parameters with the passed name and version. /// </summary> /// <param name="name">The name of the application.</param> /// <param name="version">The version of the application.</param> public AppParameters(string name, AppVersion version) { Name = name; Version = version; // Logger defaults DefaultLoggerTag = name; UseThreadedLogging = true; LogFileBaseName = "application"; LogFileTimestamp = true; LogFileHistorySize = 5; LogFileDirectory = "logs"; DefaultLoggingFormatter = null; DefaultLoggingPolicy = null; LibraryMessageMask = LoggingLevel.Standard; // Graphics defaults EnableValidationLayers = false; EnabledGraphicsFeatures = default; StrictGraphicsFeatures = true; // Content defaults GlobalContentPath = "data/Content.cpak"; }
/// <summary> /// Initializes a new instance of the <see cref="SiliconSQLProvider"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> /// <exception cref="IoTException"></exception> public SiliconSQLProvider(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService) { this.ConfigService = configService; this.ErrorService = errorService; this.LogService = logService; //set connection string if (!string.IsNullOrWhiteSpace(ConfigService[DB_CONNECTION_KEY])) { this.ConnectionString = ConfigService[DB_CONNECTION_KEY]; } else { throw new IoTException(ErrorMessages.DataProvider_ConnectionStringKeyMissing, ErrorReasonTypeEnum.Configuration); } }
/// <summary> /// Initializes a new instance of the <see cref="CommandEventHandler" /> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> public CommandEventHandler(ILogPolicy logService, IErrorPolicy errorService) : base(logService, errorService) { }
/// <summary> /// Initializes a new instance of the <see cref="DeviceDataProvider"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> /// <param name="cacheService">The cache service.</param> public DeviceDataProvider(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService, ICachePolicy cacheService) : base(configService, errorService, logService) { this.CacheService = cacheService; this.cacheScope = this.GetType().ToString(); // Create new scope where to save the entities from this provider this.CacheService.CreateScope(this.cacheScope); }
/// <summary> /// Initializes a new instance of the <see cref="ApiErrorPolicy"/> class. /// </summary> /// <param name="logService">The log service.</param> public ApiErrorPolicy(ILogPolicy logService) { this.LogService = logService; }
/// <summary> /// Initializes a new instance of the <see cref="DeviceRepository" /> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> /// <param name="sqlQueryProvider">The SQL query provider.</param> /// <param name="cacheQueryProvider">The cache query provider.</param> public DeviceRepository(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService, SqlQProvider.IDeviceQueryDataProvider sqlQueryProvider, CacheQProvider.IDeviceQueryDataProvider cacheQueryProvider) : base(configService, errorService, logService) { this.SqlQueryProvider = sqlQueryProvider; this.CacheQueryProvider = cacheQueryProvider; }
/// <summary> /// Initializes a new instance of the <see cref="SiliconCacheProvider"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> public SiliconCacheProvider(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService) { this.ConfigService = configService; this.ErrorService = errorService; this.LogService = logService; }
/// <summary> /// Initializes a new instance of the <see cref="EventHandler{T}"/> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> public EventHandler(ILogPolicy logService, IErrorPolicy errorService) { this.LogService = logService; this.ErrorService = errorService; }
/// <summary> /// Initializes a new instance of the <see cref="CommonController" /> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> public CommonController(IConfiguration configService, ILogPolicy logService, IErrorPolicy errorService) { this.ConfigService = configService; this.LogService = logService; this.ErrorService = errorService; }
/// <summary> /// Initializes a new instance of the <see cref="CommandEventHandler" /> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> public CommandEventHandler(ILogPolicy logService, IErrorPolicy errorService, ICommandService commandService) : this(logService, errorService) { this.CommandService = commandService; }
/// <summary> /// Initializes a new instance of the <see cref="SiliconIoTHubProvider"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> /// <exception cref="IoTException"></exception> public SiliconIoTHubProvider(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService) { this.ConfigService = configService; this.ErrorService = errorService; this.LogService = logService; //set connection string if (!string.IsNullOrWhiteSpace(ConfigService[IOTHUB_CONNECTION_KEY])) { this.ConnectionString = ConfigService[IOTHUB_CONNECTION_KEY]; } else { throw new IoTException(ErrorMessages.DataProvider_ConnectionStringKeyMissing, ErrorReasonTypeEnum.Configuration); } this.ProvisioningAttempts = this.ConfigService.GetValue <int>(PROVITIONING_ATTEPTS, defaultProvisioningAttempts); }
/// <summary> /// Initializes a new instance of the <see cref="SiliconRepository"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> public SiliconRepository(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService) { this.ConfigService = configService; this.ErrorService = errorService; this.LogService = logService; }
public static void SetLogPolicy(ILogPolicy policy) { current = policy; }
/// <summary> /// Initializes a new instance of the <see cref="ProvisionDeviceCommandHandler" /> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> /// <param name="eventBus">The event bus.</param> /// <param name="deviceRepository">The device repository.</param> public SubmitReceivedCommandHandler(ILogPolicy logService, IErrorPolicy errorService, IEventBus eventBus) : base(logService, errorService, eventBus) { }
static LogPolicy() { current = new QuietLogPolicy(); }
/// <summary> /// Initializes a new instance of the <see cref="DeviceRepository"/> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> /// <param name="deviceIdentityProvider">The device identity provider.</param> /// <param name="sqlCommandProvider">The device provider.</param> public DeviceRepository(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService, IoTCHubProvider.IDeviceCommandDataProvider deviceIdentityProvider, SqlCProvider.IDeviceCommandDataProvider sqlCommandProvider, CacheCProvider.IDeviceCommandDataProvider cacheCommandProvider, CacheQProvider.IDeviceQueryDataProvider cacheQueryProvider) : base(configService, errorService, logService) { this.IoTDeviceProvider = deviceIdentityProvider; this.SqlDeviceProvider = sqlCommandProvider; this.CacheCommandProvider = cacheCommandProvider; this.CacheQueryProvider = cacheQueryProvider; }
/// <summary> /// Initializes a new instance of the <see cref="IoTHubEventHandler" /> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> public IoTHubEventHandler(ILogPolicy logService, IErrorPolicy errorService) : base(logService, errorService) { }
/// <summary> /// Initializes a new instance of the <see cref="DeviceDataProvider" /> class. /// </summary> /// <param name="configService">The configuration service.</param> /// <param name="errorService">The error service.</param> /// <param name="logService">The log service.</param> public DeviceDataProvider(IConfiguration configService, IErrorPolicy errorService, ILogPolicy logService) : base(configService, errorService, logService) { }
/// <summary> /// Initializes a new instance of the <see cref="ProvisionDeviceCommandHandler" /> class. /// </summary> /// <param name="logService">The log service.</param> /// <param name="errorService">The error service.</param> /// <param name="eventBus">The event bus.</param> /// <param name="deviceRepository">The device repository.</param> public ProvisionDeviceCommandHandler(ILogPolicy logService, IErrorPolicy errorService, IEventBus eventBus, IDeviceRepository deviceRepository) : base(logService, errorService, eventBus) { this.DeviceRepository = deviceRepository; }