public T GetDefault(Characteristics characteristics)
        {
            if (characteristics == null)
            {
                throw new InvalidOperationException("Can't have a null characteristics; use Characteristics.None");
            }

            //default exitst
            if (DefaultInitialized && Default.IsValueCreated)
            {
                if (DefaultCharacteristics == characteristics)
                {
                    return(Default.Value);
                }

                throw new InvalidOperationException("unmatched Default Characteristics for existing default");
            }

            //default is prepped
            if (DefaultCharacteristics == characteristics && Default != null)
            {
                return(Default.Value);
            }

            //initialize
            if (FactoryMethods.ContainsKey(characteristics))
            {
                InitializeDefault(() => FactoryMethods[characteristics](Factory()));
                return(Default.Value);
            }
            else
            {
                throw new InvalidOperationException("un understood set to characteristics, no factory method found");
            }
        }
Ejemplo n.º 2
0
        private void Load()
        {
            // Pre clean up
            _directoryChangeNotifier.ClearListeners();

            var configData = Config.Load(DTE.Solution.GetDirectory());

            foreach (var settingData in configData?.TriggerGroups)
            {
                string generatorPath = configData.GetGeneratorPath(settingData.GeneratorName);
                AssemblyExtensions.CopyDlls(generatorPath, DTE.Solution.GetDirectory());

                if (settingData.Triggers.Count == 0)
                {
                    continue;
                }

                Project project = DTE.Solution.FindProject(settingData.UniqueProjectName);
                var     directoryChangeListener = FactoryMethods.GetRelativeDirectoryChangeListener(project.GetDirectory());
                var     generatorRunner         = new GeneratorRunner(generatorPath,
                                                                      settingData.UniqueProjectName, settingData.EntitasCfgPath, settingData.EntitasUserCfgPath);
                directoryChangeListener.Add(settingData.Triggers.ToArray());
                directoryChangeListener.Changed += () => generatorRunner.Run();
                _directoryChangeNotifier.AddListener(directoryChangeListener);
            }
        }
Ejemplo n.º 3
0
        public void Initialization_of_MdTableRow_using_FactoryMethods()
        {
            _ = FactoryMethods.Row();

            _ = FactoryMethods.Row("Cell 1", "Cell2");
            _ = FactoryMethods.Row(FactoryMethods.Text("Cell 1"), FactoryMethods.Text("Cell2"));
            _ = FactoryMethods.Row(new[] { FactoryMethods.Text("Cell 1"), FactoryMethods.Text("Cell2") });
            _ = FactoryMethods.Row(FactoryMethods.CompositeSpan("Cell 1", "Cell 1 continued"));
        }
Ejemplo n.º 4
0
 public static void Main()
 {
     using (IWindsorContainer container = new WindsorContainer())
     {
         FactoryMethods.RegisterFactories(container);
         container.Install(FromAssembly.This());
         container.Resolve <Application>().Run();
     }
 }
Ejemplo n.º 5
0
        protected override void Initialize()
        {
            base.Initialize();

            // Get and set all services
            DTE = (DTE2)GetService(typeof(SDTE));
            RunningDocumentTable = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));
            VsSolution           = (IVsSolution)GetService(typeof(SVsSolution));

            var packageLoader = FactoryMethods.GetPackageLoader();

            packageLoader.AfterOpenSolution += PackageLoader_AfterOpenSolution;

            SettingsWindowCommand.Initialize(this);
        }
Ejemplo n.º 6
0
        public void Initialization_of_MdDocument_using_FactoryMethods()
        {
            _ = FactoryMethods.Document();

            _ = FactoryMethods.Document(FactoryMethods.Container());
            _ = FactoryMethods.Document(FactoryMethods.Container(), FactoryMethods.Container());

            _ = FactoryMethods.Document(FactoryMethods.ListItem(), FactoryMethods.ListItem());

            _ = FactoryMethods.Document(FactoryMethods.BlockQuote());
            _ = FactoryMethods.Document(FactoryMethods.BlockQuote(), FactoryMethods.BlockQuote());

            _ = FactoryMethods.Document(FactoryMethods.BulletList());
            _ = FactoryMethods.Document(FactoryMethods.OrderedList());

            _ = FactoryMethods.Document(MarkdownGenerator.Extensions.FactoryMethods.Admonition("note"));
        }
Ejemplo n.º 7
0
        public static void PlayerSetTarget(GameObject target)
        {
            Selectors.RemoveSelector("targeted");
            var objType = FactoryMethods.GetType(target);

            if (objType == FactoryObjectTypes.MONSTER)
            {
                UnityClient.Player.Target = target;
                Selectors.AddSelector(target, "targeted", Color.red);
                var path = UnityClient.Map.FindPath(UnityClient.Player.Position, target.GetMapPosition());
                if (path != null)
                {
                    UnityClient.Player.FollowingPath = path;
                    Selectors.HideSelector();
                }
            }
        }
Ejemplo n.º 8
0
        public void Initialization_of_MdStrongEmphasisSpan_using_FactoryMethods()
        {
            _ = FactoryMethods.StrongEmphasis(FactoryMethods.CompositeSpan());
            _ = FactoryMethods.StrongEmphasis(FactoryMethods.Text(""), FactoryMethods.Text(""));
            _ = FactoryMethods.StrongEmphasis("", "");
            _ = FactoryMethods.StrongEmphasis(new List <MdSpan>()
            {
                FactoryMethods.Text(""), FactoryMethods.Text("")
            });

            _ = FactoryMethods.Bold(FactoryMethods.CompositeSpan());
            _ = FactoryMethods.Bold(FactoryMethods.Text(""), FactoryMethods.Text(""));
            _ = FactoryMethods.Bold("", "");
            _ = FactoryMethods.Bold(new List <MdSpan>()
            {
                FactoryMethods.Text(""), FactoryMethods.Text("")
            });
        }
Ejemplo n.º 9
0
        public void Initialization_of_MdListItem_using_FactoryMethods()
        {
            _ = FactoryMethods.ListItem();

            _ = FactoryMethods.ListItem(FactoryMethods.Container());
            _ = FactoryMethods.ListItem(FactoryMethods.Container(), FactoryMethods.Container());

            _ = FactoryMethods.ListItem(FactoryMethods.ListItem());
            _ = FactoryMethods.ListItem(FactoryMethods.ListItem(), FactoryMethods.ListItem());

            _ = FactoryMethods.ListItem(FactoryMethods.BlockQuote());
            _ = FactoryMethods.ListItem(FactoryMethods.BlockQuote(), FactoryMethods.BlockQuote());

            _ = FactoryMethods.ListItem(FactoryMethods.BulletList());
            _ = FactoryMethods.ListItem(FactoryMethods.OrderedList());

            _ = FactoryMethods.ListItem(Extensions.FactoryMethods.Admonition("note"));
        }
Ejemplo n.º 10
0
        protected override void ConfigureRequestContainer(IContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            container.Configure(cfg => {
                // start context
                cfg.For <DbContext>().Use <DailyTrackerContext>();

                // strategies
                cfg.For <IEntityPredicate>().Use <EntityPredicate>();

                // hasher
                cfg.For <IHash>().Use <MD5HashAdapter>();

                // register repos
                var loggerProxyFactory = container.GetInstance <LoggerProxyFactory>();
                var timerProxyFactory  = container.GetInstance <TimerProxyFactory>();

                // questionnaires
                cfg.For <IRead <Questionnaire> >().Use <QuestionnaireRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <IDelete <Questionnaire> >().Use <QuestionnaireRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <ISave <Questionnaire> >().Use <QuestionnaireRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));

                // questions
                cfg.For <IRead <Question> >().Use <QuestionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <IDelete <Question> >().Use <QuestionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <ISave <Question> >().Use <QuestionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));

                // options
                cfg.For <IRead <Option> >().Use <OptionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <IDelete <Option> >().Use <OptionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));
                cfg.For <ISave <Option> >().Use <OptionRepository>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));

                // users
                cfg.For <IRead <User> >().Use <UserRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));
                cfg.For <IDelete <User> >().Use <UserRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));
                cfg.For <ISave <User> >().Use <UserRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));

                // answers
                cfg.For <IRead <Answer> >().Use <AnswerRepository>().DecorateWith(a => loggerProxyFactory.Create(timerProxyFactory.Create(a)));
                cfg.For <IDelete <Answer> >().Use <AnswerRepository>().DecorateWith(a => loggerProxyFactory.Create(timerProxyFactory.Create(a)));
                cfg.For <ISave <Answer> >().Use <AnswerRepository>().DecorateWith(a => loggerProxyFactory.Create(timerProxyFactory.Create(a)));

                // user directory
                cfg.For <IRead <UserDirectory> >().Use <UserDirectoryRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));
                cfg.For <ISave <UserDirectory> >().Use <UserDirectoryRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));
                cfg.For <IDelete <UserDirectory> >().Use <UserDirectoryRepository>().DecorateWith(u => loggerProxyFactory.Create(timerProxyFactory.Create(u)));

                // unit of work
                cfg.For <IUnitOfWork>().Use <UnitOfWork>().DecorateWith(q => loggerProxyFactory.Create(timerProxyFactory.Create(q)));;

                // mediator
                cfg.For <IHub>().Use <Hub>();

                // route handling
                cfg.For <RouteHandlerFactory>().Use <RouteHandlerFactory>();

                var cacheProxyFactory = container.GetInstance <CacheProxyFactory>();

                cfg.For <SingleInstanceFactory>().Use <SingleInstanceFactory>(ctx => t => cacheProxyFactory.Create(FactoryMethods.Execute(() => ctx.GetInstance(t))));
                cfg.For <MultiInstanceFactory>().Use <MultiInstanceFactory>(ctx => t => ctx.GetAllInstances(t));

                // jwt
                cfg.For <ITokenGenerator>().Use <TokenGenerator>();
            });
        }