public IBundle InstallBundle(string location, Stream stream) { IBundle bundle = Framework.Bundles.GetBundle(location); if (bundle == null) { BundleData bundleData = Framework.ServiceContainer.GetFirstOrDefaultService <IBundleInstallerService>().CreateBundleData(location, stream); if (bundleData == null) { Framework.EventManager.DispatchFrameworkEvent(this, new FrameworkEventArgs(FrameworkEventType.Error, new Exception($"Install bundle in '{location}' failed."))); return(null); } Tuple <IBundle, IBundleMetadata> tuple = Framework.AddBundleData(bundleData); bundle = tuple.Item1; IBundleMetadata metadata = tuple.Item2; if (string.IsNullOrEmpty(bundleData.HostBundleSymbolicName)) { Interface1 host = metadata as Interface1; AssertUtility.IsTrue(host != null); List <IFragmentBundleMetadata> metadatas = BundleUtility.GetMetadatas <IFragmentBundleMetadata>(Framework.FrameworkAdaptor.State.Bundles); BundleUtility.BindFragmentMetadatas(host, metadatas); } else { IFragmentBundleMetadata metadata2 = metadata as IFragmentBundleMetadata; AssertUtility.IsTrue(metadata2 != null); BundleUtility.GetMetadatas <Interface1>(Framework.FrameworkAdaptor.State.Bundles); } Framework.ServiceContainer.GetFirstOrDefaultService <IBundlePersistent>().SaveInstallLocation(location); } return(bundle); }
public void Initialize() { State = new Dependency.Impl.State(); State.MetadataBuilder = new MetadataBuilder(_framework); var firstOrDefaultService = _framework.ServiceContainer.GetFirstOrDefaultService <IBundleInstallerService>(); var stopwatch = new Stopwatch(); try { stopwatch.Start(); if (!firstOrDefaultService.InstallBundles()) { throw new Exception(Messages.LoadBundlesFailed); } } finally { stopwatch.Stop(); FileLogUtility.Verbose(string.Format(Messages.InstallBundlesTimeCounter, stopwatch.ElapsedMilliseconds)); } UpdateService.Update(new List <BundleData>(firstOrDefaultService.BundleDatas.Values), firstOrDefaultService.UpdateFolder); LicenseService.EnsureHasAvailableBundleLicense(); var metadataBuilder = State.MetadataBuilder; CreateSystemBundle(); foreach (KeyValuePair <string, BundleData> pair in firstOrDefaultService.BundleDatas) { _framework.AddBundleData(pair.Value); } }