Пример #1
0
        private void LoadValueFromDataBus(IDataBusProperty propertyInstance, DataBusPropertyInfo propertyInfo)
        {
            if (String.IsNullOrWhiteSpace(propertyInstance.ClaimKey))
            {
                string errorMsg = String.Format("Claim key of databus property '{0}' is missing. We can't fetch anything from the databus if the claimkey is null or whitespace.", propertyInfo.Name);

                _log.Error(errorMsg);

                throw new DataBusPropertyLoadException(errorMsg);
            }

            using (new TransactionScope(_dataBusSettings.TransactionScope))
            {
                //todo remove file from databus?
                using (Stream stream = _dataBus.Get(propertyInstance.ClaimKey, propertyInfo.IsCompressedProperty))
                {
                    if (_dataBusSettings.IsChecksummingEnabled)
                    {
                        DoChecksumming(propertyInstance, propertyInfo, stream);
                    }

                    stream.Position = 0;
                    object obj = _dataBusSerializer.Deserialize(stream);

                    if (obj == null)
                    {
                        _log.Warn("Deserializing databus stream resulted in a null object.");
                    }

                    propertyInstance.SetValue(obj);
                }
            }
        }
Пример #2
0
 IMessage IMutateIncomingMessages.MutateIncoming(IMessage message)
 {
     using (new TransactionScope(TransactionScopeOption.Suppress))
         foreach (var dataBusProperty in message.DataBusPropertiesWithValues())
         {
             using (var stream = dataBus.Get(dataBusProperty.Key))
             {
                 var value = serializer.Deserialize(stream);
                 dataBusProperty.SetValue(value);
             }
         }
     return(message);
 }
Пример #3
0
        object IMutateIncomingMessages.MutateIncoming(object message)
        {
            using (new TransactionScope(TransactionScopeOption.Suppress))
                foreach (var dataBusProperty in message.DataBusPropertiesWithValues())
                {
                    var dataBusKey = message.GetHeader(DATABUS_PREFIX + dataBusProperty.Key);

                    using (var stream = dataBus.Get(dataBusKey))
                    {
                        var value = serializer.Deserialize(stream);
                        dataBusProperty.SetValue(value);
                    }
                }
            return(message);
        }
Пример #4
0
        object IMutateIncomingMessages.MutateIncoming(object message)
        {
            using (new TransactionScope(TransactionScopeOption.Suppress))
            {
                foreach (var property in GetDataBusProperties(message))
                {
                    var propertyValue = property.GetValue(message, null);

                    var    dataBusProperty = propertyValue as IDataBusProperty;
                    string headerKey;

                    if (dataBusProperty != null)
                    {
                        headerKey = dataBusProperty.Key;
                    }
                    else
                    {
                        headerKey = String.Format("{0}.{1}", message.GetType().FullName, property.Name);
                    }

                    var dataBusKey = message.GetHeader(DATABUS_PREFIX + headerKey);

                    if (string.IsNullOrEmpty(dataBusKey))
                    {
                        continue;
                    }

                    using (var stream = dataBus.Get(dataBusKey))
                    {
                        var value = serializer.Deserialize(stream);

                        if (dataBusProperty != null)
                        {
                            dataBusProperty.SetValue(value);
                        }
                        else
                        {
                            property.SetValue(message, value, null);
                        }
                    }
                }
            }

            return(message);
        }