Example #1
0
        /// <summary>
        /// Load a consumer object into its own app domain
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="typeName"></param>
        /// <param name="name"></param>
        private void LoadConsumer(String assemblyName, String typeName, String name)
        {
            Assembly assembly     = Assembly.Load(assemblyName);
            Type     consumerType = assembly.GetType(typeName);

            if (consumerType == null)
            {
                Log.Error("Consumer type could not be loaded: '" + name + "'");
                return;
            }
            IServiceConsumer consumer = Activator.CreateInstance(assembly.GetType(typeName)) as IServiceConsumer;

            if (consumer == null)
            {
                Log.Error("Consumer instance could not be created or does not derive from IServiceConsumer: '" + name + "'");
                return;
            }

            Object[] attributes = consumer.GetType().GetCustomAttributes(typeof(GuidAttribute), true);
            Guid     consumerId = (attributes.Length == 0 ? Guid.Empty : new Guid(((GuidAttribute)attributes[0]).Value));

            if (consumerId == Guid.Empty)
            {
                Log.Error("Consumer '" + typeName + "' has no Guid assigned");
                return;
            }

            ServiceConsumerInfo info = new ServiceConsumerInfo();

            info.Id = consumerId;
            info.ServiceConsumer         = consumer;
            ServiceConsumers[consumerId] = info;
        }
Example #2
0
        /// <summary>
        /// Unload a consumer
        /// </summary>
        /// <param name="consumerInfo"></param>
        private void UnloadConsumer(ServiceConsumerInfo consumerInfo)
        {
            if (consumerInfo == null)
            {
                return;
            }

            ServiceConsumers.Remove(consumerInfo.Id);
        }
Example #3
0
        /// <summary>
        /// Unload a consumer
        /// </summary>
        /// <param name="consumerInfo"></param>
        private void UnloadConsumer(ServiceConsumerInfo consumerInfo)
        {
            if (consumerInfo == null) return;

            ServiceConsumers.Remove(consumerInfo.Id);
        }
Example #4
0
        /// <summary>
        /// Load a consumer object into its own app domain
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="typeName"></param>
        /// <param name="name"></param>
        private void LoadConsumer(String assemblyName, String typeName, String name)
        {
            Assembly assembly = Assembly.Load(assemblyName);
            Type consumerType = assembly.GetType(typeName);
            if (consumerType == null)
            {
                Log.Error("Consumer type could not be loaded: '"+ name +"'");
                return;
            }
            IServiceConsumer consumer = Activator.CreateInstance(assembly.GetType(typeName)) as IServiceConsumer;
            if (consumer == null)
            {
                Log.Error("Consumer instance could not be created or does not derive from IServiceConsumer: '" + name + "'");
                return;
            }

            Object[] attributes = consumer.GetType().GetCustomAttributes(typeof (GuidAttribute), true);
            Guid consumerId = (attributes.Length == 0 ? Guid.Empty : new Guid(((GuidAttribute) attributes[0]).Value));
            if (consumerId == Guid.Empty)
            {
                Log.Error("Consumer '"+ typeName +"' has no Guid assigned");
                return;
            }

            ServiceConsumerInfo info = new ServiceConsumerInfo();
            info.Id = consumerId;
            info.ServiceConsumer = consumer;
            ServiceConsumers[consumerId] = info;
        }