internal LoadBalanderInterceptor(Func <T> builder, BalancingOption balancingOption, ActorFactory actorFactory, int parrallelLimitation) { _Builder = builder; _ParrallelLimitation = parrallelLimitation; _ActorFactory = actorFactory; _BalancingOption = balancingOption; }
static void Main(string[] args) { Console.WriteLine("!! Hello, start initialization..."); IRuleLibrary r = new RuleLibrary12Hour(); var dataManager = new DataManager(); var factory = new ActorFactory(dataManager.ActorProvider); var actorManager = new ActorManager(); actorManager.Initiate(dataManager.CurrencyProvider, dataManager.ActorProvider); while (true) { var command = Console.ReadLine(); if (command == "clear") { actorManager.ClearOldActorsData(); break; } if (command == "restart") { actorManager.ClearOldActorsData(); actorManager = new ActorManager(); actorManager.Initiate(dataManager.CurrencyProvider, dataManager.ActorProvider); } } // Console.WriteLine("Finished!!"); Console.ReadKey(); }
public async Task <IHttpActionResult> AddPoseCommand(long id, int x, int y, int z, long t) { var armActor = ActorFactory.GetArm(id); await armActor.AddPoseTaskAsync(x, y, z, t); return(Ok()); }
public async Task <bool> WaitProb(long id) { var armActor = ActorFactory.GetArm(id); var result = await armActor.WaitingProbResultAsync(); return(result); }
public async Task <IHttpActionResult> ConvertTouchPointToPose(long id, double x, double y) { var armActor = ActorFactory.GetArm(id); var result = await armActor.ConvertTouchPointToPoseAsync(x, y); return(Ok <PosePosition>(result)); }
public async Task <IHttpActionResult> NewTask(long id, string taskName) { var armActor = ActorFactory.GetArm(id); await armActor.AddNextTaskAsync(taskName); return(Ok()); }
public async Task <IHttpActionResult> ConvertPoseToCoordinate(long id, int x, int y, int z) { var armActor = ActorFactory.GetArm(id); var result = await armActor.ConvertPositionToCoordinatAsync(x, y, z); return(Ok <double[]>(new[] { result.Item1, result.Item2, result.Item3 })); }
public async Task <IHttpActionResult> ConvertCoordinateToPose(long id, double x, double y, double z) { var armActor = ActorFactory.GetArm(id); var result = await armActor.ConvertCoordinatToPositionAsync(x, y, z); return(Ok <PosePosition>(result)); }
public virtual void Install(StoryContext context) { context.AssetSource = new ResourceAssetManager(); var scenarioRepository = new ScenarioRepository(); scenarioRepository.AddScript(scenario.name, scenario.text); context.ScenarioRepository = scenarioRepository; context.VariableRepository = new TempVariableRepository(); context.ScenarioMacroRepository = new ScenarioMacroRepository(); var actorFactory = new ActorFactory <SpriteActor>(); context.ActorFactory = actorFactory; context.ScenePresenter = scenePresenter; context.ActorPresenter = actorPresenter; context.SystemSound = systemSound; audioPlayer.assetSource = context.AssetSource; context.AudioPlayer = audioPlayer; context.MessagePresenter = messagePresenter; context.SystemPresenter = scenePresenter; context.SelectionPresenter = selectionPresenter; context.MessageLogger = messageLogPresenter; }
public override LogicPart Create() { var logicPart = new LogicPart(); var rules = new HommRules(); logicPart.CreateWorld = () => new HommWorld(pids.Take(playersCount).ToArray()); logicPart.CreateDefaultSettings = () => new Settings { OperationalTimeLimit = 5, TimeLimit = 90 }; logicPart.WorldStateType = typeof(HommWorldState); logicPart.CreateWorldState = seed => new HommWorldState(int.Parse(seed)); logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 5).Select(i => i.ToString())); var actorFactory = ActorFactory.FromRobot(new HommRobot(), rules); foreach (var pid in pids.Take(playersCount)) { logicPart.Actors[pid] = actorFactory; } logicPart.Bots[HommRules.StandingBotName] = () => new Bot <HommCommand>(_ => new HommCommand { Movement = new Wait() }); return(logicPart); }
private void addActorTypeMenu_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; ObjectCreator creator = item.Tag as ObjectCreator; if (creator != null) { try { NCheckResult hit; NEMainViewport activeViewport = this.ActiveViewport; if (activeViewport != null) { activeViewport.MouseRayCheck(out hit, activeViewport.RightMouseButtenDownPosition, 512 * 1024, LineCheckType.All); Point pt = activeViewport.Viewport.Camera.WorldToScreen(hit.location); ActorFactory factory = creator.CreateInstance() as ActorFactory; factory.CreateActor(NLevelEditorEngine.Instance.MainLevel, hit.location, Vector3.Zero); } } catch (System.Exception ex) { Program.ShowException(ex, "ActorFactory Create Error!"); } } }
public Entity FromSquadStartingLocation(ScenarioTag.AiSquadDefinition.StartingLocation loc) { var entity = ActorFactory.FromStartingLocation(this.Map, loc); loc.Actor = entity; return(entity); }
public ActorContextTest() { _ActorContext = new ActorContext(); var factory = new ActorFactory(); _Proxified = new DummyClass(); _Interface = factory.Build<IDummyInterface2>(_Proxified); }
public void ReadFromFile(string fileName, bool isBigEndian) { using (var fileStream = new MemoryStream(File.ReadAllBytes(fileName))) { EntityType = (ActorEDSTypes)fileStream.ReadInt32(isBigEndian); if (EntityType == ActorEDSTypes.C_Train) { MessageBox.Show(string.Format("Detected unsupported entity. The EntityStorageData will not load."), "Toolkit", MessageBoxButton.OK, MessageBoxImage.Error); return; } Hash = fileStream.ReadUInt64(isBigEndian); TableSize = fileStream.ReadInt32(isBigEndian); uint numTables = fileStream.ReadUInt32(isBigEndian); TableHashes = new ulong[numTables]; Tables = new IActorExtraDataInterface[numTables]; for (int i = 0; i < numTables; i++) { TableHashes[i] = fileStream.ReadUInt64(isBigEndian); } for (int i = 0; i < numTables; i++) { using (MemoryStream stream = new MemoryStream(fileStream.ReadBytes(TableSize))) { var item = ActorFactory.LoadEntityDataStorage(EntityType, stream, isBigEndian); Tables[i] = item; } } } }
public override LogicPart Create() { var logicPart = new LogicPart(); var rules = new HommRules(); logicPart.CreateWorld = () => new HommWorld(); logicPart.CreateDefaultSettings = () => new Settings { OperationalTimeLimit = 5, TimeLimit = 90 }; logicPart.WorldStateType = typeof(HommWorldState); logicPart.CreateWorldState = seed => new HommWorldState(int.Parse(seed)); logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 5).Select(i => i.ToString())); var actorFactory = ActorFactory.FromRobot(new HeroRobot(), rules); logicPart.Actors[TwoPlayersId.Left] = actorFactory; if (playersCount == 2) { logicPart.Actors[TwoPlayersId.Right] = actorFactory; } logicPart.Bots[HommRules.StandingBotName] = () => new Bot <HommCommand>(_ => new HommCommand()); return(logicPart); }
public void TestCreateActors_AppropriateToFaction() { var adj = new AdjectiveFactory(); var items = new ItemFactory(); var actors = new ActorFactory(); var world = new World(); var faction = new Faction("Fish overloards", FactionRole.Wildlife); world.Factions.Add(faction); world.ActorFactory = actors; world.ItemFactory = items; actors.Blueprints = new List <ActorBlueprint> { new ActorBlueprint() { Name = "Captain Haddock" } }; var room = new Room("Tank Bay", world, 't') { ControllingFaction = faction }; Assert.IsEmpty(room.Actors); actors.Create(world, room, faction, null); Assert.IsTrue(room.Actors.Any()); Assert.GreaterOrEqual(room.Actors.Count(a => a.FactionMembership.Contains(faction)), 1, "Expected room to be populated with some actors belonging to the controlling faction"); }
protected void SetupResponse(HttpResponseMessage response) { var sender = new FakeHttpRequestSender(); sender.SetupResponse(response); this.Actor = ActorFactory.CreateSomeActorWithApiCallAbility(sender); }
public async Task Test(bool TaskPool) { IActorFactory fact = new ActorFactory(t => t.Priority = _Priority); var One = new PingPonger("Bjorg"); IPingPonger Actor1 = fact.Build <IPingPonger>(One); var Two = new PingPonger("Lendl"); var fact2 = TaskPool ? new TaskPoolActorFactory() : fact; IPingPonger Actor2 = fact2.Build <IPingPonger>(Two); One.Ponger = Actor2; Two.Ponger = Actor1; var watch = new Stopwatch(); watch.Start(); await Actor1.Ping(); Thread.Sleep(10000); var lifeCyle = Actor2 as IActorCompleteLifeCycle; Task Task2 = (lifeCyle == null) ? TaskBuilder.Completed : lifeCyle.Abort(); await Task.WhenAll(((IActorCompleteLifeCycle)(Actor1)).Abort(), Task2); watch.Stop(); Console.WriteLine("Total Ping:{0} Total Time: {1}", One.Count, watch.Elapsed); Console.WriteLine(One.Count); Console.WriteLine(Two.Count); }
private void InitHeart(int index) { _hearts[index] = ActorFactory.CreateHeart(); _hearts[index].Transform.Parent = Transform; Instatiate(_hearts[index]); PlaceHeart(_hearts[index], index); }
/// <summary> /// Spawns a monster with given SNOId in given position. /// </summary> /// <param name="monsterSNOId">The SNOId of the monster.</param> /// <param name="position">The position to spawn it.</param> public void SpawnMonster(int monsterSNOId, Vector3D position) { var monster = ActorFactory.Create(this, monsterSNOId, new TagMap()); //monster.Scale = 1.35f; // this shoudln't be here monster.EnterWorld(position); }
public SubscriptionRouterService(IServiceBus bus, string network) { _peerUri = bus.ControlBus.Endpoint.Address.Uri; _network = network; _peerId = NewId.NextGuid(); _observers = new List <SubscriptionObserver>(); _listeners = new List <BusSubscriptionEventListener>(); _unregister = () => true; _peerUri = bus.ControlBus.Endpoint.Address.Uri; var connector = new BusSubscriptionConnector(bus); _peerCache = ActorFactory.Create <PeerCache>(x => { x.ConstructedBy((fiber, scheduler, inbox) => new PeerCache(fiber, scheduler, connector, _peerId, _peerUri)); x.UseSharedScheduler(); x.HandleOnPoolFiber(); }) .GetActor(); }
public void TestActorForWithNoParametersAndDefaults() { var definition = Definition.Has <TestInterfaceActor>(Definition.NoParameters); var address = World.AddressFactory.UniqueWith("test-actor"); var mailbox = new TestMailbox(); var actor = ActorFactory.ActorFor( World.Stage, World.DefaultParent, definition, address, mailbox, null, World.DefaultLogger); Assert.NotNull(actor); Assert.NotNull(actor.Stage); Assert.Equal(World.Stage, actor.Stage); Assert.NotNull(actor.LifeCycle.Environment.Parent); Assert.Equal(World.DefaultParent, actor.LifeCycle.Environment.Parent); Assert.NotNull(actor.LifeCycle.Environment); Assert.NotNull(actor.LifeCycle.Environment.Definition); Assert.Equal(definition, actor.LifeCycle.Environment.Definition); Assert.NotNull(actor.Address); Assert.Equal(address, actor.Address); Assert.NotNull(actor.LifeCycle.Environment.Mailbox); Assert.Equal(mailbox, actor.LifeCycle.Environment.Mailbox); }
/// <summary> /// Initializes a new instance of the <see cref="ActorUnitTestingRuntime"/> class. /// </summary> internal ActorUnitTestingRuntime(Configuration configuration, Type actorType, IRandomValueGenerator valueGenerator) : base(configuration, valueGenerator) { if (!actorType.IsSubclassOf(typeof(Actor))) { this.Assert(false, "Type '{0}' is not an actor.", actorType.FullName); } var id = new ActorId(actorType, null, this); this.Instance = ActorFactory.Create(actorType); IActorManager actorManager; if (this.Instance is StateMachine stateMachine) { actorManager = new StateMachineManager(this, stateMachine, Guid.Empty); } else { actorManager = new ActorManager(this, this.Instance, Guid.Empty); } this.ActorInbox = new EventQueue(actorManager); this.Instance.Configure(this, id, actorManager, this.ActorInbox); this.Instance.SetupEventHandlers(); this.LogWriter.LogCreateActor(this.Instance.Id, null, null); this.IsActorWaitingToReceiveEvent = false; }
public void Adding_an_actor_to_a_registry() { _auctionFactory = ActorFactory.Create(inbox => new Auction(inbox)); _auctionId = CombGuid.Generate(); ActorInstance auction = _auctionFactory.GetActor(); ActorRegistry registry = ActorRegistryFactory.New(x => { //x.Remote(r => r.ListenTo("rm://234.0.0.7:40001")); }); registry.Register(_auctionId, auction); var message = new MessageImpl<Bid>(new BidImpl(27.5m)); message.DestinationAddress = new Uri("urn:uuid:" + _auctionId.ToString("N")); registry.Send<Message<Bid>>(message); // need to proxy the channel with headers somehow... // untyped channel => channel mapper -> actor instance // DestinationAddress -> set by outbound channel proxy on message<> // SourceAddress -> set by outbound channel proxy when available (not likely) // ResponseAddress -> set by outbound channel for ResponseChannel on Request to map to channel // Id -> system assigned id // DestinationAddress = urn:actor:554FC958-4661-4FE9-94F5-21D190417BCC }
public void Should_bind_channels_for_each_method() { var subject = new Subject(); ActorFactory <Subject> factory = ActorFactory.Create <Subject>(x => { x.ConstructedBy(() => subject); x.ConnectPublicMethods(); x.ConnectPropertyChannels(); }); ActorRef actor = factory.GetActor(); subject.ShouldNotBeNull(); actor.Send <Message <A> >(); actor.Send <Request <B> >(); actor.Send <Response <C> >(); actor.Send <Message <D> >(); subject.FutureA.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); subject.FutureB.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); subject.FutureC.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); subject.FutureD.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); }
public TraceChannelImpl() { _factory = ActorFactory.Create(inbox => new TraceActor(inbox)); _inbox = _factory.GetActor(); _dispose = _inbox.ExitOnDispose(); }
public override Host Build() { if (ServiceBuilders.Count > 1) { throw new HostConfigurationException("A shelf can only have one service configured"); } ServiceBuilder builder = ServiceBuilders.Single(); _log.DebugFormat("[Shelf:{0}] Building Service: {1}", Description.Name, builder.Name); var controllerFactory = new ServiceControllerFactory(); ActorFactory <IServiceController> factory = controllerFactory.CreateFactory(inbox => { var publish = new PublishChannel(_channel, inbox); IServiceController service = builder.Build(inbox, publish); return(service); }); ActorRef instance = factory.GetActor(); _channel.Connect(x => x.AddChannel(instance)); // this creates the state machine instance in the shelf and tells the servicecontroller // to create the service instance.Send(new CreateService(Description.Name)); return(new ShelfHost(instance)); }
public async Task Test(bool TaskPool) { IActorFactory fact = new ActorFactory(t=>t.Priority=_Priority); var One = new PingPonger("Bjorg"); IPingPonger Actor1 = fact.Build<IPingPonger>(One); var Two = new PingPonger("Lendl"); var fact2 = TaskPool ? new TaskPoolActorFactory() : fact; IPingPonger Actor2 = fact2.Build<IPingPonger>(Two); One.Ponger = Actor2; Two.Ponger = Actor1; var watch = new Stopwatch(); watch.Start(); await Actor1.Ping(); Thread.Sleep(10000); var lifeCyle = Actor2 as IActorCompleteLifeCycle; Task Task2 = (lifeCyle == null) ? TaskBuilder.Completed : lifeCyle.Abort(); await Task.WhenAll(((IActorCompleteLifeCycle)(Actor1)).Abort(), Task2); watch.Stop(); Console.WriteLine("Total Ping:{0} Total Time: {1}", One.Count, watch.Elapsed); Console.WriteLine(One.Count); Console.WriteLine(Two.Count); }
public override LogicPart Initialize(LogicPart logicPart) { var rules = new PudgeRules(); logicPart.CreateWorld = () => new PudgeWorld(); logicPart.CreateDefaultSettings = () => new GameSettings { OperationalTimeLimit = 5, TimeLimit = 90 }; logicPart.WorldStateType = typeof(PudgeWorldState); logicPart.CreateWorldState = seed => new PudgeWorldState(int.Parse(seed)); logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 5).Select(i => i.ToString())); var actorFactory = ActorFactory.FromRobot(new Player.PudgeRobot(), rules); logicPart.Actors[TwoPlayersId.Left] = actorFactory; if (playersCount == 2) { logicPart.Actors[TwoPlayersId.Right] = actorFactory; } var slardarFactory = ActorFactory.FromRobot(new Player.Slardar(), new SlardarRules()); List <Frame3D> slardarTrajectory = GetSlardarTrajectory(); logicPart.NPC.Add(new Tuple <string, ActorFactory, Func <IActor, IController> >( SlardarId.LeftTop, slardarFactory, CreateSlardarBot(slardarTrajectory, SlardarId.LeftTop))); logicPart.NPC.Add(new Tuple <string, ActorFactory, Func <IActor, IController> >( SlardarId.RightBottom, slardarFactory, CreateSlardarBot(slardarTrajectory, SlardarId.RightBottom))); logicPart.Bots[PudgeRules.StandingBotName] = () => rules.CreateStandingBot(); return(logicPart); }
} // end of XmlLevelData WriteToXml() protected GameActor ActorFromString(string actorName) { GameActor ret = null; var staticActor = ActorManager.GetActor(actorName); if (staticActor == null) { var splitName = actorName.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); var nsQualName = splitName[0]; splitName = nsQualName.Split('.'); actorName = splitName[splitName.Length - 1]; staticActor = ActorManager.GetActor(actorName); } if (staticActor != null) { ret = ActorFactory.Create(staticActor); } else { Debug.Assert(false, "Why can't find the actor for: '" + actorName + "'!!"); } return(ret); }
public override LogicPart Initialize(LogicPart logicPart) { var rules = new PudgeRules(); logicPart.CreateWorld = () => new PudgeWorld(true); logicPart.CreateDefaultSettings = () => new GameSettings { OperationalTimeLimit = 5, TimeLimit = 90 }; logicPart.WorldStateType = typeof(PudgeWorldState); logicPart.CreateWorldState = seed => new PudgeWorldState(int.Parse(seed)); logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 5).Select(i => i.ToString())); var actorFactory = ActorFactory.FromRobot(new PudgeRobot(), rules); logicPart.Actors[TwoPlayersId.Left] = actorFactory; logicPart.Actors[TwoPlayersId.Right] = actorFactory; var slardarFactory = ActorFactory.FromRobot(new Slardar(), new SlardarRules()); logicPart.NPC.Add(Tuple.Create(SlardarId.LeftTop, slardarFactory, CreateStandingBot())); logicPart.NPC.Add(Tuple.Create(SlardarId.RightBottom, slardarFactory, CreateWalkingBot())); logicPart.Bots[PudgeRules.StandingBotName] = () => rules.CreateStandingBot(); return(logicPart); }
public void Newly_created_account_should_have_correct_balence_and_credit() { ActorRef account = ActorFactory.Create(inbox => new AccountActor(inbox, 100.0m)).GetActor(); Future <bool> result = new Future <bool>(); decimal balance = 0xDEADBEEF; decimal availableCredit = 0xDEADBEEF; decimal creditLimit = 0xDEADBEEF; AnonymousActor.New(inbox => { account.Request(new QueryAccountBalance(), inbox) .Receive <AccountBalance>(message => { balance = message.Balance; availableCredit = message.AvailableCredit; creditLimit = message.CreditLimit; Console.WriteLine("Balance={0}, Credit={1}, Limit={2}", balance, availableCredit, creditLimit); result.Complete(true); }); }); result.WaitUntilCompleted(5.Seconds()); Assert.True(balance == 0 && availableCredit == 100.0m && creditLimit == 100.0m); }
public void Start() { AppDomain.CurrentDomain.UnhandledException += UnhandledException; CreateCoordinatorChannel(); BeforeStartingServices(); _startupServices.Each((name, builder) => { ActorFactory <IServiceController> factory = _controllerFactory.CreateFactory(inbox => { IServiceController controller = builder(inbox, this); _serviceCache.Add(name, controller); return(controller); }); ActorInstance instance = factory.GetActor(); _actorCache.Add(name, instance); instance.Send(new CreateService(name)); }); WaitUntilServicesAreRunning(_startupServices.GetAllKeys(), _timeout); AfterStartingServices(); }
public SceneManager(ActorFactory actorFactory) { Repository = new ActorRepository(); ActorFactory = actorFactory; TestEvents.DestroyActor += DestroyActor; GL.ClearColor(Color.Black); }
public PeerCache(SubscriptionObserver observer, Guid clientId, Uri controlUri, SubscriptionRepository repository) { _peers = new DictionaryCache<Uri, ActorRef>(); _peerUri = controlUri; _peerIds = new DictionaryCache<Guid, Uri>(); _peerHandlerFactory = ActorFactory.Create((f, s, i) => new PeerHandler(i, observer, repository)); // create a peer for our local client WithPeer(clientId, controlUri, x => { }, true); }
public PeerCache(Fiber fiber, Scheduler scheduler, SubscriptionObserver observer, Guid clientId, Uri controlUri) { _peers = new DictionaryCache<Uri, ActorRef>(); _peerUri = controlUri; _fiber = fiber; _scheduler = scheduler; _peerIds = new DictionaryCache<Guid, Uri>(); _peerHandlerFactory = ActorFactory.Create((f, s, i) => new PeerHandler(f, s, i, observer)); // create a peer for our local client WithPeer(clientId, controlUri, x => { }, true); }
public void Run() { _ringNodeFactory = ActorFactory.Create(inbox => new RingNode(inbox)); Stopwatch timer = Stopwatch.StartNew(); int nodeCount = 100; int roundCount = 1000; Run(nodeCount, roundCount); timer.Stop(); Console.WriteLine("Ring Benchmark"); Console.WriteLine("Processed {0} rings with {1} nodes in {2}ms", roundCount, nodeCount, timer.ElapsedMilliseconds); Console.WriteLine("That's {0} messages per second!", ((long)nodeCount*roundCount*1000)/timer.ElapsedMilliseconds); }
public void Adding_an_actor_to_a_registry() { _auctionFactory = ActorFactory.Create(inbox => new Auction(inbox)); _auctionId = CombGuid.Generate(); ActorRef auction = _auctionFactory.GetActor(); ActorRegistry registry = ActorRegistryFactory.New(x => { //x.Remote(r => r.ListenTo("rm://234.0.0.7:40001")); }); registry.Register(_auctionId, auction); _response = new Future<Response<Bid>>(); AnonymousActor.New(inbox => { registry.Request<Bid>(new BidImpl(27.42m), header => { header.DestinationAddress = new ActorUrn(_auctionId); }, inbox) .Receive<Response<Bid>>(x => _response.Complete); }); _response.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); // need to proxy the channel with headers somehow... // untyped channel => channel mapper -> actor instance // DestinationAddress -> set by outbound channel proxy on message<> // SourceAddress -> set by outbound channel proxy when available (not likely) // ResponseAddress -> set by outbound channel for ResponseChannel on Request to map to channel // Id -> system assigned id // DestinationAddress = urn:actor:554FC958-4661-4FE9-94F5-21D190417BCC }
public void Build_Should_Throw_Exception_IsSamePOCO_HasBeenUsedWithOtherFactory() { var target = new DummyClass(); var Factory = new ActorFactory(); var intface = Factory.Build<IDummyInterface2>(target); Action Do = () => _Factory.Build<IDummyInterface2>(target); Do.ShouldThrow<ArgumentException>().And.Message.Should().Contain("Standard"); }
public ActorFactoryTest() { _Factory = new ActorFactory(); }