예제 #1
0
        public void Create()
        {
            if (!this.View.DoValidate())
            {
                return;
            }

            try
            {
                this.View.RenderError("");
                this.storage.Data       = EncryptedStorageData.CreateDefaultContent();
                this.storage.Parameters = this.View.Collect();
                this.storage.Save();
                this.SaveAndClose();
            }
            catch (Exception ex)
            {
                this.View.RenderError(ex.Message);
                this.Logger.Debug(ex, "Failed to create a storage.");
            }
        }
예제 #2
0
        private static void InitializeRelations(EncryptedStorageData data)
        {
            var connectionsByName    = data.Connections.ToDictionary(c => c.Name);
            var sharedSettingsByName = data.SharedSettings.ToDictionary(cs => cs.Name);

            foreach (var connectionInfo in data.Connections)
            {
                // Parent
                var parentName = connectionInfo.ParentName;
                if (parentName != null)
                {
                    var parentConnectionInfo = connectionsByName.GetValueOrDefault(parentName);
                    if (parentConnectionInfo != null)
                    {
                        connectionInfo.Parent = parentConnectionInfo;
                    }
                    else
                    {
                        connectionInfo.ParentName = null;
                    }
                }

                // SharedSettings
                var sharedSettingsName = connectionInfo.SharedSettingsName;
                if (sharedSettingsName != null)
                {
                    var sharedSettings = sharedSettingsByName.GetValueOrDefault(sharedSettingsName);
                    if (sharedSettings != null)
                    {
                        connectionInfo.SharedSettings = sharedSettings;
                    }
                    else
                    {
                        connectionInfo.SharedSettingsName = null;
                    }
                }
            }
        }