Example #1
0
        public void EmptyInterfaceWithAdditionalAttributes()
        {
            var attributeBuilder = new CustomAttributeBuilder(
                typeof(ComponentAttribute).GetConstructor(Type.EmptyTypes),
                new object[0]);

            var di = _classEmitter.EmitInterfaceInstance <IEmpty>(_dth, null, null, new[] { attributeBuilder });

            Assert.IsNotNull(di);
            Assert.IsTrue(ComponentContextUtils.HasComponentAttribute(di.GetType()));
        }
Example #2
0
        public void Initialize(IComposer composer)
        {
            if (_composer != null)
            {
                return;
            }

            if (_targetType == null)
            {
                throw new InvalidOperationException("TargetType is not specified.");
            }

            if (!composer.Configuration.DisableAttributeChecking && !ComponentContextUtils.HasComponentAttribute(_targetType))
            {
                throw new CompositionException("The type '" + _targetType +
                                               "' is not a component, but it is being registered as one. Only classes marked with [Component] attribute can be registered.");
            }

            _composer = composer;
            CompleteConfiguration();
        }