Exemple #1
0
        /*
         * static Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args) {
         * string asmName = args.Name.Split(',')[0];
         * var root = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
         * string adapterPath = root + "\\Adapters\\";
         *
         * foreach( var dir in Directory.GetDirectories(adapterPath) ) {
         *  var fn = Path.Combine(dir, asmName + ".dll");
         *  if( File.Exists(fn) && AssemblyName.GetAssemblyName(fn).FullName == args.Name )
         *    return Assembly.LoadFrom(fn);
         * }
         *
         * return null;
         * }
         */

        internal static IServiceBusDiscovery CreateDiscovery(string name, string version, string transportation)
        {
            try {
                foreach (var asm in AsmCache.Assemblies)
                {
                    var type = asm.Types.SingleOrDefault(t =>
                                                         t.ServiceBusName == name &&
                                                         t.ServiceBusVersion == version &&
                                                         t.MessageQueueType == transportation &&
                                                         t.Interfaces.Any(i => i.EndsWith("IServiceBusDiscovery")));

                    if (type != null)
                    {
                        return((IServiceBusDiscovery)Activator.CreateInstance(asm.AssemblyName, type.TypeName).Unwrap());
                    }
                }
            } catch (TypeLoadException) {
                AsmCache.Rescan();

                CreateDiscovery(name, version, transportation);
            }


            throw new NoMessageBusManagerFound(name, transportation);
        }
Exemple #2
0
        internal static string GetManagerFilePath(string name, string version, string queueType)
        {
            try {
                if (!AsmCache.Scanning)
                {
                    foreach (var asm in AsmCache.Assemblies)
                    {
                        var type = asm.Types.SingleOrDefault(t =>
                                                             t.ServiceBusName == name &&
                                                             t.ServiceBusVersion == version &&
                                                             t.MessageQueueType == queueType &&
                                                             t.Interfaces.Any(i => i.EndsWith("IServiceBusManager")));

                        if (type != null)
                        {
                            return(asm.AssemblyFile);
                        }
                    }
                }
                else
                {
                    return(string.Empty);
                }
            } catch (TypeLoadException) {
                AsmCache.Rescan();

                return(GetManagerFilePath(name, version, queueType));
            }


            throw new NoMessageBusManagerFound(name, queueType);
        }
Exemple #3
0
        //static Dictionary<string, AppDomain> _domains = new Dictionary<string, AppDomain>();

        internal static IServiceBusManager CreateManager(string name, string version, string queueType)
        {
            // DH 2013-10-15: Using Separate AppDomain per Manager (version) is To Slow due all Marheling

            /*
             * var domainName = name + queueType;
             * var domain = _domains.GetValue(domainName, null);
             * if( domain == null ) {
             * domain = AppDomain.CreateDomain(domainName);
             * domain.AssemblyResolve += domain_AssemblyResolve;
             * _domains.Add(domainName, domain);
             * }
             */

            try {
                foreach (var asm in AsmCache.Assemblies)
                {
                    var type = asm.Types.SingleOrDefault(t =>
                                                         t.ServiceBusName == name &&
                                                         t.ServiceBusVersion == version &&
                                                         t.MessageQueueType == queueType &&
                                                         t.Interfaces.Any(i => i.EndsWith("IServiceBusManager")));

                    if (type != null)
                    {
                        return((IServiceBusManager)Activator.CreateInstance(asm.AssemblyName, type.TypeName).Unwrap());
                    }
                    //return (IServiceBusManager)domain.CreateInstanceAndUnwrap(asm.AssemblyName, type.TypeName);
                }
            } catch (TypeLoadException) {
                AsmCache.Rescan();

                CreateManager(name, version, queueType);
            }


            throw new NoMessageBusManagerFound(name, queueType);
        }