コード例 #1
0
        public ServiceHandler(IServiceContainer context)
        {
            fileBc = context.GetService(typeof(IFileBc)) as IFileBc;
            if (fileBc == null)
            {
                throw new ComponentNotFoundException("IFileBc not found");
            }

            directoryBc = context.GetService(typeof(IDirectoryBc)) as IDirectoryBc;
            if (directoryBc == null)
            {
                throw new ComponentNotFoundException("IDirectoryBc not found");
            }
        }
コード例 #2
0
        private static IServiceContainer InitContainer(IServiceFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            IServiceContainer container   = factory.CreateContainer();
            IFileBc           fileBc      = factory.CreateFileComponent();
            IDirectoryBc      directoryBc = factory.CreateDirectoryComponent();

            container.Add(fileBc, "fileComponent");
            container.Add(directoryBc, "directoryComponent");

            return(container);
        }