Example #1
0
 public BundleService(IApplicationContext context, IAssemblyLoaderService assemblyLoaderService, IObjectBuilder builder)
 {
     _bundlePath            = context.BundlePath;
     _context               = context;
     _assemblyLoaderService = assemblyLoaderService;
     _builder               = builder;
 }
 public ExtensionBuilder(IAssemblyLoaderService assemblyLoader
                         , IBundleService bundleService
                         , IExtensionRegistry registry
                         , IObjectBuilder objectBuilderService)
 {
     _assemblyLoaderService = assemblyLoader;
     _bundleService         = bundleService;
     _registry             = registry;
     _objectBuilderService = objectBuilderService;
 }
 public ExtensionRegistry(IBundleService bundleService
                          , IAssemblyLoaderService assemblyLoaderService
                          , IObjectBuilder builderService
                          , IApplicationContext context)
 {
     _bundleService    = bundleService;
     _context          = context;
     _extensionBuilder =
         new ExtensionBuilder(assemblyLoaderService, bundleService, this, builderService);
     _serializable                  = new Serializable();
     _serializable.Registry         = this;
     _serializable.ExtensionBuilder = _extensionBuilder;
 }
        private static XmlSchema[] GetContributedXmlSchemas(IEnumerable <IExtension> xmlSchemaExtensions, IBundleService bundleService, IAssemblyLoaderService assemblyLoader)
        {
            List <XmlSchema> contributedSchemas = new List <XmlSchema>();

            foreach (IExtension ext in xmlSchemaExtensions)
            {
                IBundle bundle;
                if (!bundleService.TryGetBundleForExtension(ext.Id, out bundle))
                {
                    throw new PlatformConfigurationException(
                              string.Format(CultureInfo.InvariantCulture, "不能为扩展 '{0}' 获取 Bundle .跳过它.", ext.Id));
                }
                Assembly assembly;
                if (assemblyLoader.TryGetLoadedAssembly(
                        Utils.GetAssemblySimpleNameFromLocation(bundle.AssemblyLocation), out assembly))
                {
                    if (ext.HasImplementation)
                    {
                        XmlSchema schema = XmlUtils.GetSchema(assembly, ext.Implementation);
                        contributedSchemas.Add(schema);
                    }
                }
                else
                {
                    if (assemblyLoader.TryLoadAssembly(
                            Utils.GetAssemblyFileNameFromLocation(bundle.AssemblyLocation), out assembly))
                    {
                        if (ext.HasImplementation)
                        {
                            XmlSchema schema = XmlUtils.GetSchema(assembly, ext.Implementation);
                            contributedSchemas.Add(schema);
                        }
                    }
                    else
                    {
                        throw new PlatformConfigurationException(
                                  string.Format("不能载入程序集 '{0}' 中的 XML Schema 扩展 '{1}'. 跳过它.", bundle.AssemblyLocation, ext.Id));
                    }
                }
            }

            return(contributedSchemas.ToArray());
        }
        internal static XmlSchema CreateFromContributions(IExtensionRegistry registry, IBundleService bundleService, IAssemblyLoaderService assemblyLoader)
        {
            IExtension[] extensions = registry.GetExtensions(Constants.Points.XmlSchemas);

            XmlSchema extensionSchema = new XmlSchema();

            XmlSchema[] contributedSchemas = GetContributedXmlSchemas(extensions, bundleService, assemblyLoader);

            for (int i = 0; i < contributedSchemas.Length; i++)
            {
                CopyAllItemTypes(contributedSchemas[i], extensionSchema.Items);
            }

            extensionSchema.AttributeFormDefault = XmlSchemaForm.Unqualified;
            extensionSchema.ElementFormDefault   = XmlSchemaForm.Qualified;
            extensionSchema.Version = typeof(ExtensionXmlSchema).Assembly.GetName().Version.ToString();
            extensionSchema.Namespaces.Add(string.Empty, RuntimeConstants.CurrentXmlSchemaNamespace);
            extensionSchema.TargetNamespace = RuntimeConstants.CurrentXmlSchemaNamespace;

            return(extensionSchema);
        }
Example #6
0
 public void Init()
 {
     _LoggerFactory = new LoggerFactory();
     _LoaderService = new AssemblyLoaderService(_LoggerFactory);
 }