Exemple #1
0
        private void EnsureReferenceInitialized(bool refresh)
        {
            EnsureScopeInitialized();

            if (!elementScope.IsScopeResolved)
            {
                return;
            }
            if (referenceInitialized && !refresh)
            {
                return;
            }

            if (reference != null)
            {
                reference.Dispose();
            }

            reference = lookup.CreateReference(elementScope.ScopePath, referenceAttribute.TargetType, (string)base.GetValue());
            reference.ElementFound   += ReferenceElementFound;
            reference.ElementDeleted += ReferenceElementDeleted;
            reference.NameChanged    += ReferenceNameChanged;

            referenceInitialized = true;
        }
Exemple #2
0
        public void then_reference_can_be_fixed_by_loading_section()
        {
            ElementLookup elementLookup = Container.Resolve<ElementLookup>();
            var reference = elementLookup.CreateReference("/configuration/" + ExceptionHandlingSettings.SectionName);

            var sourceModel = Container.Resolve<ConfigurationSourceModel>();
            sourceModel.AddSection(ExceptionHandlingSettings.SectionName, base.Section);

            Assert.IsNotNull(reference.Element);
        }
Exemple #3
0
        public void then_element_reference_signals_name_change()
        {
            var anyHandler = ehabModel.DescendentElements().Where(x => typeof(ExceptionHandlerData).IsAssignableFrom(x.ConfigurationType)).First();
            ElementReference reference = lookup.CreateReference(anyHandler.Path);

            string newName = string.Empty;
            reference.NameChanged += (sender, args) =>
                {
                    newName = args.Value;
                };

            anyHandler.Property("Name").Value = "new name";

            Assert.IsFalse(string.IsNullOrEmpty(newName));
            Assert.IsTrue(newName.Equals("new name"));
        }
Exemple #4
0
        public void then_reference_signals_event_if_reference_is_fixed()
        {
            bool elementFoundSignalled = false;

            ElementLookup elementLookup = Container.Resolve<ElementLookup>();
            var reference = elementLookup.CreateReference("/configuration/" + ExceptionHandlingSettings.SectionName);

            reference.ElementFound += (s, a) => elementFoundSignalled = true;

            var sourceModel = Container.Resolve<ConfigurationSourceModel>();
            sourceModel.AddSection(ExceptionHandlingSettings.SectionName, base.Section);

            Assert.IsTrue(elementFoundSignalled);
        }
Exemple #5
0
        private void InitializeElementReference(string elementPath)
        {
            elementViewModelReference = lookup.CreateReference(elementPath);

            elementViewModelReference.ElementDeleted += ElementViewModelReferenceElementDeleted;
            elementViewModelReference.PathChanged    += ElementViewModelReferencePathChanged;

            if (elementViewModelReference.Element != null)
            {
                this.elementViewModel = elementViewModelReference.Element;
            }
            else
            {
                elementViewModelReference.ElementFound += ElementViewModelReferenceElementFound;
            }
        }
        public void then_has_no_element_if_reference_cannot_be_found()
        {
            ElementReference reference = lookup.CreateReference("/path/to/unknown/element");

            Assert.IsNull(reference.Element);
        }
        public void then_has_no_element_if_reference_cannot_be_found()
        {
            ElementReference reference = lookup.CreateReference("/path/to/unknown/collection", typeof(ConfigurationElement), "element");

            Assert.IsNull(reference.Element);
        }