示例#1
0
        private Future <RelayOutcome> DeleteObject <T>(int primaryId, byte[] extendedId)
        {
            var typeSetting = GetTypeSetting <T>();

            if (typeSetting == null)
            {
                return(RelayTypeSettings.InvalidTypeFuture <RelayOutcome>());
            }
            var relayMessage = new RelayMessage(typeSetting.TypeId, primaryId, extendedId, MessageType.Delete);

            return(SendRelayMessage(typeSetting, relayMessage).Convert(replyMessage => replyMessage == null ? RelayOutcome.Success : replyMessage.ResultOutcome ?? RelayOutcome.Success));
        }
示例#2
0
        private Future <RelayOutcome> PutObject <T>(int primaryId, byte[] extendedId, T saveObject)
        {
            var typeSetting = base.GetTypeSetting <T>();

            if (typeSetting == null)
            {
                return(RelayTypeSettings.InvalidTypeFuture <RelayOutcome>());
            }

            var payload      = new RelayPayload(typeSetting.TypeId, primaryId, Serializer.Serialize(saveObject, typeSetting.Compress), typeSetting.Compress);
            var relayMessage = new RelayMessage(typeSetting.TypeId, primaryId, extendedId, MessageType.Save);

            relayMessage.Payload = payload;
            return(SendRelayMessage(typeSetting, relayMessage).Convert(replyMessage => replyMessage == null ? RelayOutcome.Success : replyMessage.ResultOutcome ?? RelayOutcome.Success));
        }
示例#3
0
        private Future <CacheResult <T> > GetObject <T>(int primaryId, byte[] extendedId)
        {
            var typeSetting = GetTypeSetting <T>();

            if (typeSetting == null)
            {
                return(RelayTypeSettings.InvalidTypeFuture <CacheResult <T> >());
            }

            var relayMessage = new RelayMessage(typeSetting.TypeId, primaryId, extendedId, MessageType.Get);

            var future = SendRelayMessage(typeSetting, relayMessage);

            return(future.Convert(replyMessage =>
            {
                if (replyMessage == null || replyMessage.Payload == null)
                {
                    return new CacheResult <T>();
                }
                return new CacheResult <T>(replyMessage.Payload.GetObject <T>());
            }));
        }