Could be the most 'meta' class I ever wrote... or a coding horror?
-
ServiceCallInfo is actually a DataContract. Yes... I have actually implemented a service that can call any other service it happens to find in it's configuration. I'm sure none of this would be necessary in a dynamic language like Ruby, however what other framework/language provides such a comprehensive and flexible service framework like WCF? I wasn't sure if this should go in "Clever Code" or "Hall of Shame" for it's meta-ness. I put it here, because I like to doubt myself :-) Right now it depends on all the service contracts being contained in one interface assembly though... I suppose I could also pass in the assembly name containing the contract and have it dynamically try to find or load the assembly too. Or would that be too far?
internal class ReflectedServiceChannelMethod
{
private static readonly Assembly InterfaceAssem = Assembly.GetAssembly(typeof(IGeneralLookupService));
private readonly Type _contractType;
private readonly Type _channelFactoryType;
private readonly object _channelFactory;
private readonly MethodInfo _createChannelMethod;
private readonly MethodInfo _callMethodInfo;
private readonly ParameterInfo[] _methodParams;public ReflectedServiceChannelMethod(string interfaceName, string methodName) { \_contractType = \_interfaceAssem.GetType(interfaceName); \_channelFactoryType = typeof(EdsChannelFactory<>).MakeGenericType(\_contractType); \_callMethodInfo = \_contractType.GetMethod(methodName); \_methodParams = \_callMethodInfo.GetParameters(); var channelFactoryConstructor = \_channelFactoryType.GetConstructor(new Type\[\] {}); \_channelFactory = channelFactoryConstructor.Invoke(new object\[\] {}); \_createChannelMethod = \_channelFactoryType.GetMethod("CreateDefaultChannel", new Type\[\]{}); } public object CallService(ServiceCallInfo job) { object channel = null; try { channel = \_createChannelMethod.Invoke(\_channelFactory, new object\[\] { }); var parameters = new List<object>(); foreach (var methodParam in \_methodParams) { object value = null; var paramType = methodParam.ParameterType.MakeByValType(); if (job.Parameters != null) { ParameterInfo param = me
-
ServiceCallInfo is actually a DataContract. Yes... I have actually implemented a service that can call any other service it happens to find in it's configuration. I'm sure none of this would be necessary in a dynamic language like Ruby, however what other framework/language provides such a comprehensive and flexible service framework like WCF? I wasn't sure if this should go in "Clever Code" or "Hall of Shame" for it's meta-ness. I put it here, because I like to doubt myself :-) Right now it depends on all the service contracts being contained in one interface assembly though... I suppose I could also pass in the assembly name containing the contract and have it dynamically try to find or load the assembly too. Or would that be too far?
internal class ReflectedServiceChannelMethod
{
private static readonly Assembly InterfaceAssem = Assembly.GetAssembly(typeof(IGeneralLookupService));
private readonly Type _contractType;
private readonly Type _channelFactoryType;
private readonly object _channelFactory;
private readonly MethodInfo _createChannelMethod;
private readonly MethodInfo _callMethodInfo;
private readonly ParameterInfo[] _methodParams;public ReflectedServiceChannelMethod(string interfaceName, string methodName) { \_contractType = \_interfaceAssem.GetType(interfaceName); \_channelFactoryType = typeof(EdsChannelFactory<>).MakeGenericType(\_contractType); \_callMethodInfo = \_contractType.GetMethod(methodName); \_methodParams = \_callMethodInfo.GetParameters(); var channelFactoryConstructor = \_channelFactoryType.GetConstructor(new Type\[\] {}); \_channelFactory = channelFactoryConstructor.Invoke(new object\[\] {}); \_createChannelMethod = \_channelFactoryType.GetMethod("CreateDefaultChannel", new Type\[\]{}); } public object CallService(ServiceCallInfo job) { object channel = null; try { channel = \_createChannelMethod.Invoke(\_channelFactory, new object\[\] { }); var parameters = new List<object>(); foreach (var methodParam in \_methodParams) { object value = null; var paramType = methodParam.ParameterType.MakeByValType(); if (job.Parameters != null) { ParameterInfo param = me
ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory
.Software Zen:
delete this;
-
ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory
.Software Zen:
delete this;
Gary R. Wheeler wrote:
ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory
.You forgot "GoldProTeamEdition"...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water