Esempio n. 1
0
        protected override void Arrange()
        {
            base.Arrange();

            backingStoreProperty       = (ElementReferenceProperty)CacheManager.Property("CacheStorage");
            backingStoreProperty.Value = "backing store";
        }
        protected override void Arrange()
        {
            base.Arrange();

            elementReferencesChanged = false;
            CachingViewModel.ElementReferencesChanged += (sender, args) => elementReferencesChanged = true;

            defaultCacheManagerProperty = (ElementReferenceProperty)CachingViewModel.Property("DefaultCacheManager");
            defaultCacheManagerProperty.Initialize(null);
        }
        protected override void Arrange()
        {
            base.Arrange();
            defaultCacheManagerProperty = (ElementReferenceProperty)CachingViewModel.Property("DefaultCacheManager");
            defaultCacheManagerProperty.Initialize(null);

            cacheManager = CachingViewModel.GetDescendentsOfType <CacheManagerData>().First();

            defaultCacheManagerPropertyChangedListener = new PropertyChangedListener(defaultCacheManagerProperty);
        }
        private static string GetMissingReferenceMessage(ElementReferenceProperty referenceProperty)
        {
            if (referenceProperty.ContainingScopeElement != null)
            {
                return(string.Format(
                           CultureInfo.CurrentCulture,
                           Properties.Resources.ValidationElementReferenceMissingWithScope,
                           referenceProperty.ContainingScopeElement.Name));
            }

            return(Properties.Resources.ValidationElementReferenceMissing);
        }
Esempio n. 5
0
        protected override void Arrange()
        {
            base.Arrange();

            var sourceModel = Container.Resolve <ConfigurationSourceModel>();

            LoggingViewModel = sourceModel.AddSection(LoggingSettings.SectionName, LoggingSection);

            elementReferencesChanged = false;
            LoggingViewModel.ElementReferencesChanged += (sender, args) => elementReferencesChanged = true;

            defaultCacheManagerProperty = (ElementReferenceProperty)LoggingViewModel.Property("DefaultCategory");
            defaultCacheManagerProperty.Initialize(null);
        }
        protected override void Arrange()
        {
            base.Arrange();

            var sourceModel = Container.Resolve <ConfigurationSourceModel>();

            LoggingViewModel = sourceModel.AddSection(LoggingSettings.SectionName, LoggingSection);

            defaultCategoryProperty = (ElementReferenceProperty)LoggingViewModel.Property("DefaultCategory");
            defaultCategoryProperty.Initialize(null);

            traceSource = LoggingViewModel.GetDescendentsOfType <TraceSourceData>().First();

            defaultCacheManagerPropertyChangedListener = new PropertyChangedListener(defaultCategoryProperty);
        }
        protected override void Arrange()
        {
            base.Arrange();

            ConfigurationSourceModel sourceModel = Container.Resolve <ConfigurationSourceModel>();
            var section = sourceModel.AddSection(ConfigurationSourceSection.SectionName, new ConfigurationSourceSection()
            {
                Sources = { { new FileConfigurationSourceElement("file1", "file1") },
                            { new FileConfigurationSourceElement("file2", "file1") },
                            { new SystemConfigurationSourceElement("system") } },
                RedirectedSections = {   { new RedirectedSectionElement()
                                           {
                                               Name = "redirect"
                                           } } }
            });


            sourceProperty = (ElementReferenceProperty)section.GetDescendentsOfType <RedirectedSectionElement>().First().Property("SourceName");
        }
        public void then_properties_with_suggested_values_offer_standard_values()
        {
            var exceptionType    = model.GetDescendentsOfType <ExceptionTypeData>().First();
            var typeNameProperty = new ElementReferenceProperty(Container.Resolve <IServiceProvider>(),
                                                                Container.Resolve <ElementLookup>(),
                                                                exceptionType,
                                                                TypeDescriptor.GetProperties(typeof(ExceptionTypeData)).OfType <PropertyDescriptor>().Where(x => x.Name == "Name").First(),
                                                                new Attribute[] { new ReferenceAttribute(typeof(ExceptionHandlingSettings), typeof(ExceptionTypeData)) });

            typeNameProperty.Initialize(new InitializeContext());


            Assert.IsTrue(typeNameProperty.BindableProperty is SuggestedValuesBindableProperty);
            Assert.IsTrue(typeNameProperty.BindableProperty is PropertyDescriptor);
            PropertyDescriptor propertyDescriptor = (PropertyDescriptor)typeNameProperty.BindableProperty;
            TypeConverter      propertyDescriptorTypeConverter = propertyDescriptor.Converter;

            Assert.IsTrue(propertyDescriptorTypeConverter.GetStandardValuesSupported());
            Assert.IsFalse(propertyDescriptorTypeConverter.GetStandardValuesExclusive());
        }
        protected override void InnerExecute(object parameter)
        {
            var configurationSourceSection = configurationSource.Sections.OfType <ConfigurationSourceSectionViewModel>().FirstOrDefault();

            if (configurationSourceSection != null)
            {
                ElementReferenceProperty selectedSourceProperty = (ElementReferenceProperty)configurationSourceSection.Property("SelectedSource");

                if (typeof(SystemConfigurationSourceElement) != selectedSourceProperty.ReferencedElement.ConfigurationType)
                {
                    UIService.ShowMessageWpf(DesignResources.ExportingEnvironemntConfigurationUsingNonSystemSource, DesignResources.ExportMergedEnvironmentTitle, MessageBoxButton.OK);
                    return;
                }
            }
            if (application.IsDirty)
            {
                var saveDialogResult = UIService.ShowMessageWpf(
                    DesignResources.ExportMergedUnsavedMainConfigurationMessage,
                    DesignResources.ExportMergedConfigurationTitle,
                    System.Windows.MessageBoxButton.OKCancel);

                if (saveDialogResult == System.Windows.MessageBoxResult.Cancel)
                {
                    return;
                }
                if (!application.Save())
                {
                    return;
                }
            }

            string mergedConfigurationFile = (string)overridesViewModel.Property("EnvironmentConfigurationFile").Value;

            if (string.IsNullOrEmpty(mergedConfigurationFile))
            {
                SaveFileDialog saveEnvrionmentDialog = new SaveFileDialog()
                {
                    Title       = DesignResources.ExportMergedConfigurationTitle,
                    DefaultExt  = "*.config",
                    Filter      = Resources.SaveConfigurationFileDialogFilter,
                    FilterIndex = 0
                };

                var saveFileResults = UIService.ShowFileDialog(saveEnvrionmentDialog);
                if (saveFileResults.DialogResult != true)
                {
                    return;
                }
                mergedConfigurationFile = saveFileResults.FileName;
            }
            else
            {
                if (File.Exists(mergedConfigurationFile))
                {
                    var confirmationResult = UIService.ShowMessageWpf(
                        string.Format(CultureInfo.CurrentCulture, DesignResources.SaveOverwriteMergedFile, mergedConfigurationFile),
                        DesignResources.ExportMergedConfigurationTitle, MessageBoxButton.YesNo);

                    if (confirmationResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }
            }

            if (!Path.IsPathRooted(mergedConfigurationFile))
            {
                string configurationFileDirectory = Path.GetDirectoryName(application.ConfigurationFilePath);
                mergedConfigurationFile = Path.Combine(configurationFileDirectory, mergedConfigurationFile);
            }

            ConfigurationMerger mergeComponent = new ConfigurationMerger(application.ConfigurationFilePath, (EnvironmentalOverridesSection)overridesViewModel.ConfigurationElement);

            mergeComponent.MergeConfiguration(mergedConfigurationFile);

            overridesViewModel.Property("EnvironmentConfigurationFile").Value = mergedConfigurationFile;
        }