public void Can_Assign_NonDefault_DefinitionReader()
        {
            var attrib = new ImportResourceAttribute("the resource");
            attrib.DefinitionReader = typeof(AbstractObjectDefinitionReader);

            Assert.That(attrib.DefinitionReader, Is.EqualTo(typeof(AbstractObjectDefinitionReader)));
        }
        public void Can_Assign_NonDefault_DefinitionReader()
        {
            var attrib = new ImportResourceAttribute("the resource");

            attrib.DefinitionReader = typeof(AbstractObjectDefinitionReader);

            Assert.That(attrib.DefinitionReader, Is.EqualTo(typeof(AbstractObjectDefinitionReader)));
        }
        public void DefinitionReader_Can_Prevent_Improper_Types()
        {
            ImportResourceAttribute attrib = new ImportResourceAttribute("the resource");

            try
            {
                attrib.DefinitionReader = typeof(Object);// <--need to pass *anything* ensured *not* to implement IObjectDefinitionReader
                Assert.Fail("Expected Exception of type ArgumentException not thrown!");
            }
            catch (ArgumentException)
            {
                //swallow the expected exception
            }
        }
        public void DefinitionReader_Can_Prevent_Improper_Types()
        {
            ImportResourceAttribute attrib = new ImportResourceAttribute("the resource");

            try
            {
                attrib.DefinitionReader = typeof(Object);// <--need to pass *anything* ensured *not* to implement IObjectDefinitionReader
                Assert.Fail("Expected Exception of type ArgumentException not thrown!");
            }
            catch (ArgumentException)
            {
                //swallow the expected exception
            }
        }
        private void DoProcessConfigurationClass(ConfigurationClass configurationClass)
        {
            Attribute[] importAttributes = Attribute.GetCustomAttributes(configurationClass.ConfigurationClassType, typeof(ImportAttribute));

            if (importAttributes.Length > 0)
            {
                foreach (Attribute importAttribute in importAttributes)
                {
                    ImportAttribute attrib = importAttribute as ImportAttribute;

                    if (null != attrib)
                    {
                        ProcessImport(configurationClass, attrib.Types);
                    }
                }
            }

            Attribute[] importResourceAttributes = Attribute.GetCustomAttributes(configurationClass.ConfigurationClassType, typeof(ImportResourceAttribute));

            if (importResourceAttributes.Length > 0)
            {
                foreach (Attribute importResourceAttribute in importResourceAttributes)
                {
                    ImportResourceAttribute attrib = importResourceAttribute as ImportResourceAttribute;

                    if (null != attrib)
                    {
                        foreach (string resource in attrib.Resources)
                        {
                            configurationClass.AddImportedResource(resource, attrib.DefinitionReader);
                        }
                    }
                }
            }

            Collections.Generic.ISet <MethodInfo> definitionMethods = GetAllMethodsWithCustomAttributeForClass(configurationClass.ConfigurationClassType, typeof(ObjectDefAttribute));
            foreach (MethodInfo definitionMethod in definitionMethods)
            {
                configurationClass.Methods.Add(new ConfigurationClassMethod(definitionMethod, configurationClass));
            }
        }
        public void Uses_XmlObjectDefinitionReader_By_Default()
        {
            var attrib = new ImportResourceAttribute("the resource");

            Assert.That(attrib.DefinitionReader, Is.EqualTo(typeof(XmlObjectDefinitionReader)));
        }
        public void Uses_XmlObjectDefinitionReader_By_Default()
        {
            var attrib = new ImportResourceAttribute("the resource");

            Assert.That(attrib.DefinitionReader, Is.EqualTo(typeof(XmlObjectDefinitionReader)));
        }