Exemplo n.º 1
0
        public CustomEventAbstract(XElement xElement)
        {
            Name             = xElement.Attribute("Name")?.Value;
            BindingParameter = xElement.Descendants()
                               .Single(a => a.Name.LocalName == "Parameter" && a.Attribute("Name").Value == "bindingParameter")
                               .Attribute("Type")?.Value;

            // Recognize Edm types and transform as necessary.
            var proposedType = xElement.Descendants().SingleOrDefault(a => a.Name.LocalName == "ReturnType")?.Attribute("Type")?.Value;

            if (!string.IsNullOrWhiteSpace(proposedType))
            {
                if (proposedType.StartsWith("Collection("))
                {
                    ReturnsCollection = true;
                    proposedType      = proposedType.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
                }

                ReturnType = TypeMapper.MapType(proposedType);
            }
            else
            {
                ReturnType = "";
            }

            if (!string.IsNullOrWhiteSpace(BindingParameter) && BindingParameter.StartsWith("Collection("))
            {
                IsCollectionAction = true;
                BindingParameter   = BindingParameter.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            NameSpace =
                xElement.Ancestors().First(a => a.Attribute("Namespace") != null)?.Attribute("Namespace")?.Value;
        }
        public CustomEventAbstract(XElement xElement)
        {
            Name             = xElement.Attribute("Name")?.Value;
            BindingParameter = xElement.Descendants()?
                               .SingleOrDefault(a => a.Name.LocalName == "Parameter" && a.Attribute("Name")?.Value == "bindingParameter")?
                               .Attribute("Type")?.Value;

            ReturnType = xElement.Descendants().SingleOrDefault(a => a.Name.LocalName == "ReturnType")?.Attribute("Type")?.Value;

            if (!string.IsNullOrWhiteSpace(ReturnType) && ReturnType.StartsWith("Collection("))
            {
                ReturnsCollection = true;
                ReturnType        = ReturnType.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            if (!string.IsNullOrWhiteSpace(BindingParameter) && BindingParameter.StartsWith("Collection("))
            {
                IsCollectionAction = true;
                BindingParameter   = BindingParameter.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            NameSpace =
                xElement.Ancestors().First(a => a.Attribute("Namespace") != null)?.Attribute("Namespace")?.Value;
        }