private static void Clear(NativeActivityContext context)
        {
            var properties = ActivityHelpers.GetBpContextProperties(context, _properties);

            if (properties.ContainsKey(UnitOfWorkInternalPropertyName))
            {
                var uw = (IUnitOfWork)properties[UnitOfWorkInternalPropertyName];
                if (uw != null)
                {
                    uw.Dispose();
                }
                properties[UnitOfWorkInternalPropertyName] = null;
            }

            if (properties.ContainsKey(UseTransPropertyName))
            {
                properties.Remove(UseTransPropertyName);
            }

            //throw new DeveloperException("Не найдено свойство типа IUnitOfWork в аргументе {0}.", BpContextArgumentName);
        }
        public static IUnitOfWork GetUnitOfWork(NativeActivityContext context)
        {
            var properties = ActivityHelpers.GetBpContextProperties(context, _properties);

            //if (properties == null)
            //    throw new DeveloperException("Ошибка получения свойств для создания транзакции (GetUnitOfWork).");
            if (properties == null) //Убрал exception для случая отсутсвия BpContext
            {
                return(null);
            }

            if (properties.ContainsKey(UnitOfWorkInternalPropertyName))
            {
                return((IUnitOfWork)properties[UnitOfWorkInternalPropertyName]);
            }

            if (properties.ContainsKey(UseTransPropertyName))
            {
                throw new DeveloperException("Не найдено свойство типа IUnitOfWork в аргументе {0}.", BpContext.BpContextArgumentName);
            }
            return(null);
        }
        protected override void Execute(NativeActivityContext context)
        {
            var properties = ActivityHelpers.GetBpContextProperties(context, _properties);

            if (properties == null)
            {
                throw new DeveloperException("Ошибка получения свойств для создания транзакции.");
            }

            properties[UseTransPropertyName] = true;

            IUnitOfWork uw;

            if (properties.ContainsKey(UnitOfWorkInternalPropertyName))
            {
                uw = (IUnitOfWork)properties[UnitOfWorkInternalPropertyName];
                if (uw != null)
                {
                    throw new DeveloperException("Невозможно открыть новую транзакцию. Предыдущая транзакция не завершена.");
                }
            }

            var uowFactory = IoC.Instance.Resolve <IUnitOfWorkFactory>();

            uw = uowFactory.Create(false);

            if (IsolationLevel == IsolationLevel.Unspecified)
            {
                uw.BeginChanges();
            }
            else
            {
                uw.BeginChanges(IsolationLevel);
            }

            properties[UnitOfWorkInternalPropertyName] = uw;
        }