Exemple #1
0
        public void CanReturnServiceIfInitializedAndRegistered()
        {
            IWindsorContainer container = new WindsorContainer();

            container.AddComponent("validator", typeof(IValidator), typeof(Validator));
            ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));

            IValidator validatorService = SafeServiceLocator <IValidator> .GetService();

            Assert.That(validatorService, Is.Not.Null);
        }
Exemple #2
0
        public override bool IsValid(object value)
        {
            var entityToValidate = value as IEntityWithTypedId <int>;

            Check.Require(
                entityToValidate != null,
                "This validator must be used at the class level of an IDomainWithTypedId<int>. The type you provided was " + value.GetType());

            var duplicateChecker = SafeServiceLocator <IEntityDuplicateChecker> .GetService();

            return(!duplicateChecker.DoesDuplicateExistWithTypedIdOf(entityToValidate));
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            IDocumentSession session = SafeServiceLocator <IDocumentSession> .GetService();

            if (((filterContext.Exception != null) && filterContext.ExceptionHandled) ||
                this.ShouldRollback(filterContext))
            {
                return;
            }

            session.SaveChanges();
        }
        public bool IsValid(object value, IConstraintValidatorContext constraintValidatorContext)
        {
            IEntityWithTypedId <int> entityToValidate = value as IEntityWithTypedId <int>;

            Check.Require(entityToValidate != null,
                          "This validator must be used at the class level of an " +
                          "IdomainWithTypedId<int>. The type you provided was " + value.GetType().ToString());

            IEntityDuplicateChecker duplicateChecker = SafeServiceLocator <IEntityDuplicateChecker> .GetService();

            return(!duplicateChecker.DoesDuplicateExistWithTypedIdOf <int>(entityToValidate));
        }
        public void WillBeInformedIfServiceLocatorNotInitialized()
        {
            bool exceptionThrown = false;

            try {
                SafeServiceLocator <IValidator> .GetService();
            }
            catch (NullReferenceException e) {
                exceptionThrown = true;
                Assert.That(e.Message.Contains("ServiceLocator has not been initialized"));
            }

            Assert.That(exceptionThrown);
        }
        public bool IsValid(object value, IConstraintValidatorContext constraintValidatorContext)
        {
            IEntityWithTypedId <string> entityToValidate = value as IEntityWithTypedId <string>;

            Check.Require(entityToValidate != null,
                          "This validator must be used at the class level of an " +
                          "IdomainWithTypedId<string>. The type you provided was " + value.GetType().ToString() + ". " +
                          "Other validators exist for various Id types. Please open an issue with S#arp Architecture " +
                          "if you need a new Id type supported; you can make your own in the meantime.");

            IEntityDuplicateChecker duplicateChecker = SafeServiceLocator <IEntityDuplicateChecker> .GetService();

            return(!duplicateChecker.DoesDuplicateExistWithTypedIdOf <string>(entityToValidate));
        }
        public void WillBeInformedIfServiceNotRegistered()
        {
            bool exceptionThrown = false;

            IWindsorContainer container = new WindsorContainer();

            ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));

            try {
                SafeServiceLocator <IValidator> .GetService();
            }
            catch (ActivationException e) {
                exceptionThrown = true;
                Assert.That(e.Message.Contains("IValidator could not be located"));
            }

            Assert.That(exceptionThrown);
        }
        public OutfitEngineService()
        {
            // HACK: To support multiple calls from WCF Service, we need to create the dependencies here.
            garmentRepository = SafeServiceLocator <IGarmentRepository> .GetService();

            closetRepository = SafeServiceLocator <IClosetRepository> .GetService();

            fashionFlavorRepository = SafeServiceLocator <IFashionFlavorRepository> .GetService();

            // HACK: We create always a new Processor to avoid conflicts if retrieve it directly from Locator as it works like Singleton.
            processor = new OutfitEngineProcessor(
                SafeServiceLocator <IStyleRuleRepository> .GetService(),
                SafeServiceLocator <IClosetRepository> .GetService(),
                SafeServiceLocator <IOutfitUpdaterService> .GetService(),
                SafeServiceLocator <IIndexCreationService> .GetService());

            logger = log4net.LogManager.GetLogger(this.GetType().Namespace);
            logger.Info("Constructor called");
        }
Exemple #9
0
        public static string GetKey()
        {
            var provider = SafeServiceLocator <ISessionFactoryKeyProvider> .GetService();

            return(provider.GetKey());
        }
Exemple #10
0
        public static string GetKeyFrom(object anObject)
        {
            var provider = SafeServiceLocator <ISessionFactoryKeyProvider> .GetService();

            return(provider.GetKeyFrom(anObject));
        }
Exemple #11
0
 public CotRoleProvider()
 {
     _personManagementService = SafeServiceLocator <IPersonManagementService> .GetService();
 }