Exemplo n.º 1
0
        private static IProductElement GetChildElement(IProductElement context, string name)
        {
            // locate a child instance that is a collection or element, and has a Any-To-One cardinality
            var element = context.GetChildren()
                          .FirstOrDefault(c => c.DefinitionName.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (element != null)
            {
                var abstractElement = element as IAbstractElement;
                if (abstractElement != null && abstractElement.Info != null)
                {
                    if (abstractElement.Info.Cardinality.IsAnyToOne())
                    {
                        return(element);
                    }
                }
            }

            return(null);
        }