private void AddVehicleCustomizeButton(VehicleWorldInfoPanel infoPanel, out UIButton button, Vector3 offset) { button = UiUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft, (component, e) => { InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel); SelectedInstanceID = instanceID; var vehicle = VehicleManager.instance.m_vehicles.m_buffer[instanceID.Vehicle].Info; try { if (VehiclePanelWrapper == null || vehicle != SelectedVehicle) { VehiclePanelWrapper = vehicle.GenerateVehiclePanel(); } else { VehiclePanelWrapper.isVisible = false; UiUtils.DeepDestroy(VehiclePanelWrapper); } } catch (Exception ex) { Debug.Log($"{ex.Message} - {ex.StackTrace}"); } if (component.hasFocus) { component.Unfocus(); } }); }
public async Task <ActionResult> GetMessageBoxInstance(int instanceOwnerPartyId, Guid instanceGuid, [FromQuery] string language) { string[] acceptedLanguages = { "en", "nb", "nn" }; string languageId = "nb"; if (language != null && acceptedLanguages.Contains(language.ToLower())) { languageId = language; } string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; Instance instance = await _instanceRepository.GetOne(instanceId, instanceOwnerPartyId); if (instance == null) { return(NotFound($"Could not find instance {instanceId}")); } //// TODO: Authorise Dictionary <string, Dictionary <string, string> > appTitle = await _applicationRepository.GetAppTitles(new List <string> { instance.AppId }); MessageBoxInstance messageBoxInstance = InstanceHelper.ConvertToMessageBoxInstance(new List <Instance> { instance }, appTitle, languageId).First(); return(Ok(messageBoxInstance)); }
public async Task <ActionResult> GetMessageBoxInstance(int instanceOwnerId, Guid instanceGuid, [FromQuery] string language) { string[] acceptedLanguages = new string[] { "en", "nb", "nn-no" }; string languageId = "nb"; if (language != null && acceptedLanguages.Contains(language.ToLower())) { languageId = language; } string instanceId = instanceOwnerId.ToString() + "/" + instanceGuid.ToString(); Instance instance = await _instanceRepository.GetOne(instanceId, instanceOwnerId); if (instance == null) { return(NotFound($"Could not find instance {instanceId}")); } // TODO: authorize // Get title from app metadata Dictionary <string, Dictionary <string, string> > appTitle = await _applicationRepository.GetAppTitles(new List <string> { instance.AppId }); // Simplify instances and return MessageBoxInstance messageBoxInstance = InstanceHelper.ConvertToMessageBoxInstance(new List <Instance>() { instance }, appTitle, languageId).First(); return(Ok(messageBoxInstance)); }
public void GetSBLStatusForCurrentTask_TC04() { Instance instance = TestData.Instance_1_Status_4; string sblStatus = InstanceHelper.GetSBLStatusForCurrentTask(instance); Assert.Equal("default", sblStatus); }
public void DoCheckOfferor_ShouldThrow() { PersonOfferor offeror = null; var auctionServcie = InstanceHelper.GetAuctionService(null); Assert.ThrowsAny <Exception>(() => CanOfferorEndAuctionCheck.DoCheck(offeror, auctionServcie)); }
public IFlowBuilderStart Via <TAction>() where TAction : class, IAction { var action = this.createdInstances.GetOrAdd <TAction>( InstanceHelper.CreateInstance <TAction>()); return(this.Via(action)); }
public void GetSBLStatusForCurrentTask_TC01() { Instance instance = TestData.Instance_1_Status_1; string sblStatus = InstanceHelper.GetSBLStatusForCurrentTask(instance); Assert.Equal("FormFilling", sblStatus); }
/// <summary> /// 返回一个最合理的拾取位置 /// </summary> public Vector3 GenerateDropPosition(Vector3 pos, int count) { //if(count > 3) // return pos; Vector3 retPos = Vector3.zero; // 先对位置进行简单随机 // const float dropPosMaxOffset = 2f; // float offsetX = Maths.Random_.Range(-dropPosMaxOffset, dropPosMaxOffset); // float offsetZ = Maths.Random_.Range(-dropPosMaxOffset, dropPosMaxOffset); // retPos.x = pos.x + offsetX; // retPos.y = pos.y; // retPos.x = pos.z + offsetZ; Actor localPlayer = Game.GetInstance().GetLocalPlayer(); if (pos.Equals(Vector3.zero) == true && localPlayer != null) { pos = localPlayer.transform.position; } int dropCnt = DropNum + 10; float r = dropCnt * 0.1f; float degrees = dropCnt * 1f; retPos.x = pos.x + r * (float)Math.Cos(degrees); retPos.z = pos.z + r * (float)Math.Sin(degrees); if (localPlayer != null) { retPos.y = localPlayer.transform.position.y; } //GameDebug.LogWarning("Drop pos: " + retPos); // 限制在副本场景内 retPos = InstanceHelper.ClampInWalkableRange(retPos); // 获取地形高度 retPos.y = PhysicsHelp.GetHeight(retPos.x, retPos.z); // 如果地形太低、则取本地玩家的高度 if (retPos.y <= -19f) { var local_player = Game.GetInstance().GetLocalPlayer(); if (local_player != null) { retPos.y = local_player.transform.position.y; } } /*foreach (DropColliderComponent drop in mDrops) * { * if (drop != null && (retPos - drop.transform.position).sqrMagnitude < 3f) * { * return GenerateDropPosition(retPos, count+1); * } * }*/ return(retPos); }
private void AddBuildingInformationButton(WorldInfoPanel infoPanel, out UIButton button, Vector3 offset) { button = UiUtils.CreateToggleButton(ZoneBuildingPanel.component, offset, UIAlignAnchor.BottomLeft, (comp, e) => { InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel); var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info; try { if (ZonedBuildingPanelWrapper == null || building != CurrentSelectedBuilding) { ZonedBuildingPanelWrapper = building.GenerateBuildingInformation(); } else { ZonedBuildingPanelWrapper.isVisible = false; UiUtils.DeepDestroy(ZonedBuildingPanelWrapper); } } catch (Exception ex) { Debug.Log($"{ex.Message} - {ex.StackTrace}"); } if (comp.hasFocus) { comp.Unfocus(); } }); }
public bool GotoGuilRainRedPacket(params object[] args) { //if (!SysConfigManager.GetInstance().CheckSysHasOpened(GameConst.SYS_OPEN_RAIN_RED_PACKET, true)) //{ // return false; //} //if (!ActivityHelper.IsActivityOpen(GameConst.SYS_OPEN_RAIN_RED_PACKET, true)) //{ // return false; //} if (!CheckSysDownloaded(GameConst.SYS_OPEN_RAIN_RED_PACKET)) { return(false); } if (LocalPlayerManager.Instance.GuildID > 0) { //InstanceHelper.EnterGuildManor(); InstanceHelper.EnterGuildRainRedPacket(); } else { UIManager.GetInstance().ShowSysWindow("UIGuildWindow"); } return(true); }
public bool GotoGuildFire(params object[] args) { if (!SysConfigManager.GetInstance().CheckSysHasOpened(GameConst.SYS_OPEN_GUILD_FIRE, true)) { return(false); } if (!ActivityHelper.IsActivityOpen(GameConst.SYS_OPEN_GUILD_FIRE, true)) { return(false); } if (!CheckSysDownloaded(GameConst.SYS_OPEN_GUILD_FIRE)) { return(false); } if (LocalPlayerManager.Instance.GuildID > 0) { InstanceHelper.EnterGuildManor(); } else { UIManager.GetInstance().ShowSysWindow("UIGuildWindow"); } return(true); }
public IFlowBuilderTo To <TState>() where TState : class, IState { var state = this.createdInstances.GetOrAdd <TState>( InstanceHelper.CreateInstance <TState>()); return(this.To(state)); }
public IStartViaBuilder FromStartTo <TState>() where TState : class, IState { var state = this.createdInstances.GetOrAdd <TState>( InstanceHelper.CreateInstance <TState>()); return(this.FromStartTo(state)); }
private void AddButton(CitizenWorldInfoPanel infoPanel, out UIButton button, Vector3 offSet) { button = UiUtils.CreateToggleButton(infoPanel.component, offSet, UIAlignAnchor.BottomLeft, (component, e) => { InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel); var citizen = CitizenManager.instance.m_citizens.m_buffer[instanceID.Citizen]; try { if (CitizenPanelWrapper == null || instanceID.Citizen != SelectedCitizen) { CitizenPanelWrapper = citizen.GenerateCitizenPanel(instanceID.Citizen); } else { CitizenPanelWrapper.isVisible = false; UiUtils.DeepDestroy(CitizenPanelWrapper); } } catch (Exception ex) { Debug.Log($"{ex.Message} - {ex.StackTrace}"); } if (component.hasFocus) { component.Unfocus(); } }); }
protected override void Process([NotNull] InstallArgs args) { Assert.ArgumentNotNull(args, nameof(args)); Instance instance = args.Instance; Assert.IsNotNull(instance, nameof(instance)); if (ProcessorDefinition.Param == "nowait") { if (!args.PreHeat) { return; } try { InstanceHelper.StartInstance(instance, 500); } catch { // ignore error } } else { InstanceHelper.StartInstance(instance); } }
private void AddDefaultBuildingPropertiesButton(WorldInfoPanel infoPanel, out UIButton button, Vector3 offset) { button = UiUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft, (comp, e) => { PanelType = InfoPanelType.Default; InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel); var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info; try { if (CustomizeItExtendedPanel == null || building != CurrentSelectedBuilding) { CustomizeItExtendedPanel = building.GenerateCustomizeItExtendedPanel(); } else { CustomizeItExtendedPanel.isVisible = false; UiUtils.DeepDestroy(CustomizeItExtendedPanel); } } catch (Exception ex) { Debug.Log($"{ex.Message} - {ex.StackTrace}"); } if (comp.hasFocus) { comp.Unfocus(); } }); }
public void GetLogGroupsTest() { var files = new[] { "C:\\Crawling.log.20140905.135957.txt", "D:\\Crawling.log.20140905.txt", "log.20140905.135957.txt", "E:\\assaasd\\log.20140905.txt", "readme.12324.txt", "Search.log.20140905.135957.txt", "Search.log.20140905.txt", "WebDAV.log.20140905.135957.txt", "WebDAV.log.20140905.txt" }; var results = InstanceHelper.GetLogGroups(files).OrderBy(x => x).Select(x => x.ToLower()).ToArray(); var expected = new[] { "crawling.log", "log", "search.log", "webdav.log" }.OrderBy(x => x).ToArray(); Assert.AreEqual(results.Count(), expected.Count()); for (int i = 0; i < expected.Count(); ++i) { Assert.AreEqual(expected[i], results[i]); } }
public async Task <ActionResult> GetMessageBoxInstance(int instanceOwnerPartyId, Guid instanceGuid, [FromQuery] string language) { string[] acceptedLanguages = { "en", "nb", "nn" }; string languageId = "nb"; if (language != null && acceptedLanguages.Contains(language.ToLower())) { languageId = language; } string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; Instance instance = await _instanceRepository.GetOne(instanceId, instanceOwnerPartyId); if (instance == null) { return(NotFound($"Could not find instance {instanceId}")); } MessageBoxInstance messageBoxInstance = InstanceHelper.ConvertToMessageBoxInstance(instance); // Setting these two properties could be handled by custom PEP. messageBoxInstance.AllowDelete = true; messageBoxInstance.AuthorizedForWrite = true; Dictionary <string, Dictionary <string, string> > appTitle = await _applicationRepository.GetAppTitles(new List <string> { instance.AppId }); InstanceHelper.AddTitleToInstances(new List <MessageBoxInstance> { messageBoxInstance }, appTitle, languageId); return(Ok(messageBoxInstance)); }
public void ConvertToMessageBoxInstance_TC06() { // Arrange string lastChangedBy = TestData.UserId_1; Instance instance = TestData.Instance_1_1; instance.Data = new List <DataElement>() { new DataElement() { LastChanged = Convert.ToDateTime("2019-08-21T19:19:22.2135489Z"), LastChangedBy = lastChangedBy } }; // Act List <MessageBoxInstance> actual = InstanceHelper.ConvertToMessageBoxInstanceList(new List <Instance>() { instance }, TestData.AppTitles_Dict_App1, "nb"); string actualLastChangedBy = actual.FirstOrDefault().LastChangedBy; // Assert Assert.Equal(lastChangedBy, actualLastChangedBy); }
public async Task <ActionResult> GetMessageBoxInstanceEvents( [FromRoute] int instanceOwnerPartyId, [FromRoute] Guid instanceGuid) { string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; string[] eventTypes = new string[] { InstanceEventType.Created.ToString(), InstanceEventType.Deleted.ToString(), InstanceEventType.Saved.ToString(), InstanceEventType.Submited.ToString(), InstanceEventType.Undeleted.ToString() }; if (string.IsNullOrEmpty(instanceId)) { return(BadRequest("Unable to perform query.")); } List <InstanceEvent> result = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null); // filtering out Create & delete data element event result = result.Where(r => string.IsNullOrEmpty(r.DataId) || r.EventType.Equals(InstanceEventType.Saved)).ToList(); return(Ok(InstanceHelper.ConvertToSBLInstanceEvent(result))); }
public void GetSBLStatusForCurrentTask_TC03() { Instance instance = TestData.Instance_1_Status_3; string sblStatus = InstanceHelper.GetSBLStatusForCurrentTask(instance); Assert.Equal("Archived", sblStatus); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { try { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { string title = (string)InstanceHelper.GetPropertyValue("Title", context.Instance, context.Instance.GetType()); Dictionary <string, KNXSelectedAddress> readAddressId = (Dictionary <string, KNXSelectedAddress>)InstanceHelper.GetPropertyValue("ReadAddressId", context.Instance, context.Instance.GetType()); if (null != readAddressId) { var frm = new FrmGroupAddressPick(); frm.Text = UIResMang.GetString("PropEtsReadAddressId") + " - " + title; frm.MultiSelect = false; frm.PickType = FrmGroupAddressPick.AddressType.Read; frm.SelectedAddress = readAddressId; var result = frm.ShowDialog(); if (result == DialogResult.OK) { //value = frm.SelectedAddress; value = new Dictionary <string, KNXSelectedAddress>(frm.SelectedAddress); } } } } catch (Exception ex) { System.Console.WriteLine("PropertyGridImageEditor Error : " + ex.Message); return(value); } return(value); }
public void ConvertToMessageBoxInstance_TC03() { // Arrange string language = "nn-NO"; string app2 = TestData.App_2; string app3 = TestData.App_3; List <Instance> instances = new List <Instance>() { TestData.Instance_2_1, TestData.Instance_3_1 }; Dictionary <string, Dictionary <string, string> > apptitles = new Dictionary <string, Dictionary <string, string> >() { { TestData.Application_2.Id, TestData.AppTitles_App2 }, { TestData.Application_3.Id, TestData.AppTitles_App3 } }; string expected_title_app2 = "Test applikasjon 2 bokmål"; string expected_title_app3 = "Test applikasjon 3 nynorsk"; // Act List <MessageBoxInstance> actual = InstanceHelper.ConvertToMessageBoxInstanceList(instances, TestData.AppTitles_InstanceList_InstanceOwner1, language); string actual_title_app2 = actual.Where(i => i.AppName.Equals(app2)).Select(i => i.Title).FirstOrDefault(); string actual_title_app3 = actual.Where(i => i.AppName.Equals(app3)).Select(i => i.Title).FirstOrDefault(); // Assert Assert.Equal(expected_title_app2, actual_title_app2); Assert.Equal(expected_title_app3, actual_title_app3); }
//private readonly InputHelper _inputHelper = new InputHelper(); public Animal CreateAnimal() { Console.WriteLine("What animal do you want to create?"); Console.WriteLine("1) Cat"); Console.WriteLine("2) Dog"); Console.WriteLine("3) Snake"); var chosenAnimal = Console.ReadKey(true); Animal createdAnimal = null; switch (chosenAnimal.Key) { case ConsoleKey.D1: createdAnimal = InstanceHelper.CreateInstance <Cat>(); break; case ConsoleKey.D2: createdAnimal = InstanceHelper.CreateInstance <Dog>(); break; case ConsoleKey.D3: createdAnimal = InstanceHelper.CreateInstance <Snake>(); break; default: Console.WriteLine("Wrong option chosen!"); break; } return(createdAnimal); }
public async Task <ActionResult> GetMessageBoxInstanceEvents( [FromRoute] int instanceOwnerPartyId, [FromRoute] Guid instanceGuid) { string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; string[] eventTypes = { InstanceEventType.Created.ToString(), InstanceEventType.Deleted.ToString(), InstanceEventType.Saved.ToString(), InstanceEventType.Submited.ToString(), InstanceEventType.Undeleted.ToString(), InstanceEventType.SubstatusUpdated.ToString() }; if (string.IsNullOrEmpty(instanceId)) { return(BadRequest("Unable to perform query.")); } List <InstanceEvent> allInstanceEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null); List <InstanceEvent> filteredInstanceEvents = InstanceEventHelper.RemoveDuplicateEvents(allInstanceEvents); return(Ok(InstanceHelper.ConvertToSBLInstanceEvent(filteredInstanceEvents))); }
public static void Main(string[] args) { try { // Серверный экземпляр приложения. Если он создан не будет, // скорее всего он уже создан, значит текущий экземпляр - не первый. IInstance instance = null; try { // Пытаемся зарегистрировать сервер. InstanceHelper.RegisterServer( Settings.Environment.ServerPort, Settings.Environment.ApplicationName, new AppInstance()); } catch (RemotingException) { // Зарегистрировать сервер не удалось - пытаемся подключиться к серверу. instance = InstanceHelper.GetObject( Settings.Environment.ClientPort, Settings.Environment.ServerPort, Settings.Environment.ApplicationName); // Подключиться к серверу не удалось - что-то не работает. if (instance == null) { throw new CantGetServerAppInstanceException(); } } if (instance == null) { // Если это первый экземпляр приложения, запускаем его... Application.ThreadException += Application_ThreadException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (Core.Instance) { // Запускаем основное окно... Core.Instance.Run(args); } } else { // Если это не первый экземпляр приложения, нужно передать в первый // информацию об открываемых файлах. instance.Message(args.Length == 0 ? null : args); } } catch (Exception e) { ShowErrorMessage(e.GetType().Name, e.Message, e.StackTrace); } catch { ShowErrorMessage(string.Empty, string.Empty, string.Empty); } }
public ServerMob(GameSession session, MobData mobId, Tuple <MapTile, MapTile, MapTile> spawn, int toTeam, GameUser user) { _sender = user; _session = session; _wayPoints = spawn; SenderId = user.User.Id; user.MobsSend++; MobData = mobId; StatusEffect = new List <MobStatusEffectModel>(); TargetTeam = toTeam; VisitedWayPoint = _wayPoints.Item2 == null; InstanceId = InstanceHelper.GetNewInstanceId(); X = spawn.Item1.X; Y = spawn.Item1.Y; MobId = mobId.MobId; Speed = (float)mobId.Speed; Hp = mobId.Hp; TilePosX = spawn.Item1.X; TilePosY = spawn.Item1.Y; LastUpdate = 0; UpdatePath(); }
// This function will get triggered/executed when a new message is written // on an Azure Queue called queue. public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log) { log.WriteLine(message); // Step 1. InstanceHelper.GetEndpointList(ConfigurationManager.AppSettings["EndpointList"].GetList(), log); }
public static object ExecuteMethod <TServiceContract>(string bindingName, string method, params object[] parameters) where TServiceContract : IDevServiceContract { using (TServiceContract client = CreateService <TServiceContract>(bindingName)) { return(InstanceHelper.ExecuteMethod <TServiceContract>(client, method, parameters)); } }
public void OnClicked(CEventBaseArgs args) { Actor localPlayer = Game.GetInstance().GetLocalPlayer(); if (localPlayer == null || localPlayer.IsDead() == true) { return; } if (args == null || args.arg == null) { return; } GameObject clickedObject = args.arg as GameObject; // 实际点击的是该组件的孩子 if (clickedObject == null || clickedObject.transform == null || clickedObject.transform.parent == null || clickedObject.transform.parent.gameObject == null || clickedObject.transform.parent.gameObject != this.gameObject) { return; } // 帮派篝火要判断是否还有烤肉次数和背包是否已满 if (mClass == "guild_league_fire") { if (GuildBonfireCheckCanMeat(true) == false) { return; } if (ItemManager.Instance.BagIsFull(1) == true) { UINotice.Instance.ShowMessage(DBConstText.GetText("BAG_IS_FULL")); return; } } // 跨服boss大宝箱 if (mClass == "span_boss_big_box" || mClass == "span_boss_little_box") { if (CheckCanGetServerBossBox(true) == false) { return; } } mIsClickedTouch = true; if (!IsLocalPlayerCloseEnoughToEnter) { bool result = false; Vector3 pos = transform.position; pos = InstanceHelper.ClampInWalkableRange(pos, pos, out result); localPlayer.MoveCtrl.TryWalkToAlong(pos); } else { OnTouchEnter(); } }