コード例 #1
0
 public HostBundleMetadataNode(IResolver resolver, Interface1 metadata) : base(resolver, metadata)
 {
     this._referencableProxy = new Referencable();
     AssertUtility.ArgumentNotNull(resolver, "resolver");
     this.FragmentNodes = new List <IFragmentBundleMetadataNode>();
     BundleUtility.BuildFragments(this);
 }
コード例 #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 T Find <T>(Func <ServiceManager.InterfaceHolder, bool> comparer, Func <ServiceManager.InterfaceHolder> creator, Func <ServiceManager.FindServiceResult, T> func)
            {
                T result;

                using (DictionaryLocker <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> dictionaryLocker = CreateLocker())
                {
                    foreach (KeyValuePair <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> current in dictionaryLocker)
                    {
                        if (comparer(current.Key) && func != null)
                        {
                            result = func(new ServiceManager.FindServiceResult(base.Container, current.Key));
                            return(result);
                        }
                    }
                    if (creator != null)
                    {
                        AssertUtility.ArgumentNotNull(creator, "creator");
                        ServiceManager.InterfaceHolder key = creator();
                        dictionaryLocker[key] = new ServiceManager.ServiceInstancesHolder();
                        if (func != null)
                        {
                            result = func(new ServiceManager.FindServiceResult(base.Container, key));
                            return(result);
                        }
                    }
                    result = default(T);
                }
                return(result);
            }
コード例 #4
0
 public ObjectCreator(IBundle owner, string classType, Func <string, T> creator)
 {
     AssertUtility.ArgumentNotNull(classType, "classType");
     AssertUtility.ArgumentNotNull(creator, "creator");
     Class   = classType;
     Creator = creator;
     Owner   = owner;
 }
コード例 #5
0
 public ServiceTracker(IBundleContext context, bool throwsExceptionIfServiceNotFound)
 {
     AssertUtility.ArgumentNotNull(context, "BundleContext");
     BundleContext           = context;
     _defaultOrFirstService  = context.GetFirstOrDefaultService <TServiceInterface>();
     _serviceInstances       = context.GetService <TServiceInterface>();
     context.ServiceChanged += new EventHandler <ServiceEventArgs>(ServiceChanged);
 }
コード例 #6
0
 public DisposableLocker(object syncRoot, int millisecondsTimeout)
 {
     AssertUtility.ArgumentNotNull(syncRoot, "syncRoot");
     this._syncRoot            = syncRoot;
     this._millisecondsTimeout = millisecondsTimeout;
     this._lockAcquired        = Monitor.TryEnter(this._syncRoot, this._millisecondsTimeout);
     this.LogWhenAcquireLockFailed();
 }
コード例 #7
0
 public ExtensionManager(Framework framework)
 {
     AssertUtility.ArgumentNotNull(framework, "framework");
     this._framework      = framework;
     this.ExtensionPoints = new List <ExtensionPoint>();
     this.Extensions      = new Dictionary <string, List <Extension> >();
     framework.EventManager.AddBundleEventListener(new EventHandler <BundleStateChangedEventArgs>(this.BundleEventHandler), true);
 }
コード例 #8
0
ファイル: BundleUrlHelper.cs プロジェクト: daywrite/OBear
 public static string Content(IBundle bundle, string url)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     AssertUtility.ArgumentHasText(url, "url");
     while (url.StartsWith("~") || url.StartsWith("/") || url.StartsWith("\\"))
     {
         url = url.Remove(0, 1);
     }
     return(Path.Combine(bundle.Location.Replace(WebRootPath, "~\\"), url).Replace("\\", "/"));
 }
コード例 #9
0
 public List <IAssemblyMetadataNode> AttachFragment(IFragmentBundleMetadataNode fragment)
 {
     AssertUtility.ArgumentNotNull(fragment, "fragement");
     if (!this.FragmentNodes.Contains(fragment))
     {
         fragment.HostNode = this;
         base.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(fragment.SharedAssemblyNodes);
         base.ConstraintResolver.ResolvedAssemblyMetadataNodes.AddRange(fragment.PrivateAssemblyNodes);
         this.FragmentNodes.Add(fragment);
         this.SortByBundleID <IFragmentBundleMetadataNode>(this.FragmentNodes, true);
     }
     return(null);
 }
コード例 #10
0
 public BundleContext(AbstractBundle bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "BundleContext.bundle");
     Bundle    = bundle;
     Framework = bundle.Framework;
     AssertUtility.ArgumentNotNull(Framework, "Framework");
     ExtensionManager = GetFirstOrDefaultService <IExtensionManager>();
     AssertUtility.ArgumentNotNull(ExtensionManager, "ExtensionManager");
     ExtensionManager.ExtensionChanged      += new EventHandler <ExtensionEventArgs>(OnExtensionChanged);
     ExtensionManager.ExtensionPointChanged += new EventHandler <ExtensionPointEventArgs>(OnExtensionPointChanged);
     Framework.EventManager.AddFrameworkEventListener(new EventHandler <FrameworkEventArgs>(OnFrameworkStateChanged));
     Framework.EventManager.AddBundleEventListener(new EventHandler <BundleStateChangedEventArgs>(OnBundleStateChanged), false);
     Framework.EventManager.AddBundleEventListener(new EventHandler <BundleStateChangedEventArgs>(OnSyncBundleStateChanged), true);
     Framework.EventManager.AddServiceEventListener(new EventHandler <ServiceEventArgs>(OnServiceChanged));
     Framework.EventManager.AddBundleLazyActivatedEventListener(new EventHandler <BundleLazyActivatedEventArgs>(OnBundleLazyActivated));
 }
コード例 #11
0
 private T Find <T>(Func <ServiceManager.InterfaceHolder, bool> comparer, Func <ServiceManager.InterfaceHolder> creator, Func <ServiceManager.FindServiceResult, T> func)
 {
     using (DictionaryLocker <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> locker = this.CreateLocker())
     {
         foreach (KeyValuePair <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> pair in locker)
         {
             if (comparer(pair.Key) && (func != null))
             {
                 return(func(new ServiceManager.FindServiceResult(base.Container, pair.Key)));
             }
         }
         if (creator != null)
         {
             AssertUtility.ArgumentNotNull(creator, "creator");
             ServiceManager.InterfaceHolder key = creator();
             locker[key] = new ServiceManager.ServiceInstancesHolder();
             if (func != null)
             {
                 return(func(new ServiceManager.FindServiceResult(base.Container, key)));
             }
         }
         return(default(T));
     }
 }
コード例 #12
0
 public void RecordBundleRemovalPending(IBundleMetadata bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     this._changes.Add(new BundleDelta(bundle, BundleDeltaType.RemovalPending));
 }
コード例 #13
0
 public ExtensionHooker(IExtensionManager extensionManager)
 {
     AssertUtility.ArgumentNotNull(extensionManager, "extensionManager");
     _extensionManager = extensionManager;
     _extensionManager.ExtensionChanged += _extensionManager_ExtensionChanged;
 }
コード例 #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 RemoveCommand(ICommandAdaptor cmd)
 {
     AssertUtility.ArgumentNotNull(cmd, "cmd");
     this.Commands.Commands.Remove(cmd);
 }
コード例 #16
0
 public void AddCommand(ICommandAdaptor cmd)
 {
     AssertUtility.ArgumentNotNull(cmd, "cmd");
     this.Commands.Commands.Add(cmd);
 }
コード例 #17
0
 public ShellLayoutViewProxy(Control owner, Action <object, object> showSmartPart)
 {
     AssertUtility.ArgumentNotNull(owner, "owner");
     _owner         = owner;
     _showSmartPart = showSmartPart;
 }
コード例 #18
0
 public BundlePersistentData(IBundle bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     State = bundle.State;
 }
コード例 #19
0
        public ServiceManager(IFramework framework)
        {
            AssertUtility.ArgumentNotNull(framework, "framework");

            //  framework.EventManager.AddBundleEventListener(new EventHandler<BundleStateChangedEventArgs>(  BundleEventListener), true);
        }
コード例 #20
0
 public void RecordBundleUnresolved(IBundleMetadata bundle)
 {
     AssertUtility.ArgumentNotNull(bundle, "bundle");
     this._changes.Add(new BundleDelta(bundle, BundleDeltaType.Unresolved));
 }
コード例 #21
0
 public ObjectCreator(IBundle owner, T instance)
 {
     AssertUtility.ArgumentNotNull(instance, "defaultValue");
     _serviceInstance = instance;
     Owner            = owner;
 }
コード例 #22
0
ファイル: ExtensionPoint.cs プロジェクト: yshulin/OSGi
 internal ExtensionPoint(IExtensionManager extensionManager)
 {
     AssertUtility.ArgumentNotNull(extensionManager, "extensionManager");
     _extensionManager = extensionManager;
 }