Exemple #1
0
        /// <summary>
        /// Called when [saved].
        /// </summary>
        /// <param name="model">The model.</param>
        public void OnSaved(SourceDescriptorEdit model)
        {
            Model = model;

            if (Model.DataProviders.Any())
            {
                SetDataProvider(Model.DataProviders[0]);
                SelectDataProvider(Model.DataProviders[0]);
            }
            else
            {
                DataProviderViewModel = null;
                SelectedDataProvider = null;
            }

            SourceFieldsViewModel.OnSaved(Model.ProviderFields);
        }
Exemple #2
0
        /// <summary>
        /// Initializes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parentWindow">The parent window.</param>
        public void Initialize(SourceDescriptorEdit model, ITopLevelWindow parentWindow)
        {
            Model = model;
            ParentWindow = parentWindow;

            if (Model.DataProviders.Any())
            {
                SetDataProvider(Model.DataProviders[0]);
                SelectDataProvider(Model.DataProviders[0]);
            }
            else
            {
                var dataProvider = DataProviders.FirstOrDefault(dp => dp.Metadata.ProviderName == SqlDataProviderEdit.CN_SQL_DATA_PROVIDER)
                                   ?? DataProviders.FirstOrDefault();

                if (dataProvider != null)
                {
                    var newModel = DataProviderFactory.NewProvider(dataProvider.Metadata.ProviderName);

                    Model.DataProviders.Add(newModel);

                    SetDataProvider(newModel);
                    SelectDataProvider(Model.DataProviders.First());
                }
            }

            SourceFieldsViewModel.Initialize(Model.ProviderFields, ParentWindow);
        }