Beispiel #1
0
        public IEnumerable <TemplateDefinition> GetTemplates(Type contentType)
        {
            yield return(CreateTemplate(map.GetOrCreateDefinition(contentType)));

            foreach (var ta in N2.Web.PathDictionary.GetFinders(contentType).OfType <N2.Web.TemplateAttribute>().Where(ta => ta.SelectableAsDefault))
            {
                string templateKey = ta.Action;
                var    definition  = map.GetOrCreateDefinition(contentType, templateKey);
                var    template    = CreateTemplate(definition);
                template.OriginalFactory = () => null;
                template.TemplateFactory = () => activator.CreateInstance(contentType, null, templateKey);
                template.Title           = ta.TemplateTitle ?? definition.Title;
                template.Description     = ta.TemplateDescription ?? definition.Description;
                template.Name            = templateKey;
                yield return(template);
            }
        }
Beispiel #2
0
        protected List <ItemDefinition> FindDefinitions()
        {
            List <ItemDefinition> definitions = new List <ItemDefinition>();

            foreach (Type itemType in FindConcreteTypes())
            {
                var definition = staticDefinitions.GetOrCreateDefinition(itemType);
                definition.DefaultContainerName = config.Definitions.DefaultContainerName;
                if (config.Definitions.DefineUnattributedTypes)
                {
                    definition.IsDefined = true;
                }
                definitions.Add(definition);
            }

            foreach (DefinitionElement element in config.Definitions.RemovedElements)
            {
                ItemDefinition definition = definitions.Find(d => d.Discriminator == element.Name);
                if (definition == null)
                {
                    throw new ConfigurationErrorsException("The configuration element /n2/engine/definitions/remove references a definition '" + element.Name + "' that couldn't be found in the application. Either remove the <remove/> configuration or ensure that the corresponding content class exists.");
                }

                definitions.Remove(definition);
            }

            foreach (DefinitionElement element in config.Definitions.AllElements)
            {
                if (element.Name == "*")
                {
                    UpdateMatchingDefinitions(definitions, element);
                }
                else
                {
                    AddOrUpdateDefinition(definitions, element);
                }
            }

            definitions.Sort();
            return(definitions);
        }
		public void TestFixtureSetUp()
		{
			factory = new InterceptingProxyFactory();
			var map = new DefinitionMap();
			factory.Initialize(new[] { typeof(InterceptableItem), typeof(InterceptableInheritorItem), typeof(IgnoringItem) }.Select(t => map.GetOrCreateDefinition(t)));
		}
Beispiel #4
0
 public IEnumerable <TemplateDefinition> GetTemplates(Type contentType)
 {
     yield return(CreateTemplate(map.GetOrCreateDefinition(contentType)));
 }