コード例 #1
0
        public SaveStatus ConfigureClientWith(Uri resource, PasswordParameters password = null)
        {
            logger.Info($"Attempting to configure local client with '{resource}'...");

            try
            {
                TryLoadData(resource, out var data);

                using (data)
                {
                    TryParseData(data, out var encryption, out var format, out var rawData, password);

                    certificateStore.ExtractAndImportIdentities(rawData);
                    encryption = DetermineEncryptionForClientConfiguration(rawData, encryption);

                    var status = TrySerializeData(rawData, format, out var serialized, encryption);

                    using (serialized)
                    {
                        if (status == SaveStatus.Success)
                        {
                            status = TrySaveData(new Uri(dataValues.GetAppDataFilePath()), serialized);
                        }

                        return(status);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error($"Unexpected error while trying to configure local client with '{resource}'!", e);

                return(SaveStatus.UnexpectedError);
            }
        }