示例#1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     BootStrap.Configure(services, Configuration.GetConnectionString("DefaultConnection"));
     services.AddMvc(x => {
         x.Filters.Add(typeof(CustomExceptionFilter));
     });
 }
示例#2
0
 public DataService()
 {
     if (_container == null)
     {
         _container = BootStrap.BuildContainer();
     }
 }
示例#3
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            this.Dispatcher.UnhandledException += DispatcherOnUnhandledException;
            var loadingWindow = new LoadingWindow();

            loadingWindow.Show(null, MiscStrings.CheckingConfiguration, MiscStrings.Initialising);
            var initResult = await BootStrap.CheckConfigurationAndInit();

            _container = initResult.container;
            if (!initResult.ConfigResult.Success)
            {
                MessageBox.Show(string.Join(Environment.NewLine, initResult.ConfigResult.Errors),
                                MiscStrings.LoadErrorCaption);
                Shutdown();
                return;
            }
            loadingWindow.SetStatus(MiscStrings.CheckingForNewVersion);
            var release = await _container.GetInstance <IVersionChecker>().GetLatestVersion();

            if (release.NewVersion)
            {
                MessageBox.Show(release.Release.ChangeLog, "New version " + release.Release.TagName + " is available!");
            }
            loadingWindow.Hide();
            _container.Configure(c => c.For <ILoadingWindow>().Use(loadingWindow).Singleton());
            var windowProvider = _container.GetInstance <IWindowProvider>();

            windowProvider.CreateWindow <IDeployment>().Show();
        }
    protected override void OnUpdate()
    {
        for (int i = 0; i < data.Length; ++i)
        {
            Entity         spawnedEntity = data.Entities[i];
            PizzaSpawnData spawnData     = data.SpawnData[i];

            PostUpdateCommands.RemoveComponent <PizzaSpawnData>(spawnedEntity);

            PostUpdateCommands.AddSharedComponent(spawnedEntity, spawnData.PizzaGroup);
            PostUpdateCommands.AddComponent(spawnedEntity, spawnData.Position);
            IngredientList ingredientList = new IngredientList {
                Value = generatePizzaIngredients()
            };
            PostUpdateCommands.AddSharedComponent(spawnedEntity, ingredientList);

            PostUpdateCommands.AddComponent(spawnedEntity, new Pizza {
            });
            PostUpdateCommands.AddComponent(spawnedEntity, new Heading2D {
                Value = new float2(0, -1)
            });
            PostUpdateCommands.AddComponent(spawnedEntity, default(TransformMatrix));
            PostUpdateCommands.AddSharedComponent(spawnedEntity, BootStrap.PizzaLook);

            PostUpdateCommands.AddComponent(spawnedEntity, getPizzaCost(ingredientList));

            BootStrap.SetPizzaOrderUIIngredients(ingredientList.Value, spawnData.PizzaGroup.PizzaId);
        }
    }
示例#5
0
        public void TestListenEndPointReplacement()
        {
            CreateBootstrap("Basic.config");

            var endPointReplacement = new Dictionary <string, IPEndPoint>(StringComparer.OrdinalIgnoreCase);

            endPointReplacement.Add("TestServer_2012", new IPEndPoint(IPAddress.Any, 3012));

            BootStrap.Initialize(endPointReplacement);

            var appServer = BootStrap.AppServers.OfType <IAppServer>().FirstOrDefault();

            Assert.AreEqual(1, appServer.Listeners.Length);

            Assert.AreEqual(3012, appServer.Listeners[0].EndPoint.Port);

            CreateBootstrap("Listeners.config");

            endPointReplacement = new Dictionary <string, IPEndPoint>(StringComparer.OrdinalIgnoreCase);
            endPointReplacement.Add("TestServer_2012", new IPEndPoint(IPAddress.Any, 3012));
            endPointReplacement.Add("TestServer_2013", new IPEndPoint(IPAddress.Any, 3013));

            BootStrap.Initialize(endPointReplacement);

            appServer = BootStrap.AppServers.OfType <IAppServer>().FirstOrDefault();

            Assert.AreEqual(2, appServer.Listeners.Length);

            Assert.AreEqual(3012, appServer.Listeners[0].EndPoint.Port);
            Assert.AreEqual(3013, appServer.Listeners[1].EndPoint.Port);
        }
示例#6
0
    //copy pasta is bad, but I'm trying to do this quickly.
    private BaseEntity FindClosest(BaseEntity actor, string targetTag)
    {
        int        count       = _entities.Count;
        BaseEntity closest     = null;
        float      closestDist = -1;

        for (int i = 0; i < count; ++i)
        {
            BaseEntity target = _entities[i];
            if (!target.HasTag(targetTag))
            {
                continue;
            }

            float dist = BootStrap.DistSqrd(actor.transform.position, target.transform.position);

            if (closestDist == -1 || dist < closestDist)
            {
                closest     = target;
                closestDist = dist;
            }
        }

        return(closest);
    }
示例#7
0
 public ReminderManager()
 {
     BootStrap.Config();
     _ticketsApp     = new TicketsApplication();
     _usersApp       = new UserApplication();
     _projectApp     = new ProjectApplication();
     _historyManager = new ReminderHistoryManager();
 }
示例#8
0
        public void By_default_token_parser_is_the_configured_template_parser(IContainer container)
        {
            "Given we have bootstraped the IoC"
            ._(() => container = BootStrap.Start());

            "Then it should resolve the token template parser"
            ._(() => container.Resolve <ITemplateParser>().Should().BeOfType <TokenTemplateParser>());
        }
示例#9
0
 public TestBase()
 {
     if (BootStrapper == null)
     {
         BootStrapper = new BootStrap();
         SetupData();
     }
 }
示例#10
0
 public bool ReadBootStrap(BootStrap info)
 {
     info.Version = ReadByte();
     info.Flags = EReadInt24();
     info.BootStrapVersion = EReadInt32();
     byte flags = ReadByte();
     info.ProfileType = (flags & 0xc0) >> 6;
     if ((flags & 0x20) == 0x20)
     {
         info.Live = true;
         info.HasMetadata = false;
     }
     info.IsUpdate = ((flags & 0x10) == 0x10);
     if (!info.IsUpdate)
     {
         info.SegmentTables = new Dictionary<int, Segment>();
         info.FragmentTables = new Dictionary<int, Fragment>();
     }
     info.Timescale = EReadInt32();
     info.CurrentMediaTime = EReadInt64();
     info.SmpteTimeCodeOffset = EReadInt64();
     info.MovieIdentifier = EReadString();
     int cnt = ReadByte();
     info.ServerEntryTable = new List<string>();
     for (int x = 0; x < cnt; x++)
         info.ServerEntryTable.Add(EReadString());
     cnt = ReadByte();
     info.QualityEntryTable = new List<string>();
     for (int x = 0; x < cnt; x++)
         info.QualityEntryTable.Add(EReadString());
     info.DrmData = ReadString();
     info.MetaData = ReadString();
     cnt = ReadByte();
     for (int x = 0; x < cnt; x++)
     {
         string name;
         long left = ReadHeader(out name);
         if (name == "asrt")
             ReadSegment().ToList().ForEach(a => info.SegmentTables[a.Key] = a.Value);
         else
             BaseStream.Seek(left, SeekOrigin.Current);
     }
     cnt = ReadByte();
     for (int x = 0; x < cnt; x++)
     {
         string name;
         long left = ReadHeader(out name);
         if (name == "afrt")
             ReadFragment().ToList().ForEach(a => info.FragmentTables[a.Key] = a.Value);
         else
             BaseStream.Seek(left, SeekOrigin.Current);
     }
     info.SegmentTables = info.SegmentTables.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value);
     info.FragmentTables = info.FragmentTables.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value);
     info.InitFragments();
     return true;
 }
示例#11
0
 public PaymentCheck()
 {
     BootStrap.Config();
     paymentManagerEmail = ConfigurationManager.AppSettings["PaymentManagerEmail"];
     teamEmail           = ConfigurationManager.AppSettings["TeamEmail"];
     proposalTrackerApp  = new ProposalTrackerApplication();
     projectApp          = new ProjectApplication();
     _invoicesApp        = new InvoicesApplication();
 }
示例#12
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            BootStrap.Init();
        }
示例#13
0
        public async Task Setup(BootStrap strap, System.Action <IManager> onSetup, System.Action <IManager> onFail)
        {
            Debug.LogFormat("<color=green>{0}</color> start at {1}", name, Time.fixedTime);

            Task  setup = Task.Delay(setupTimeMS);
            await setup;

            Debug.LogFormat("<color=green>{0}</color> end at {1}", name, Time.fixedTime);
            onSetup(this);
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     BootStrap.Start();
     worker = new BackgroundWorker();
     worker.WorkerReportsProgress = true;
     worker.DoWork             += worker_DoWork;
     worker.ProgressChanged    += worker_ProgressChanged;
     worker.RunWorkerCompleted += worker_RunWorkerCompleted;
     worker.RunWorkerAsync();
 }
示例#15
0
        static void Main()
        {
            BootStrap.Configure();
            IControllerFactory lContFactory = BootStrap.GetControllerFactory();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new ModoAdministrador(lContFactory));
            Application.Run(new Player());
        }
示例#16
0
    public bool IsInRange(Transform other)
    {
        if (other == null)
        {
            return(false);
        }

        float dist = BootStrap.DistSqrd(transform.position, other.position);

        return((_attackRange * _attackRange) >= dist);
    }
示例#17
0
        protected void Application_Start()
        {
            MvcHandler.DisableMvcResponseHeader = true;
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            BootStrap.Build();
        }
示例#18
0
        private bool TestMaxConnectionNumber(int maxConnectionNumber)
        {
            var configSource = SetupBootstrap(DefaultServerConfig, new Func<IServerConfig, IServerConfig>(c =>
                {
                    var nc = new ServerConfig(c);
                    nc.MaxConnectionNumber = maxConnectionNumber;
                    return nc;
                }));

            BootStrap.Start();

            var config = configSource.Servers.FirstOrDefault();
            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), config.Port);

            List<Socket> sockets = new List<Socket>();

            var server = BootStrap.AppServers.FirstOrDefault();

            try
            {
                for (int i = 0; i < maxConnectionNumber; i++)
                {
                    Socket socket = CreateClientSocket();
                    socket.Connect(serverAddress);
                    Stream socketStream = GetSocketStream(socket);
                    StreamReader reader = new StreamReader(socketStream, m_Encoding, true);
                    reader.ReadLine();
                    sockets.Add(socket);
                }

                Assert.AreEqual(maxConnectionNumber, server.SessionCount);

                Assert.IsFalse(TryConnect(serverAddress));

                sockets[0].SafeClose();

                Thread.Sleep(500);

                Assert.AreEqual(maxConnectionNumber - 1, server.SessionCount);

                return TryConnect(serverAddress);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + " " + e.StackTrace);
                throw e;
            }
            finally
            {
                ClearBootstrap();
            }
        }
示例#19
0
    private void Awake()
    {
        bootstrap = FindObjectOfType <BootStrap>();
        if (bootstrap != null && bootstrap.IsLoadWorld)
        {
            GenerateLoadWorld();
        }
        else
        {
            GenerateTexture();
        }

        //calls it so generation is done before the camera renders
    }
示例#20
0
    private void TrySpawnUnit()
    {
        if (entityManager == null)
        {
            return;
        }

        if (_lastSpawnTime == -1 || BootStrap.EpochNow() - _lastSpawnTime > _spawnTimeMS)
        {
            _lastSpawnTime = BootStrap.EpochNow();
            var unit = GameObject.Instantiate(_spawnPrefab, transform.position, Quaternion.identity, transform.parent);
            unit.name = "Unit";
        }
    }
        public void Xml_help_provider_is_configured_as_the_default_help_provider(IContainer container)
        {
            "Given we have bootstraped the IoC"
            ._(() => container = BootStrap.Start());

            "Then it should resolve the help provider to be an xml help provider"
            ._(() => container.Resolve <IHelpProvider>().Should().BeOfType <XmlHelpProvider>());

            "And it should be a singleton instance" // Is there a better way to verify lifecycle in Autofac?
            ._(
                () =>
                ReferenceEquals(container.Resolve <IHelpProvider>(),
                                container.Resolve <IHelpProvider>())
                .Should().BeTrue());
        }
示例#22
0
    private void TryAttack()
    {
        if (entityManager == null)
        {
            return;
        }

        double now = BootStrap.EpochNow();

        if (_lastAttacked == -1 || now - _lastAttacked >= _attackRateMS)
        {
            _lastAttacked = now;
            Attack();
        }
    }
示例#23
0
        protected void Application_Start()
        {
            SFConfig.Init();
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            ConfigLog4net();
            GlobalDataBusiness.SetGolbalData();

            BootStrap.Config();
        }
示例#24
0
        public void command_module_registration(IContainer container)
        {
            "Given we have bootstraped the IoC"
            ._(() => container = BootStrap.Start());

            "Then it should resolve the help command"
            ._(() => container.Resolve <IEnumerable <ICraneCommand> >().Any(item => item.GetType() == typeof(Help)).Should().BeTrue());

            "And it should be a singleton instance" // Is there a better way to verify lifecycle in Autofac?
            ._(
                () =>
                ReferenceEquals(container.Resolve <IEnumerable <ICraneCommand> >().First(item => item.GetType() == typeof(Help)),
                                container.Resolve <IEnumerable <ICraneCommand> >().First(item => item.GetType() == typeof(Help)))
                .Should().BeTrue());
        }
示例#25
0
        void TestAddServerInRuntimeImplement()
        {
            StartBootstrap(DefaultServerConfig);
            var bootstrap = BootStrap as IDynamicBootstrap;

            var options = new NameValueCollection();

            options["testAtt1"] = "1";
            options["testAtt2"] = "2";

            Assert.IsTrue(bootstrap.AddAndStart(new ServerConfig
            {
                Name       = "TestDynamicServer",
                ServerType = "SuperSocket.Test.TestServer, SuperSocket.Test",
                Port       = 2013,
                Options    = options
            }));

            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2013);

            using (Socket socket = CreateClientSocket())
            {
                try
                {
                    socket.Connect(serverAddress);
                }
                catch
                {
                    Assert.Fail("Failed to connect to the dynamic created server.");
                }

                Stream socketStream = GetSocketStream(socket);
                using (StreamReader reader = new StreamReader(socketStream, m_Encoding, true))
                    using (ConsoleWriter writer = new ConsoleWriter(socketStream, m_Encoding, 1024 * 8))
                    {
                        string welcomeString = reader.ReadLine();
                        Assert.AreEqual(string.Format(TestSession.WelcomeMessageFormat, "TestDynamicServer"), welcomeString);
                        var line = Guid.NewGuid().ToString();
                        writer.WriteLine("ECHO " + line);
                        writer.Flush();

                        Assert.AreEqual(line, reader.ReadLine());
                    }
            }

            BootStrap.GetServerByName("TestDynamicServer").Stop();
            bootstrap.Remove("TestDynamicServer");
        }
示例#26
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            BootStrap.Initialize(services);

            services.AddControllers()
            .AddNewtonsoftJson(
                options => options.SerializerSettings.Culture = CultureInfo.CurrentCulture
                );

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Chatbot", Version = "v1"
                });
            });
        }
示例#27
0
        public async Task Setup(BootStrap bootstrap, System.Action <IManager> onSetup, System.Action <IManager> onSetupFail)
        {
            PromiseChain promise = new PromiseChain();

            if (_layerRoot == null)
            {
                promise.Then(LoadUICamera);
            }
            if (_layerPrefab == null)
            {
                promise.Then(LoadDeviceFrame);
            }
            await promise.Exec();

            SetupInternal();

            onSetup(this);
        }
示例#28
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Starting in console mode...");
            var initResult = BootStrap.CheckConfigurationAndInit().GetAwaiter().GetResult();

            if (!initResult.ConfigResult.Success)
            {
                initResult.container.Configure(c =>
                {
                    c.For <IConsoleDoJob>().Use <ConsoleDoJob>();
                });
                System.Console.Write(string.Join(Environment.NewLine, initResult.ConfigResult.Errors));
                return;
            }
            var container = initResult.container;

            Parser.Default.ParseArguments <OctoPlusOptions>(args).WithParsed(opts => RunConsole(container, opts));
        }
示例#29
0
 public void Start()
 {
     TimerDI = new TimerCollection(); //创建容器
     try {
         BootStrap boot = new BootStrap();
         TimerDI = boot.Boot();
         foreach (string key in TimerDI.Timers.Keys) {
             TimerDI.Timers[key].Start();
         }
         if (_OnSuccess != null)
             _OnSuccess();
     }
     catch (Exception ex) {
         Dispose();
         if (_OnFail != null)
             _OnFail(ex);
         else
             throw ex;
     }
 }
示例#30
0
        public void Upload_ValidProdutFile_ProductsCreated(string partner, string startBy, string expected)
        {
            //string productContractInput = $@"{GetAssemblyDirectory()}\TestData\MusicContract.txt";
            //ProductCreateController prodCreatecontroller = new ProductCreateController();
            //prodCreatecontroller.Upload(productContractInput);

            //string partnerContractInput = $@"{GetAssemblyDirectory()}\TestData\PartnerContract.txt";
            //PartnerCreateController partnerCreatorController = new PartnerCreateController();
            //partnerCreatorController.Upload(partnerContractInput);

            BootStrap bs = new BootStrap();

            //Initialise database with default data from the local file
            bs.Init(null);

            //Execute the search
            var actual = bs.Execute(partner, startBy);

            Assert.IsTrue(actual.StartsWith(expected));
        }
示例#31
0
        public void TestMethod1()
        {
            BootStrap.Init();
            //    ConfigurationHelper.SetConsoleLogger();
            LogUtil.Error("asdf");
            DemoRepository demoRep = new DemoRepository(new DataAccessFactory());

            #region ÐÂÔö
            Demo newDemo = new Demo()
            {
                FAge = 1, FBirthday = DateTime.Now, FName = "test1"
            };
            demoRep.Insert(newDemo);
            #endregion

            #region ²éѯ
            var list     = demoRep.QueryList(x => x.FName == "test1");
            var jsonList = new NewtonsoftJsonSerializer().GetJsonByObj(list);
            Console.WriteLine(jsonList);
            #endregion
        }
    private void updatePizzaCost(int pizzaIndex)
    {
        List <int> currentIngredients = getIngredientsOnPizza(pizzaIndex);

        PizzaCost      pizzaCost      = pizzaData.PizzaCost[pizzaIndex];
        IngredientList ingredientList = pizzaData.PizzaOrder[pizzaIndex];

        List <int> missingIngredients = ingredientList.Value.Except <int>(currentIngredients).ToList();
        List <int> extraIngredients   = currentIngredients.Except <int>(ingredientList.Value).ToList();

        var actualCost = pizzaCost.OrderCost - missingIngredients.Count * 5 - extraIngredients.Count * 5;

        pizzaCost.ActualCost            = actualCost;
        pizzaData.PizzaCost[pizzaIndex] = pizzaCost;

        // Legacy
        BootStrap.SetPizzaOrderUIPrice(
            (float)pizzaCost.ActualCost / 100,
            pizzaData.PizzaGroup[pizzaIndex].PizzaId
            );
    }
 public async Task Start(string baseurl, string guid, Manifest manifest, Media media, CancellationToken token,IProgress<double> progress)
 {
     this.media = media;
     this.guid = guid;
     this.baseurl = baseurl;
     this.bootstrap = media.Info.Info;
     this.manifest = manifest;
     await InitFile();
     await DoNextFragment();
     progress.Report((double)bootstrap.CurrentFragmentWrite * 100D/(double)bootstrap.FragmentCount);
     token.ThrowIfCancellationRequested();
     await ThreadProcessor(token, progress);
     token.ThrowIfCancellationRequested();
 }