/// <summary>
        /// Uses the ExtensionPoint type to scan the plugins folder for extensions.
        /// </summary>
        /// <returns>
        /// An enumerable collection that contains information on each extension that will help the loader
        /// load them into the AppDomain. If no extensions are found, null is returned.</returns>
        public ShredStartupInfoList ScanExtensions()
        {
            Platform.Log(LogLevel.Debug, this.GetType().ToString() + ":" + this.GetType().Name + " in AppDomain [" + AppDomain.CurrentDomain.FriendlyName + "]");

            var shredInfoList = new ShredStartupInfoList();
			var xp = new ShredExtensionPoint();
            var shredObjects = xp.CreateExtensions();
            foreach (var shredObject in shredObjects)
            {
				var shredType = shredObject.GetType();
            	var asShred = shredObject as IShred;
				if (asShred == null)
				{
					Platform.Log(LogLevel.Debug, "Shred extension '{0}' does not implement IShred.", shredType.FullName);
					continue;
				}

            	var shredIsolation = shredType.GetCustomAttributes(typeof (ShredIsolationAttribute), true).OfType<ShredIsolationAttribute>().FirstOrDefault();
            	var shredIsolationLevel = shredIsolation == null ? ShredIsolationLevel.OwnAppDomain : shredIsolation.Level;

				var assemblyPath = new Uri(shredType.Assembly.CodeBase);
				var startupInfo = new ShredStartupInfo(assemblyPath, ((IShred)shredObject).GetDisplayName(), shredType.FullName, shredIsolationLevel);
                shredInfoList.Add(startupInfo);
            }

            return shredInfoList;
        }
Example #2
0
        /// <summary>
        /// Uses the ExtensionPoint type to scan the plugins folder for extensions.
        /// </summary>
        /// <returns>
        /// An enumerable collection that contains information on each extension that will help the loader
        /// load them into the AppDomain. If no extensions are found, null is returned.</returns>
        public ShredStartupInfoList ScanExtensions()
        {
            Platform.Log(LogLevel.Debug, this.GetType().ToString() + ":" + this.GetType().Name + " in AppDomain [" + AppDomain.CurrentDomain.FriendlyName + "]");

            ShredStartupInfoList shredInfoList = new ShredStartupInfoList();
            ShredExtensionPoint xp = new ShredExtensionPoint();
            object[] shredObjects = xp.CreateExtensions();
            foreach (object shredObject in shredObjects)
            {
                if (shredObject is IShred)
                {
                    Uri assemblyPath = new Uri(shredObject.GetType().Assembly.CodeBase);
                    shredInfoList.Add(new ShredStartupInfo(assemblyPath, (shredObject as IShred).GetDisplayName(), shredObject.GetType().FullName));
                }
            }

            return shredInfoList;
        }
Example #3
0
        private static void StartShreds(ShredStartupInfoList shredStartupInfoList)
        {
            if (null != shredStartupInfoList)
            {
                // create the data structure that will hold the shreds and their thread, etc. related objects
                foreach (ShredStartupInfo shredStartupInfo in shredStartupInfoList)
                {
                    if (null != shredStartupInfo)
                    {
                        // clone the shredStartupInfo structure into the current AppDomain, otherwise, once the StagingDomain 
                        // has been unloaded, the shredStartupInfo structure will be destroyed
                        ShredStartupInfo newShredStartupInfo = new ShredStartupInfo(shredStartupInfo.AssemblyPath, shredStartupInfo.ShredName, shredStartupInfo.ShredTypeName);
                        
                        // create the controller that will allow us to start and stop the shred
                        ShredController shredController = new ShredController(newShredStartupInfo);
                        _shredInfoList.Add(shredController);
                    }

                }
            }

            foreach (ShredController shredController in _shredInfoList)
            {
                shredController.Start();
            }
        }