Example #1
0
        private IEntityContext CreateEntityContext(IKernel kernel, CreationContext context)
        {
            IEntityContext result = null;

            lock (_lock)
            {
                EntityContextFactory entityContextFactory = _entityContextFactory.Value;
                if (!_isNamedGraphSelectorInitialized)
                {
                    entityContextFactory             = entityContextFactory.WithNamedGraphSelector(kernel.Resolve <INamedGraphSelector>());
                    _isNamedGraphSelectorInitialized = true;
                }

                if (!_isBaseUriInitialized)
                {
                    var baseUri = kernel.Resolve <IHttpServerConfiguration>().BaseUri;
                    if (baseUri != null)
                    {
                        _isBaseUriInitialized = true;
                        result = entityContextFactory.WithBaseUri(policy => policy.Default.Is(baseUri)).CreateContext();
                    }
                }

                if (result == null)
                {
                    result = entityContextFactory.CreateContext();
                }
            }

            return(result);
        }