public INetworkEvent AndHandleWith<T>(T objectToHandle, Expression<Func<T, Delegate>> methodToHandle) { var methodInfo = methodToHandle.GetMethodInfo(); var types = methodInfo.GetParameters().Select(x => x.ParameterType).ToList(); Guard.That(types.All(x => x.IsPrimitive || x == typeof(string)), "All types should be primitive"); var properties = RuntimePropertyInfo.GetPropertyInfo(types.ToArray()); SetDynamicPoco(properties); SetMessageHandler(properties.Select(x => RuntimePropertyInfo.GetPrimitiveTypeAlias(x.PropertyType)).ToList(), objectToHandle, methodInfo.Name); var argumentsDisposable = GemClient.MessageFlow[profile,messageType].Add(messageFlowArgs); SetDynamicEvent(argumentsDisposable); messageFlowArgs.IncludesLocalTime = false; GemClient.MessageFlow[profile, messageType].SubscribeEvent(messageFlowArgs.ID); return messageFlowArgs.EventRaisingclass; }
private string GetMapping(List <RuntimePropertyInfo> propertyFields) { var sb = new StringBuilder(); for (int i = 0; i < propertyFields.Count; i++) { sb.Append(string.Format("{0} =({1})props[{2}],", propertyFields[i].PropertyName, RuntimePropertyInfo.GetPrimitiveTypeAlias(propertyFields[i].PropertyType), i)); } sb.Length--; return(sb.ToString()); }