Example #1
0
        private static IUnityContainer BuildUnityContainer()
        {
            IUnityContainer container = new UnityContainer();

            InjectFactory.SetContainer(container.CreateChildContainer());

            RegisterTypes(container);

            return(container);
        }
Example #2
0
        public static void Build(IUnityContainer container)
        {
            InjectFactory.SetContainer(container);

            //Assembly[] assemblies = BuildManager.GetReferencedAssemblies().OfType<Assembly>().ToArray();

            //container.RegisterTypes(
            //    AllClasses.FromLoadedAssemblies()
            //        .Where(
            //            a =>
            //                a.FullName.StartsWith("AppUsage")
            //        //a.FullName.StartsWith("AppUsage") &&
            //        //(a.FullName.EndsWith("Business") || a.FullName.EndsWith("Application"))
            //        ),
            //        WithMappings.FromMatchingInterface,
            //        WithName.Default,
            //        WithLifetime.Hierarchical);

            buildContext(container, new HierarchicalLifetimeManager());
            buildInfrastructure(container, new HierarchicalLifetimeManager());
            buildBusinessServices(container, new HierarchicalLifetimeManager());
            buildApplicationServices(container, new HierarchicalLifetimeManager());
        }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                Bootstrapper.Initialize();
                fileHandler = InjectFactory.Resolve <IFileHandler>();
                wordEngine  = InjectFactory.Resolve <IWordEngine <IWord> >();

                Word   startWord;
                Word   targetWord;
                int    wordsLength = Convert.ToInt32(ConfigurationManager.AppSettings.Get("WordsLenght"));
                string filePath    = ConfigurationManager.AppSettings.Get("InputFilePath");
                string resultfile;

                Console.WriteLine(string.Format("Enter start word: "));
                startWord = new Word(Console.ReadLine());

                Console.WriteLine(string.Format("Enter target Word: "));
                targetWord = new Word(Console.ReadLine());
                Console.WriteLine(Environment.NewLine);

                if (!startWord.HasSameLength(targetWord))
                {
                    Console.WriteLine("Both words need to have same lenght.");
                }

                if (!startWord.IsValid() && !targetWord.IsValid())
                {
                    throw new Exception("One words is invalid.");
                }

                if (startWord.Value.Length != wordsLength || targetWord.Value.Length != wordsLength)
                {
                    throw new Exception($"Both words need to have {wordsLength} of length");
                }

                resultfile = startWord.Value + targetWord.Value + ".txt";

                originalWords = fileHandler.LoadDictionaryContent(wordsLength).ToList()
                                .Select(x => new Word(x.ToLower())).ToList();

                Console.WriteLine($"Word dictionary: {filePath} Loaded");

                WordEngine          engine = new WordEngine();
                IEnumerable <IWord> sPath  = engine.FindPath(startWord, targetWord, originalWords);

                sPath.ToList().ForEach(x => Console.WriteLine(x.Value));

                IEnumerable <string> output = sPath.Select(x => x.Value);

                fileHandler.SaveOutputFile(resultfile, output);

                Console.WriteLine($"Output file is {resultfile}");
                Console.WriteLine("Press some key to exit");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #4
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            InjectFactory.Resolve <IDbContext>().Initialize();
        }