Пример #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);
        }
Пример #2
0
 public BundleDelta(IBundleMetadata bundleMetadata, BundleDeltaType deltaType)
 {
     AssertUtility.ArgumentNotNull(bundleMetadata, "bundleMetadata");
     AssertUtility.EnumDefined(typeof(BundleDeltaType), deltaType, "deltaType");
     this.Bundle = bundleMetadata;
     this.Type   = deltaType;
 }
Пример #3
0
 private void OnRemovalPending(IBundleMetadata metadata)
 {
     this.Changes.RecordBundleRemovalPending(metadata);
     if (this.BundleRemovalPending != null)
     {
         this.BundleRemovalPending(this, new BundleMetadataEventArgs(metadata));
     }
 }
Пример #4
0
 private void OnRemovedBundle(IBundleMetadata bundleDescription)
 {
     this.Changes.RecordBundleRemoved(bundleDescription);
     if (this.BundleRemoved != null)
     {
         this.BundleRemoved(this, new BundleMetadataEventArgs(bundleDescription));
     }
 }
Пример #5
0
        internal Tuple <IBundle, IBundleMetadata> AddBundleData(BundleData bundleData)
        {
            this.FrameworkAdaptor.InstalledBundles.Add(bundleData);
            IBundle item = this.ServiceContainer.GetFirstOrDefaultService <IBundleFactory>().CreateBundle(bundleData);

            this.Bundles.Add(item);
            IBundleMetadata bundle = this.FrameworkAdaptor.State.MetadataBuilder.BuildBundleMetadata(bundleData, item.BundleID);

            this.FrameworkAdaptor.State.AddBundle(bundle);
            return(TupleUtility.CreateTuple <IBundle, IBundleMetadata>(item, bundle));
        }
Пример #6
0
        private void LogAssembliesFailedToLoaded(IBundleMetadata unresolvedNode)
        {
            Action <IAssemblyMetadata> action = null;

            if (unresolvedNode.AssembliesFailedToLoad.Count > 0)
            {
                if (action == null)
                {
                    action = node => FileLogUtility.Error(string.Format(Messages.BundleLocalAssemblyResolvedFailed, unresolvedNode.SymbolicName, unresolvedNode.Version, node.Path));
                }
                unresolvedNode.AssembliesFailedToLoad.ForEach(action);
            }
        }
Пример #7
0
        private void MarkAsResolvable(Interface2 bundle)
        {
            IBundleMetadata unresolvedNode = bundle.Metadata as IBundleMetadata;
            bool            resovable      = (unresolvedNode != null) && (unresolvedNode.AssembliesFailedToLoad.Count == 0);

            if (!resovable)
            {
                this.LogAssembliesFailedToLoaded(unresolvedNode);
            }
            bundle.IsResolvable = resovable;
            bundle.DependentAssemblyNodes.ForEach((Action <IDependentAssemblyConstraintNode>)(dependent => (dependent.IsResolvable = resovable)));
            bundle.DependentBundleNodes.ForEach((Action <IDependentBundleConstraintNode>)(dependent => (dependent.IsResolvable = resovable)));
        }
Пример #8
0
 public void RemoveBundle(IBundleMetadata bundleMetadata)
 {
     if (bundleMetadata != null)
     {
         IHostBundleMetadataNode node = this.Resolver.ResolvedNodes.Find(node => node.Metadata == bundleMetadata) as IHostBundleMetadataNode;
         if ((node != null) && node.IsReferenced())
         {
             this.Changes.RecordBundleRemovalPending(bundleMetadata);
             this.OnRemovalPending(bundleMetadata);
         }
         else
         {
             this.Bundles.Remove(bundleMetadata);
             this.OnRemovedBundle(bundleMetadata);
         }
     }
 }
Пример #9
0
        public bool Resolve()
        {
            if (!this.IsResolved && this.IsResolvable)
            {
                IDependentAssemblyConstraintNode node2 = this.DependentAssemblyNodes.Find(a => !a.Resolve());
                if (node2 != null)
                {
                    FileLogUtility.Error(string.Format(Messages.BundleDependentAssemblyNotResolved, new object[] { node2.Owner.SymbolicName, node2.Owner.Version, node2.AssemblyName, node2.AssemblyVersion, node2.BundleSymbolicName, node2.BundleVersion }));
                    this.IsResolvable = false;
                    this.IsResolved   = false;
                    return(this.IsResolvable);
                }
                IDependentBundleConstraintNode node = this.DependentBundleNodes.Find(a => !a.Resolve());
                if (node != null)
                {
                    this.IsResolvable = false;
                    this.IsResolved   = false;
                    FileLogUtility.Error(string.Format(Messages.BundleDependentBundleNotResolved, new object[] { node.Owner.SymbolicName, node.Owner.Version, node.BundleSymbolicName, node.BundleVersion }));
                }
                else
                {
                    this.IsResolved = true;
                    this.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(this.SharedAssemblyNodes);
                    this.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(this.PrivateAssemblyNodes);
                }
                return(this.IsResolvable);
            }
            Action <IAssemblyMetadata> action         = null;
            IBundleMetadata            bundleMetadata = base.Metadata as IBundleMetadata;

            if (bundleMetadata.AssembliesFailedToLoad.Count > 0)
            {
                if (action == null)
                {
                    action = delegate(IAssemblyMetadata node) {
                        FileLogUtility.Error(string.Format(Messages.BundleLocalAssemblyResolvedFailed, bundleMetadata.SymbolicName, bundleMetadata.Version, node.Path));
                    };
                }
                bundleMetadata.AssembliesFailedToLoad.ForEach(action);
            }
            return(this.IsResolved);
        }
Пример #10
0
        public BundleMetadataNode(IResolver resolver, IBundleMetadata metadata) : base(metadata)
        {
            Action <IAssemblyMetadata>            action  = null;
            Action <IAssemblyMetadata>            action2 = null;
            Action <IDependentBundleConstraint>   action3 = null;
            Action <IDependentAssemblyConstraint> action4 = null;

            this.ConstraintResolver     = resolver;
            this.BundleID               = metadata.BundleID;
            this.SymbolicName           = metadata.SymbolicName;
            this.DependentAssemblyNodes = new List <IDependentAssemblyConstraintNode>(metadata.DependentAssemblies.Count);
            this.DependentBundleNodes   = new List <IDependentBundleConstraintNode>(metadata.DependentBundles.Count);
            this.SharedAssemblyNodes    = new List <IAssemblyMetadataNode>(metadata.SharedAssemblies.Count);
            this.PrivateAssemblyNodes   = new List <IAssemblyMetadataNode>(metadata.PrivateAssemblies.Count);
            action = item => this.SharedAssemblyNodes.Add(new AssemblyMetadataNode(item, this));
            metadata.SharedAssemblies.ForEach(action);
            action2 = item => this.PrivateAssemblyNodes.Add(new AssemblyMetadataNode(item, this));
            metadata.PrivateAssemblies.ForEach(action2);
            action3 = item => this.DependentBundleNodes.Add(new DependentBundleConstraintNode(resolver, this, item));
            metadata.DependentBundles.ForEach(action3);
            action4 = item => this.DependentAssemblyNodes.Add(new DependentAssemblyConstraintNode(resolver, this, item));
            metadata.DependentAssemblies.ForEach(action4);
        }
Пример #11
0
 public BundleMetadataEventArgs(IBundleMetadata bundle)
 {
     this._bundle = bundle;
 }
Пример #12
0
        private List <IAssemblyMetadata> BuildAssemblyPathConstraintMetadata(AssemblyData assemblyData, IBundleMetadata bundleMetadata)
        {
            List <IAssemblyMetadata> list = new List <IAssemblyMetadata>(assemblyData.PathArray.Length);

            foreach (string str in assemblyData.PathArray)
            {
                AssemblyMetadata item = new AssemblyMetadata {
                    Path             = str,
                    Owner            = bundleMetadata,
                    MultipleVersions = assemblyData.MultipleVersions
                };
                list.Add(item);
            }
            return(list);
        }
Пример #13
0
 private IDependentBundleConstraint BuildDependencyConstraintMetadata(DependencyData requireBundleData, IBundleMetadata bundleMetadata) =>
 new DependentBundleConstraint
 {
     BundleSymbolicName = requireBundleData.BundleSymbolicName,
     BundleVersion      = requireBundleData.BundleVersion,
     Owner = bundleMetadata
 };
Пример #14
0
        public IBundleMetadata BuildBundleMetadata(BundleData bundleData, long bundleID)
        {
            AssertUtility.ArgumentNotNull(bundleData, "bundleData");
            IBundleMetadata bundleMetadata = null;

            if (!string.IsNullOrEmpty(bundleData.HostBundleSymbolicName))
            {
                FragmentBundleMetadata metadata = new FragmentBundleMetadata();
                bundleMetadata = metadata;
                HostConstraint constraint = new HostConstraint {
                    BundleSymbolicName = bundleData.HostBundleSymbolicName,
                    BundleVersion      = bundleData.HostBundleVersion
                };
                metadata.HostConstraint = constraint;
            }
            else
            {
                bundleMetadata = new HostBundleMetadata();
            }
            bundleMetadata.BundleID     = bundleID;
            bundleMetadata.SymbolicName = bundleData.SymbolicName;
            if (bundleData.Version != null)
            {
                bundleMetadata.Version = bundleData.Version;
            }
            else
            {
                bundleMetadata.Version = FrameworkConstants.DEFAULT_VERSION;
            }
            bundleMetadata.Location = bundleData.Path;
            bundleData.Runtime.Assemblies.ForEach(delegate(AssemblyData assemblyData) {
                List <IAssemblyMetadata> assemblyMetadata = this.BuildAssemblyPathConstraintMetadata(assemblyData, bundleMetadata);
                this.ResolveAndValidateAssembly(bundleData.Path, assemblyMetadata);
                if (assemblyData.Share)
                {
                    bundleMetadata.SharedAssemblies.AddRange(assemblyMetadata);
                }
                else
                {
                    bundleMetadata.PrivateAssemblies.AddRange(assemblyMetadata);
                }
            });
            bundleData.Runtime.Dependencies.ForEach(delegate(DependencyData a) {
                if (!string.IsNullOrEmpty(a.AssemblyName))
                {
                    DependentAssemblyConstraint item = new DependentAssemblyConstraint {
                        AssemblyName       = a.AssemblyName,
                        BundleSymbolicName = a.BundleSymbolicName,
                        AssemblyVersion    = a.AssemblyVersion,
                        BundleVersion      = a.BundleVersion,
                        Owner      = bundleMetadata,
                        Resolution = a.Resolution
                    };
                    bundleMetadata.DependentAssemblies.Add(item);
                }
                else
                {
                    bundleMetadata.DependentBundles.Add(this.BuildDependencyConstraintMetadata(a, bundleMetadata));
                }
            });
            return(bundleMetadata);
        }
Пример #15
0
 public void RecordBundleRemovalPending(IBundleMetadata bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     this._changes.Add(new BundleDelta(bundle, BundleDeltaType.RemovalPending));
 }
Пример #16
0
 public void RecordBundleUnresolved(IBundleMetadata bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     this._changes.Add(new BundleDelta(bundle, BundleDeltaType.Unresolved));
 }
Пример #17
0
 public void AddBundle(IBundleMetadata bundle)
 {
     this.Bundles.Add(bundle);
     this.OnAddedBundle(bundle);
 }
Пример #18
0
 public void ResolveBundle(IBundleMetadata bundleMetadata, bool isResolved, Tuple <IHostConstraint, Interface1>[] resolvedHosts, Tuple <IDependentBundleConstraint, Interface1>[] resolvedDependentBundles, Tuple <IDependentAssemblyConstraint, IAssemblyMetadata> resolvedDependentAssemblies)
 {
 }