Beispiel #1
0
        public void ShouldNotTryToResolveAbstractDefinitionsToType()
        {
            GenericObjectDefinition definition = new GenericObjectDefinition();

            definition.ObjectTypeName = "~/Default.aspx";
            definition.IsAbstract     = true;
            Assert.That(ConfigurationClassObjectDefinitionReader.CheckConfigurationClassCandidate(definition), Is.False);
        }
        private void ProcessConfigObjectDefinitions(IObjectDefinitionRegistry registry)
        {
            Collections.Generic.ISet <ObjectDefinitionHolder> configCandidates = new HashedSet <ObjectDefinitionHolder>();
            foreach (string objectName in registry.GetObjectDefinitionNames())
            {
                IObjectDefinition objectDef = registry.GetObjectDefinition(objectName);
                if (ConfigurationClassObjectDefinitionReader.CheckConfigurationClassCandidate(objectDef))
                {
                    configCandidates.Add(new ObjectDefinitionHolder(objectDef, objectName));
                }
            }

            //if nothing to process, bail out
            if (configCandidates.Count == 0)
            {
                return;
            }

            ConfigurationClassParser parser = new ConfigurationClassParser(_problemReporter);

            foreach (ObjectDefinitionHolder holder in configCandidates)
            {
                IObjectDefinition bd = holder.ObjectDefinition;
                try
                {
                    if (bd is AbstractObjectDefinition && ((AbstractObjectDefinition)bd).HasObjectType)
                    {
                        parser.Parse(((AbstractObjectDefinition)bd).ObjectType, holder.ObjectName);
                    }
                    else
                    {
                        //parser.Parse(bd.ObjectTypeName, holder.ObjectName);
                    }
                }
                catch (ObjectDefinitionParsingException ex)
                {
                    throw new ObjectDefinitionStoreException("Failed to load object class: " + bd.ObjectTypeName, ex);
                }
            }
            parser.Validate();

            // Read the model and create Object definitions based on its content
            ConfigurationClassObjectDefinitionReader reader = new ConfigurationClassObjectDefinitionReader(registry, _problemReporter);

            reader.LoadObjectDefinitions(parser.ConfigurationClasses);
        }