public XmlSpecificationCompilerTests()
        {
            // stub the extension factory
            Platform.SetExtensionFactory(new StubExtensionFactory());

            // load the test file
            using (Stream s = this.GetType().Assembly.GetManifestResourceStream("ClearCanvas.Common.Specifications.Tests.XmlSpecificationCompilerTests.xml"))
            {
                _factory = new SpecificationFactory(s);
            }
        }
Пример #2
0
		public XmlSpecificationCompilerTests()
		{
			// stub the extension factory
			Platform.SetExtensionFactory(new StubExtensionFactory());

			// load the test file
			using (Stream s = this.GetType().Assembly.GetManifestResourceStream("ClearCanvas.Common.Specifications.Tests.XmlSpecificationCompilerTests.xml"))
			{
				_factory = new SpecificationFactory(s);
			}
		}
        private static bool IsSatisfiedByAllSpecifications(IDPEndPoint ep, X509Certificate2 cert)
        {
            foreach (ICertificateSpecification spec in SpecificationFactory.GetCertificateSpecifications(ep))
            {
                if (!spec.IsSatisfiedBy(cert))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// 创建仓储规约
        /// </summary>
        /// <returns></returns>
        public ISpecification <TEntity> CreateSpecification(object searchObj, int?pageIndex = -1, int?pageSize = -1)
        {
            ISpecification <TEntity> specification = SpecificationFactory.Create <TEntity>();

            if (pageIndex != -1 && pageSize != -1)
            {
                specification.PageIndex = pageIndex;
                specification.PageSize  = pageSize;
            }
            specification.SearchObject = searchObj;
            return(specification);
        }
Пример #5
0
        /// <summary>
        /// Determines whether the certificate is satisfied by all specifications.
        /// </summary>
        /// <param name="idp">The identity provider.</param>
        /// <param name="cert">The cert.</param>
        /// <returns><c>true</c> if certificate is satisfied by all specifications; otherwise, <c>false</c>.</returns>
        private static bool CertificateSatisfiesSpecifications(IdentityProvider idp, X509Certificate2 cert, ILogger logger)
        {
            return(SpecificationFactory.GetCertificateSpecifications(idp).All(spec =>
            {
                bool isValid = spec.IsSatisfiedBy(cert);
                if (!isValid)
                {
                    logger.LogWarning(ErrorMessages.CertificateIsNotRFC3280Valid, cert.SubjectName.Name, cert.Thumbprint);
                }

                return isValid;
            }));
        }
    public static R For <T, R>(this SpecificationFactories factories)
        where T : class//, IEntity
        where R : SpecificationFactory <T>
    {
        ISpecificationFactory?factory = factories.For(typeof(T));

        if (factory == null)
        {
            var autoFac = new SpecificationFactory <T>(); // Nothing to do with AutoFac DI :)
            factories.Add <T>(autoFac);
            return((R)autoFac);
        }
        return((R)factory);
    }
        private static bool IsSatisfiedByAllSpecifications(IDPEndPoint ep, X509Certificate2 cert, out string failureReason)
        {
            foreach (ICertificateSpecification spec in SpecificationFactory.GetCertificateSpecifications(ep))
            {
                string r;
                if (!spec.IsSatisfiedBy(cert, out r))
                {
                    failureReason = $"{spec.GetType().Name}: {r}";
                    return(false);
                }
            }

            failureReason = null;
            return(true);
        }
Пример #8
0
        public async Task Get_blogs_not_expired_and_created_after_date(string dateParameter, string countParameter)
        {
            // Arrange
            var afterDate = DateTime.Parse(dateParameter);
            var count     = long.Parse(countParameter);

            // Act
            var blogRepository       = new EfReadRepository <Blog>(_mockDbContext.BloggingContext);
            var specificationFactory = new SpecificationFactory();
            var service      = new BlogService(specificationFactory, blogRepository);
            var searchResult = await service.GetNotExpiredBlogsAfterAsync(afterDate, CancellationToken.None);

            // Assert
            Check.That(searchResult).IsEqualTo(count);
        }
Пример #9
0
        static void Main(string[] args)
        {
            using (var context = new ApplicationDbContext())
            {
                var factory = new SpecificationFactory();

                var query = context.Persons.AsQueryable();

                var specification = factory.Create <Person>()
                                    .FromUkraine()
                                    .WorkInCompany();

                var persons = context.Persons.Where(specification);

                foreach (var person in persons)
                {
                    WriteLine($"Id: {person.Id}, firstName: {person.FirstName}, lastName: {person.LastName}, salary: {person.Salary}");
                }

                ReadLine();
            }
        }
Пример #10
0
        private static async Task Main()
        {
            using (var context = new DesignTimeDbContextFactory().CreateDbContext(null))
            {
                context.ConfigureLogging(s => Console.WriteLine(s), SqlLoggerFilter);
                await BloggingContextSeed.SeedAsync(context);

                var specificationFactory = new SpecificationFactory();
                var specification        = specificationFactory.Create <Blog>()
                                           .CreatedAfter(new DateTime(2017, 1, 1));

                var blogRepository = new EfReadRepository <Blog>(context);
                var result         = blogRepository
                                     .Where(specification, b => b.Posts)
                                     .ToList();

                ConsoleTableBuilder
                .From(result.ToDataTable())
                .WithFormat(ConsoleTableBuilderFormat.Minimal)
                .ExportAndWriteLine();
            }
        }
Пример #11
0
        public FindSpecification <Price> GetFindSpecification(IReadOnlyCollection <ICommand> commands)
        {
            var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList();

            return(SpecificationFactory <Price> .Contains(x => x.Id, ids));
        }
Пример #12
0
        public async Task <ActionResult <Item> > GetItems()
        {
            var list = await _repository.ListAsync(SpecificationFactory.Create <Item>());

            return(Ok(list));
        }
 public void SetUp()
 {
     factory = new SpecificationFactory();
 }
Пример #14
0
 /// <summary>
 /// Determines whether the certificate is satisfied by all specifications.
 /// </summary>
 /// <param name="idp">The identity provider.</param>
 /// <param name="cert">The cert.</param>
 /// <returns><c>true</c> if certificate is satisfied by all specifications; otherwise, <c>false</c>.</returns>
 private static bool CertificateSatisfiesSpecifications(IdentityProvider idp, X509Certificate2 cert)
 {
     return(SpecificationFactory.GetCertificateSpecifications(idp).All(spec => spec.IsSatisfiedBy(cert)));
 }
Пример #15
0
 public void OtherProfile()
 {
     var spec     = SpecificationFactory.Create("http://someserver.nl/Profile/lipid.profile.xml#ldlCholesterol");
     var resource = TestProvider.LoadResource("TestData\\ldlcholesterol-correct.xml");
     var report   = spec.Validate(resource);
 }
Пример #16
0
 public static void Init(TestContext context)
 {
     spec = SpecificationFactory.Create("http://hl7.org/fhir/Profile/Profile");
 }
        public FindSpecification <SalesModelCategoryRestriction> GetFindSpecification(IReadOnlyCollection <ICommand> commands)
        {
            var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList();

            return(SpecificationFactory <SalesModelCategoryRestriction> .Contains(x => x.ProjectId, ids));
        }
 public FindSpecification<CategoryOrganizationUnit> GetFindSpecification(IReadOnlyCollection<ICommand> commands)
 {
     var ids = commands.Cast<SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList();
     return SpecificationFactory<CategoryOrganizationUnit>.Contains(x => x.Id, ids);
 }
 public void Setup()
 {
     _flyweightedFactory = new Mock<IFlyweightedFactory>();
     _specificationFactory = new SpecificationFactory(_flyweightedFactory.Object);
 }
 public static SpecificationFactories Add <T>(this SpecificationFactories factories, SpecificationFactory <T> factory)
     where T : class//, IEntity
 {
     factories.Register(typeof(T), factory);
     return(factories);
 }
Пример #21
0
        public FindSpecification <OrderPositionCostPerClick> GetFindSpecification(IReadOnlyCollection <ICommand> commands)
        {
            var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList();

            return(SpecificationFactory <OrderPositionCostPerClick> .Contains(x => x.OrderPositionId, ids));
        }