Exemplo n.º 1
0
        /// <summary>
        /// Creates an observable reporting deployment errors ongoingly (reactive to changes in the device).
        /// </summary>
        /// <param name="self"></param>
        /// <param name="model">Deployment Model</param>
        /// <returns></returns>
        public static IObservable <DeploymentModelError[]> VerifyObservable(this Hub self, DeploymentModel model)
        {
            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            return(self.Protocol.UpstreamMessages.Select(msg => model.Verify(self.Protocol))); // stay with protocol messages in general. Future constraint may listen to e.g. property changes.
        }
Exemplo n.º 2
0
    /// <summary>
    /// Verifies the deployment model and waits till it reaches zero deployment errors.
    /// </summary>
    /// <param name="self"></param>
    /// <param name="configure">Builder infrastructure for the deployment model</param>
    /// <returns></returns>
    public static async Task VerifyDeploymentModelAsync(this Hub self, DeploymentModel model)
    {
        var awaitable = self.VerifyObservable(model)
                        .Do(LogErrors(self))
                        .Where(x => x.Length == 0)
                        .FirstAsync()
                        .GetAwaiter();

        var firstErors = model.Verify(self.Protocol);

        if (firstErors.Length > 0)
        {
            LogErrors(self)(firstErors);

            await awaitable;
        }
    }