Example #1
0
        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;
        }
Example #2
0
        private static byte CreateMessageFlowArguments(byte id, Type type, string profile)
        {
            var properties      = RuntimePropertyInfo.GetPropertyInfo(Activator.CreateInstance(type).GetPropertyTypes().ToArray());
            var messageFlowArgs = new MessageFlowArguments();

            messageFlowArgs.MessageHandler = new DummyHandler();
            messageFlowArgs.MessagePoco    = Dependencies.Container.Resolve <IPocoFactory>().Create(properties, "poco" + id);
            messageFlowArgs.ID             = (byte)(GemNetwork.InitialId + ProtocolObjectsFound++);

            GemClient.MessageFlow[profile, MessageType.Data].Add(messageFlowArgs);
            GemServer.MessageFlow[profile, MessageType.Data].Add(new MessageArguments
            {
                ID             = messageFlowArgs.ID,
                MessageHandler = new DummyHandler(),
                MessagePoco    = messageFlowArgs.MessagePoco
            });

            return(messageFlowArgs.ID);
        }