public IDictionary <string, IBackend> CreateAll()
        {
            var result = new Dictionary <string, IBackend>();

            foreach (var component in ComponentProvider.GetAll())
            {
                foreach (var type in component.Assembly.Types)
                {
                    var attribute = type.GetCustomAttribute <DataTableBackendAttribute>();

                    if (attribute == null)
                    {
                        continue;
                    }

                    if (!typeof(IBackend).IsAssignableFrom(type))
                    {
                        throw new DataTableBackendDoesNotImplementIBackendException(type);
                    }

                    result.Add(attribute.Id, (IBackend)Instantiator.Instantiate(type));
                }
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Returns the Component contents which could be found. Components that couldn't be found don't appear in the list.
        /// </summary>
        /// <param name="componentUris"></param>
        /// <returns></returns>
        public IList <IComponent> GetComponents(string[] componentUris)
        {
            List <IComponent> components = new List <IComponent>();

            foreach (string content in ComponentProvider.GetContentMultiple(componentUris))
            {
                components.Add(GetIComponentObject(content));
            }
            return(components);
        }
 public IEnumerable <T> GetAll <T>() where T : IComposable
 {
     return(ComponentProvider
            .GetAll()
            .Select(c => c.Assembly)
            .SelectMany(a => a.Types)
            .Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && typeof(T).IsAssignableFrom(t))
            .Select(t => (T)Instantiator.Instantiate(t))
            .ToList()
            .AsReadOnly());
 }
Exemple #4
0
        public IList <IComponent> FindComponents(IQuery queryParameters)
        {
            LoggerService.Debug(">>FindComponents ({0})", LoggingCategory.Performance, queryParameters.ToString());

            var results = ComponentProvider.FindComponents(queryParameters)
                          .Select(c => { IComponent comp = null; TryGetComponent(c, out comp); return(comp); })
                          .Where(c => c != null)
                          .ToList();

            LoggerService.Debug("<<FindComponents ({0})", LoggingCategory.Performance, queryParameters.ToString());
            return(results);
        }
Exemple #5
0
        public IList <IComponent> FindComponents(IQuery queryParameters, int pageIndex, int pageSize, out int totalCount)
        {
            LoggerService.Debug(">>FindComponents ({0},{1})", LoggingCategory.Performance, queryParameters.ToString(), Convert.ToString(pageIndex));
            totalCount = 0;
            IList <string> results = ComponentProvider.FindComponents(queryParameters);

            totalCount = results.Count;

            var pagedResults = results
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .Select(c => { IComponent comp = null; TryGetComponent(c, out comp); return(comp); })
                               .Where(c => c != null)
                               .ToList();

            LoggerService.Debug("<<FindComponents ({0},{1})", LoggingCategory.Performance, queryParameters.ToString(), Convert.ToString(pageIndex));
            return(pagedResults);
        }
		internal HttpServer.HttpServer GetCore()
		{
			if(core == null)
			{
				// create my dispatcher module
				var testModule = new DispatcherModule(GetClassList());

				// create session handling
				var customComponents = new ComponentProvider();
				var sessionStore = new MemorySessionStore();
				sessionStore.ExpireTime = 5;

				customComponents.AddInstance<IHttpSessionStore>(sessionStore);

				core = new HttpServer.HttpServer(customComponents);
				core.Add(new HttpModuleWrapper(testModule));
			}
			return core;
		}
Exemple #7
0
        public bool TryGetComponent(string componentUri, out IComponent component, string templateUri = "")
        {
            LoggerService.Debug(">>TryGetComponent ({0})", LoggingCategory.Performance, componentUri);

            component = null;

            string cacheKey = String.Format(CacheKeyFormatByUri, componentUri, templateUri);

            component = (IComponent)CacheAgent.Load(cacheKey);

            if (component != null)
            {
                LoggerService.Debug("<<TryGetComponent ({0}) - from cache", LoggingCategory.Performance, componentUri);
                return(true);
            }

            string content = !String.IsNullOrEmpty(templateUri) ? ComponentProvider.GetContent(componentUri, templateUri) : ComponentProvider.GetContent(componentUri);

            if (string.IsNullOrEmpty(content))
            {
                LoggerService.Debug("<<TryGetComponent ({0}) - from provider", LoggingCategory.Performance, componentUri);
                return(false);
            }

            LoggerService.Debug("about to create IComponent from content ({0})", LoggingCategory.Performance, componentUri);
            component = GetIComponentObject(content);
            LoggerService.Debug("finished creating IComponent from content ({0})", LoggingCategory.Performance, componentUri);

            if (IncludeLastPublishedDate)
            {
                ((Component)component).LastPublishedDate = ComponentProvider.GetLastPublishedDate(componentUri);
            }
            LoggerService.Debug("about to store IComponent in cache ({0})", LoggingCategory.Performance, componentUri);
            CacheAgent.Store(cacheKey, CacheRegion, component);
            LoggerService.Debug("finished storing IComponent in cache ({0})", LoggingCategory.Performance, componentUri);
            LoggerService.Debug("<<TryGetComponent ({0})", LoggingCategory.Performance, componentUri);
            return(true);
        }
Exemple #8
0
        public IEnumerable <IDependencyInjector> Create()
        {
            var result = new List <IDependencyInjector>();

            foreach (var component in ComponentProvider.GetAll())
            {
                foreach (var type in component.Assembly.Types)
                {
                    if (!typeof(IDependencyInjector).IsAssignableFrom(type))
                    {
                        continue;
                    }

                    if (type.IsAbstract || type.IsInterface)
                    {
                        continue;
                    }

                    result.Add((IDependencyInjector)Instantiator.Instantiate(type));
                }
            }

            return(result);
        }
Exemple #9
0
        public IEnumerable <UIHintControlMapping> Create()
        {
            var result = new List <UIHintControlMapping>();

            foreach (var component in ComponentProvider.GetAll())
            {
                foreach (var type in component.Assembly.Types)
                {
                    var controlAttribute = type.GetCustomAttribute <ControlAttribute>();

                    if (controlAttribute == null)
                    {
                        continue;
                    }

                    foreach (var mapControlToUIHintAttribute in type.GetCustomAttributes <MapControlToUIHintAttribute>())
                    {
                        result.Add(new UIHintControlMapping(UIHintDefinitionParser.Parse(mapControlToUIHintAttribute.UIHintDefinition), controlAttribute.Id));
                    }
                }
            }

            return(result.AsReadOnly());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer"/> class.
 /// </summary>
 public HttpServer()
 {
     _components = new ComponentProvider();
     _requestQueue = new RequestQueue(ProcessRequestWrapper);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer"/> class.
 /// </summary>
 /// <param name="decoderProvider">Form decoders are used to convert different types of posted data to the <see cref="HttpInput"/> object types.</param>
 /// <param name="sessionStore">A session store is used to save and retrieve sessions</param>
 /// <param name="logWriter">The log writer.</param>
 /// <seealso cref="IFormDecoder"/>
 /// <seealso cref="FormDecoderProviders"/>
 /// <seealso cref="LogWriter"/>
 /// <seealso cref="IHttpSessionStore"/>
 public HttpServer(FormDecoderProvider decoderProvider, IHttpSessionStore sessionStore, ILogWriter logWriter)
 {
     Check.Require(decoderProvider, "decoderProvider");
     Check.Require(sessionStore, "sessionStore");
     _components = new ComponentProvider();
     _components.AddInstance<FormDecoderProvider>(sessionStore);
     _components.AddInstance<IHttpSessionStore>(sessionStore);
     if (logWriter != null)
         _components.AddInstance<ILogWriter>(logWriter);
     _requestQueue = new RequestQueue(ProcessRequestWrapper);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer"/> class.
 /// </summary>
 /// <param name="decoderProvider">Form decoders are used to convert different types of posted data to the <see cref="HttpInput"/> object types.</param>
 /// <param name="logWriter">The log writer.</param>
 /// <seealso cref="IFormDecoder"/>
 /// <seealso cref="FormDecoderProviders"/>
 /// <seealso cref="LogWriter"/>
 public HttpServer(FormDecoderProvider decoderProvider, ILogWriter logWriter)
 {
     Check.Require(decoderProvider, "decoderProvider");
     Check.Require(logWriter, "logWriter");
     _components = new ComponentProvider();
     _components.AddInstance<FormDecoderProvider>(decoderProvider);
     _requestQueue = new RequestQueue(ProcessRequestWrapper);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer"/> class.
 /// </summary>
 /// <param name="sessionStore">A session store is used to save and retrieve sessions</param>
 /// <seealso cref="IHttpSessionStore"/>
 public HttpServer(IHttpSessionStore sessionStore)
 {
     Check.Require(sessionStore, "sessionStore");
     _components = new ComponentProvider();
     _components.AddInstance<IHttpSessionStore>(sessionStore);
     _requestQueue = new RequestQueue(ProcessRequestWrapper);
 }
Exemple #14
0
 public DateTime GetLastPublishedDate(string uri)
 {
     return(ComponentProvider.GetLastPublishedDate(uri));
 }