示例#1
0
        public void VisitElement(XElement element, IContainer container, IInitializationContext context)
        {
            var nameAttribute = element
                                .Attributes(NameAttributeName)
                                .Select(attr => attr.Value)
                                .FirstOrDefault();

            if (nameAttribute == null)
            {
                throw new ConfirurationFileFormatException("Alias element must have name attribute");
            }

            if (!element.HasElements || element.Elements().Count() > 1)
            {
                throw new ConfirurationFileFormatException("Alias element must have one child attribute");
            }

            var expression =
                context.Builder.BuildObjectBuildingExpressionTree(element.Elements().First(), context);

            context.AddAlias(nameAttribute, expression);
        }