Example #1
0
        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);
        }
Example #2
0
        private void State_BundleRemoved(object sender, BundleMetadataEventArgs e)
        {
            Predicate <Interface2> match      = null;
            Predicate <Interface2> predicate2 = null;
            Predicate <Interface2> predicate3 = null;
            Interface1             host       = e.Metadata as Interface1;

            if (host != null)
            {
                if (host.IsResolved)
                {
                    if (match == null)
                    {
                        match = a => a.Metadata == host;
                    }
                    Interface2 interface3 = this.ResolvedNodes.Find(match);
                    if (interface3 != null)
                    {
                        interface3.Unresolve();
                    }
                    if (predicate2 == null)
                    {
                        predicate2 = a => a.Metadata == e.Metadata;
                    }
                    this.ResolvedNodes.RemoveAll(predicate2);
                }
                else
                {
                    if (predicate3 == null)
                    {
                        predicate3 = a => a.Metadata == e.Metadata;
                    }
                    this.UnResolverNodes.RemoveAll(predicate3);
                }
            }
            else
            {
                Predicate <Interface2>  predicate4 = null;
                IFragmentBundleMetadata framgent   = e.Metadata as IFragmentBundleMetadata;
                if (this.ResolvedNodes.Find(a => framgent.HostConstraint.DependentMetadata == a.Metadata) == null)
                {
                    if (predicate4 == null)
                    {
                        predicate4 = a => framgent.HostConstraint.DependentMetadata == a.Metadata;
                    }
                    Interface2 interface2 = this.UnResolverNodes.Find(predicate4);
                }
            }
        }
 public FragmentBundleMetadataNode(IResolver resolver, IFragmentBundleMetadata metadata) : base(resolver, metadata)
 {
     this.HostConstraintNode = new UIShell.OSGi.Dependency.Resolver.Impl.HostConstraintNode(resolver, this, metadata.HostConstraint);
 }