Ejemplo n.º 1
0
        private void AddOrUpdateDefinition(List <ItemDefinition> definitions, DefinitionElement element)
        {
            ItemDefinition definition = definitions.Find(d => d.Discriminator == element.Name);

            if (definition == null)
            {
                Type itemType = EnsureType <ContentItem>(element.Type);

                definition = staticDefinitions.GetOrCreateDefinition(itemType);
                definition.Discriminator = element.Name;
                definitions.Add(definition);
            }
            else
            {
                Type changedType = Type.GetType(element.Type);
                if (changedType != null && changedType != definition.ItemType)
                {
                    definition.ItemType = changedType;
                    definition.Clear();
                    definition.Initialize(definition.ItemType);
                }
            }

            definition.IsDefined = true;
            UpdateDefinitionFromConfiguration(element, definition);
        }