Exemplo n.º 1
0
        public void EnumSetter()
        {
            var          graph  = new PluginGraph();
            PluginFamily family = graph.FindFamily(typeof(IGridColumn));

            family.AddPlugin(typeof(EnumGridColumn));

            family.AddInstance(_source.GetMemento("Enum"));

            var manager = new Container(graph);

            var column = (EnumGridColumn)manager.GetInstance <IGridColumn>("Enum");

            Assert.AreEqual(FontStyleEnum.BodyText, column.FontStyle);
        }
        public void GetTemplatedMementoFromNodeNormalizedTemplate()
        {
            InstanceMemento templateMemento = _nodeTemplateSource.GetMemento("Grandmother");

            Assert.IsNotNull(templateMemento);
            InstanceMemento combinedMemento = templateMemento.Substitute(_referringMemento);

            validateCombinedMemento(combinedMemento);
        }
        public void SetUp()
        {
            DataMother.WriteDocument(FILE_NAME);

            _nodeTemplateSource = new XmlFileMementoSource(FILE_NAME, "NodeTemplates", "Parent");
            _attTemplateSource = new XmlAttributeFileMementoSource(FILE_NAME, "AttTemplates", "Parent");
            _source = new XmlAttributeFileMementoSource(FILE_NAME, "Parents", "Parent");

            _referringMemento = _source.GetMemento("Jackie");

            _templatedSource = new TemplatedMementoSource(_source, _attTemplateSource);
        }
Exemplo n.º 4
0
        public void GetComplex1()
        {
            InstanceMemento memento = source.GetMemento("Complex1");

            Assert.IsNotNull(memento);


            Assert.AreEqual("Complex1", memento.InstanceKey, "InstanceKey");
            Assert.AreEqual("Complex", memento.ConcreteKey, "ConcreteTypeKey");
            Assert.AreEqual("Red", memento.GetProperty("String"), "String");
            Assert.AreEqual("Green", memento.GetProperty("String2"), "String2");
            Assert.AreEqual("1", memento.GetProperty("Int"), "Int");
            Assert.AreEqual("2", memento.GetProperty("Long"), "Long");
            Assert.AreEqual("3", memento.GetProperty("Byte"), "Byte");
            Assert.AreEqual("4.5", memento.GetProperty("Double"), "Double");
            Assert.AreEqual("true", memento.GetProperty("Bool"), "Bool");
        }
Exemplo n.º 5
0
        private InstanceMemento resolveMemento(InstanceMemento rawMemento)
        {
            InstanceMemento returnValue = null;

            string templateName = rawMemento.TemplateName;
            if (templateName == string.Empty)
            {
                returnValue = rawMemento;
            }
            else
            {
                InstanceMemento templateMemento = _templateSource.GetMemento(templateName);

                if (templateMemento == null)
                {
                    throw new StructureMapException(250, templateName);
                }

                returnValue = templateMemento.Substitute(rawMemento);
            }

            return returnValue;
        }
Exemplo n.º 6
0
        protected override InstanceMemento retrieveMemento(string instanceKey)
        {
            InstanceMemento rawMemento = _innerSource.GetMemento(instanceKey);

            return resolveMemento(rawMemento);
        }