public static void LaunchPlugin(newPlugin createDelegate) { TopologyContext context = null; Config config = new Config(); Context.pluginType = PluginType.UNKNOW; #if NETFRAMEWORK4 Type classType = createDelegate.Method.ReturnType; #else Type classType = createDelegate.GetMethodInfo().ReturnType; #endif Type[] interfaces = classType.GetInterfaces(); foreach (Type eachType in interfaces) { if (eachType == typeof(ISpout)) { Context.pluginType = PluginType.SPOUT; break; } else if (eachType == typeof(IBolt)) { Context.pluginType = PluginType.BOLT; break; } else if (eachType == typeof(IBasicBolt)) { Context.pluginType = PluginType.BASICBOLT; break; } } InitComponent(ref config, ref context); Context.Config = config; Context.TopologyContext = context; PluginType pluginType = Context.pluginType; Context.Logger.Info("LaunchPlugin, pluginType: {0}", new object[] { pluginType }); switch (pluginType) { case PluginType.SPOUT: { Spout spout = new Spout(createDelegate); spout.Launch(); return; } case PluginType.BOLT: { Bolt bolt = new Bolt(createDelegate); bolt.Launch(); return; } case PluginType.BASICBOLT: { BasicBolt basicBolt = new BasicBolt(createDelegate); basicBolt.Launch(); return; } default: { Context.Logger.Error("unexpected pluginType: {0}!", new object[] { pluginType }); return; } } }
public static void LaunchPlugin(newPlugin createDelegate) { TopologyContext context = null; Config config = new Config(); Context.pluginType = PluginType.UNKNOW; Type classType = createDelegate.Method.ReturnType; Type[] interfaces = classType.GetInterfaces(); foreach (Type eachType in interfaces) { if (eachType == typeof(ISpout)) { Context.pluginType = PluginType.SPOUT; break; } else if (eachType == typeof(IBolt)) { Context.pluginType = PluginType.BOLT; break; } else if (eachType == typeof(IBasicBolt)) { Context.pluginType = PluginType.BASICBOLT; break; } } InitComponent(ref config, ref context); Context.Config = config; Context.TopologyContext = context; PluginType pluginType = Context.pluginType; Context.Logger.Info("LaunchPlugin, pluginType: {0}", new object[] { pluginType }); switch (pluginType) { case PluginType.SPOUT: { Spout spout = new Spout(createDelegate); spout.Launch(); return; } case PluginType.BOLT: { Bolt bolt = new Bolt(createDelegate); bolt.Launch(); return; } case PluginType.BASICBOLT: { BasicBolt basicBolt = new BasicBolt(createDelegate); basicBolt.Launch(); return; } default: { Context.Logger.Error("unexpected pluginType: {0}!", new object[] { pluginType }); return; } } }