XElement ToProviderElement(TypeDefinition type, string name) { var attr = ContentProviderAttribute.FromTypeDefinition(type); if (attr == null) { return(null); } IEnumerable <MetaDataAttribute> metadata = MetaDataAttribute.FromCustomAttributeProvider(type); IEnumerable <GrantUriPermissionAttribute> grants = GrantUriPermissionAttribute.FromTypeDefinition(type); IEnumerable <IntentFilterAttribute> intents = IntentFilterAttribute.FromTypeDefinition(type); XElement element = attr.ToElement(PackageName); if (element.Attribute(attName) == null) { element.Add(new XAttribute(attName, name)); } element.Add(metadata.Select(md => md.ToElement(PackageName))); element.Add(grants.Select(intent => intent.ToElement(PackageName))); element.Add(intents.Select(intent => intent.ToElement(PackageName))); return(element); }
XElement ToElement <TAttribute> (TypeDefinition type, string name, Func <TypeDefinition, TAttribute> parser, Func <TAttribute, XElement> toElement, Action <TAttribute, XElement> update) where TAttribute : class { TAttribute attr = parser(type); if (attr == null) { return(null); } IEnumerable <MetaDataAttribute> metadata = MetaDataAttribute.FromCustomAttributeProvider(type); IEnumerable <IntentFilterAttribute> intents = IntentFilterAttribute.FromTypeDefinition(type); XElement element = toElement(attr); if (element.Attribute(attName) == null) { element.Add(new XAttribute(attName, name)); } element.Add(metadata.Select(md => md.ToElement(PackageName))); element.Add(intents.Select(intent => intent.ToElement(PackageName))); if (update != null) { update(attr, element); } return(element); }
static IEnumerable <string> ExtractSchemes(IntentFilterAttribute a) { if (a.DataSchemes != null) { // If DataSchemes is defined, it will be used // instead of DataScheme (the singular version) foreach (var ds in a.DataSchemes) { yield return(ds); } } else if (!string.IsNullOrWhiteSpace(a.DataScheme)) { // When DataScheme (singular version) is used. yield return(a.DataScheme !); } }
private bool IsActionDefaultBrowsable(IntentFilterAttribute ifa) { return(ifa.Actions.Contains(Intent.ActionView) && ifa.Categories.Contains(Intent.CategoryDefault) && ifa.Categories.Contains(Intent.CategoryBrowsable)); }
private bool HasSchemeHostAndPrefix(IntentFilterAttribute ifa) { return(ifa.DataScheme != null && ifa.DataHost != null && ifa.DataPathPrefix != null); }