Exemplo n.º 1
0
 /// <summary>Initializes a new instance of the <see cref="UrlMatchingResourceResolutionStrategy" /> class.</summary>
 /// <param name="ontology">Optional ontology provider.</param>
 /// <param name="mappingAssemblies">Optional mapping assemblies.</param>
 /// <param name="baseUris">Base uris.</param>
 /// <param name="webRequestFactory">Web request factory method.</param>
 public UrlMatchingResourceResolutionStrategy(IOntologyProvider ontology, IEnumerable <Assembly> mappingAssemblies, IEnumerable <Uri> baseUris, Func <Uri, WebRequest> webRequestFactory = null)
 {
     _namedGraphSelector = new BaseUriNamedGraphSelector(_baseUris = baseUris);
     _metaGraph.BaseUri  = new Uri("urn:meta:graph");
     _tripleStore.Add(_metaGraph);
     _entityContext     = new Lazy <IEntityContext>(() => CreateEntityContext(ontology, mappingAssemblies));
     _webRequestFactory = webRequestFactory ?? CreateRequest;
     _predicateNode     = _metaGraph.CreateUriNode(Foaf.primaryTopic);
 }
        /// <summary>
        /// Creates a new instance of <see cref="EntityContextFactory"/>
        /// </summary>
        public EntityContextFactory()
        {
            // todo: change how defaults are set
            _namedGraphSelector = new NamedGraphSelector();
            _mappingsRepository = new MappingsRepository();
            _mappingsRepository.AddVisitor(_matcher);

            WithMappings(DefaultMappings);
            _conventions = CreateDefaultConventions().ToList();
            LogTo.Info("Created entity context factory");
        }
Exemplo n.º 3
0
 /// <summary>Initializes a new instance of the <see cref="EntityProxy" /> class.</summary>
 /// <param name="entity">The entity.</param>
 /// <param name="entityMapping">The entity mappings.</param>
 /// <param name="resultTransformers">The result transformers.</param>
 /// <param name="selector">The named graph selector.</param>
 /// <param name="log">Logging facility.</param>
 public EntityProxy(
     Entity entity,
     IEntityMapping entityMapping,
     IResultTransformerCatalog resultTransformers,
     INamedGraphSelector selector,
     ILogger log)
 {
     _store              = (_context = entity.Context).Store;
     _entity             = entity;
     _entityMapping      = entityMapping;
     _resultTransformers = resultTransformers;
     _selector           = selector;
     _log = log;
 }
 public void Setup()
 {
     var descriptionBuilder = new Mock<IHttpControllerDescriptionBuilder>(MockBehavior.Strict);
     var controllerInfo = new ControllerInfo<TestController>(
         null,
         EntryPoint,
         typeof(TestController).GetMethod("List").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
         typeof(TestController).GetMethod("Get").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
         typeof(TestController).GetMethod("Create").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
         typeof(TestController).GetMethod("Update").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
         typeof(TestController).GetMethod("Delete").ToOperationInfo(EntryPoint.ToString(), Verb.GET));
     descriptionBuilder.Setup(instance => instance.BuildDescriptor()).Returns(controllerInfo);
     _selector = new OwningResourceNamedGraphSelector(new[] { descriptionBuilder.Object });
 }
 public InternalProxyCaster(
     Func <Entity, IEntityMapping, IEntityProxy> proxyFactory,
     IMappingsRepository mappings,
     INamedGraphSelector graphSelector,
     IEntityStore store)
 {
     _createProxy          = proxyFactory;
     _mappings             = mappings;
     _graphSelector        = graphSelector;
     _store                = store;
     _typedEntityMapping   = _mappings.MappingFor <ITypedEntity>();
     _typesPropertyMapping = _typedEntityMapping.PropertyFor("Types");
     _cache                = new ConcurrentDictionary <IEntityContext, IDictionary <Entity, IDictionary <int, dynamic> > >();
 }
Exemplo n.º 6
0
        public void Setup()
        {
            var descriptionBuilder = new Mock <IHttpControllerDescriptionBuilder>(MockBehavior.Strict);
            var controllerInfo     = new ControllerInfo <TestController>(
                null,
                EntryPoint,
                typeof(TestController).GetMethod("List").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
                typeof(TestController).GetMethod("Get").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
                typeof(TestController).GetMethod("Create").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
                typeof(TestController).GetMethod("Update").ToOperationInfo(EntryPoint.ToString(), Verb.GET),
                typeof(TestController).GetMethod("Delete").ToOperationInfo(EntryPoint.ToString(), Verb.GET));

            descriptionBuilder.Setup(instance => instance.BuildDescriptor()).Returns(controllerInfo);
            _selector = new OwningResourceNamedGraphSelector(new[] { descriptionBuilder.Object });
        }
 public void Teardown()
 {
     _graphSelector = null;
 }
 public void Setup()
 {
     _graphSelector = new BaseUriNamedGraphSelector(new Uri(BaseUri));
 }
Exemplo n.º 9
0
 public void Teardown()
 {
     _selector = null;
 }
 public void Teardown()
 {
     _selector = null;
 }
Exemplo n.º 11
0
 private static Uri SelectGraphMethod(INamedGraphSelector arg)
 {
     return(null);
 }
 private static Uri SelectGraphMethod(INamedGraphSelector arg)
 {
     return null;
 }
 /// <summary>Exposes a method to define how the default graph name should be obtained.</summary>
 public EntityContextFactory WithNamedGraphSelector(INamedGraphSelector namedGraphSelector)
 {
     _namedGraphSelector = namedGraphSelector;
     return this;
 }
Exemplo n.º 14
0
 /// <summary>Exposes a method to define how the default graph name should be obtained.</summary>
 public EntityContextFactory WithNamedGraphSelector(INamedGraphSelector namedGraphSelector)
 {
     _container.RegisterInstance(namedGraphSelector);
     return(this);
 }