Ejemplo n.º 1
0
 /// <summary>
 /// Show a message for approval and return result.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="silent"></param>
 /// <returns>True if approved, false otherwise.</returns>
 private async Task <bool> ApproveMessage(string message, bool silent)
 {
     if (!silent && MessageDlg != null)
     {
         MessageDlg.Message(message, true);
         return(await MessageDlg.ShowAsync().ConfigureAwait(false));
     }
     else
     {
         Utils.LogError(message);
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Show a message for approval and return result.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="silent"></param>
 /// <returns>True if approved, false otherwise.</returns>
 private static async Task <bool> ApproveMessage(string message, bool silent)
 {
     if (!silent && MessageDlg != null)
     {
         MessageDlg.Message(message, true);
         return(await MessageDlg.ShowAsync());
     }
     else
     {
         Utils.Trace(message);
         return(false);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the configuration.
        /// </summary>
        public async Task <ApplicationConfiguration> LoadAppConfig(
            bool silent,
            Stream stream,
            ApplicationType applicationType,
            Type configurationType,
            bool applyTraceSettings,
            ICertificatePasswordProvider certificatePasswordProvider = null)
        {
            Utils.LogInfo("Loading application from stream.");

            try
            {
                // load the configuration file.
                ApplicationConfiguration configuration = await ApplicationConfiguration.Load(
                    stream,
                    applicationType,
                    configurationType,
                    applyTraceSettings,
                    certificatePasswordProvider)
                                                         .ConfigureAwait(false);

                if (configuration == null)
                {
                    return(null);
                }

                return(configuration);
            }
            catch (Exception e)
            {
                Utils.LogError(e, "Could not load configuration from stream.");

                // warn user.
                if (!silent)
                {
                    if (MessageDlg != null)
                    {
                        MessageDlg.Message("Load Application Configuration: " + e.Message);
                        await MessageDlg.ShowAsync().ConfigureAwait(false);
                    }

                    throw;
                }

                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads the configuration.
        /// </summary>
        public static async Task <ApplicationConfiguration> LoadAppConfig(
            bool silent,
            string filePath,
            ApplicationType applicationType,
            Type configurationType,
            bool applyTraceSettings,
            ICertificatePasswordProvider certificatePasswordProvider = null)
        {
            Utils.Trace(Utils.TraceMasks.Information, "Loading application configuration file. {0}", filePath);

            try
            {
                // load the configuration file.
                ApplicationConfiguration configuration = await ApplicationConfiguration.Load(
                    new System.IO.FileInfo(filePath),
                    applicationType,
                    configurationType,
                    applyTraceSettings,
                    certificatePasswordProvider)
                                                         .ConfigureAwait(false);

                if (configuration == null)
                {
                    return(null);
                }

                return(configuration);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Could not load configuration file. {0}", filePath);

                // warn user.
                if (!silent)
                {
                    if (MessageDlg != null)
                    {
                        MessageDlg.Message("Load Application Configuration: " + e.Message);
                        await MessageDlg.ShowAsync().ConfigureAwait(false);
                    }

                    throw;
                }

                return(null);
            }
        }