public void Providers_scanning_ignored_for_system_assemblies(Type type)
        {
            Assembly asm = type.GetTypeInfo().Assembly;

            Assert.False(SharedRuntimeOptionsAttribute.GetSharedRuntimeOptions(asm).Providers);
            Assert.False(SharedRuntimeOptionsAttribute.GetSharedRuntimeOptions(asm).Templates);
            Assert.False(SharedRuntimeOptionsAttribute.GetSharedRuntimeOptions(asm).Adapters);
        }
        public void Adapters_scanning_for_this_assembly_enabled()
        {
            Assembly shared = typeof(Adaptable).GetTypeInfo().Assembly;

            Assert.True(SharedRuntimeOptionsAttribute.GetSharedRuntimeOptions(shared).Adapters);

            Assembly self = GetType().GetTypeInfo().Assembly;

            Assert.True(SharedRuntimeOptionsAttribute.GetSharedRuntimeOptions(self).Adapters);
        }
Example #3
0
        private AssemblyInfo(Assembly a)
        {
            _assembly = a;

            var sc = (SharedRuntimeOptionsAttribute)Attribute.GetCustomAttribute(_assembly, typeof(SharedRuntimeOptionsAttribute));

            _options  = sc ?? SharedRuntimeOptionsAttribute.Default;
            Scannable = Utility.IsScannableAssembly(a);

            if (Scannable)
            {
                _resolver = new AssemblyInfoXmlNamespaceResolver(this);
            }
            else
            {
                _resolver = AssemblyInfoXmlNamespaceResolver.Null;
            }

            _metadata = new Lazy <IProperties>(() => {
                var props       = new Properties();
                var globalScope = Carbonfrost.Commons.Core.XmlNamespaceResolver.Global;

                // We provide "share" by convention, and using our own resolver this should also help
                // avoid probing the full app
                var services = ServiceProvider.FromValue(new XmlNamespaceResolver(new [] { globalScope })
                {
                    { "share", Xmlns.ShareableCodeMetadata2011 },
                });
                foreach (AssemblyMetadataAttribute am in Attribute.GetCustomAttributes(_assembly, typeof(AssemblyMetadataAttribute)))
                {
                    if (string.IsNullOrEmpty(am.Key))
                    {
                        continue;
                    }
                    if (QualifiedName.TryParse(am.Key, services, out QualifiedName qn))
                    {
                        props.Add(qn.ToString(), am.Value);
                    }
                }
                return(Properties.ReadOnly(props));
            });
        }