static void Main(string[] args) { Customer c = new Customer(); c.Name = "Alice"; c.ID = 1; CreateAction <Customer>()(c); }
public BattlePanelView() { GameObject UIRootCanvas = GameObject.Find("UIRootCanvas"); // GameObject UICamera = UIRootCanvas.transform.FindChild("UICamera").gameObject; view = ResourceMgr.GetGameObject(URLConst.GetUI(UIType.battle.Name)); view.transform.SetParent(UIRootCanvas.transform); view.transform.localPosition = new Vector3(0, 0, 0); view.transform.localScale = new Vector3(1, 1, 1); m_battleSkillUI = new BattleSkillUI(); GameObject cardbtn = view.transform.FindChild("Image").gameObject; UIEventHandlerBase.AddListener(cardbtn, UIEventType.ON_POINTER_DOWN, delegate(GameObject arg1, BaseEventData arg2){ Debug.Log("point down!!!!!!!!"); // SceneMgr.Instance.GetCurSceneView().addMonster(100101); }); UIEventHandlerBase.AddListener(cardbtn, UIEventType.ON_POINTER_UP, delegate(GameObject arg1, BaseEventData arg2){ Debug.Log("point Up!!!!!!!!"); GameObject m_CurSceneGO = SceneManager.GetActiveScene().GetRootGameObjects()[0]; Vector3 pos = m_CurSceneGO.transform.FindChild("Camera").GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition); // SceneMgr.Instance.GetCurSceneView().addMonster(100101, new Vector3(pos.x, pos.y, 0)); CreateAction action = new CreateAction(pos); LockStepMgr.Instance.AddAction(action); }); }
public void Create_ValidCreateAction_NewObjectCreatedAndAddedToState() { //Setup var unit = CreateUnit(); var creator = unit.As <ICreator>(); var action = new CreateAction(0); UnitActionCollection actions = new UnitActionCollection(); actions.AddAction(unit.Object.Id, action); var obj = new Mock <WorldObject>().Object; creator.Setup(c => c.CanCreate(action)).Returns(true); creator.Setup(c => c.Create(action)).Returns(obj); var state = CreateStateMock(CreateUnitList(unit)); AddUnitToState(unit, state); var subject = new ActionExecutor(state.Object); //Act subject.Execute(actions); //Assert creator.Verify(c => c.CanCreate(action)); creator.Verify(c => c.Create(action)); state.Verify(s => s.Add(obj)); }
protected override void Execute(List <InputEntity> entities) { var moversList = new List <GameEntity>(_movers.GetEntities()); var clientId = _client.ConnectionId.Id.ToString(); var curMover = moversList.Find(m => m.moverID.value == clientId); var curTick = _gameContext.tick.CurrentTick; if (curMover != null) { var iceCommand = new ClientCreateIceCommand { Tick = curTick + 1, LastsTick = 150 }; var iceAction = new IceAction(iceCommand, clientId); GameUtil.AddLocalActionList(_gameContext, iceAction); _client.EnqueueCommand(iceCommand); return; } foreach (var e in entities) { var position = e.mouseDown.position; var direction = Random.Range(0, 360); var createCommand = new ClientCreateBeeCommand { Position = position, Direction = direction, Tick = curTick + 1, Sprite = "bee" }; var createAction = new CreateAction(createCommand, clientId); Debug.Log($"createAction : ${position.x:f5},{position.y:f5}"); GameUtil.AddLocalActionList(_gameContext, createAction); _client.EnqueueCommand(createCommand); } }
public override MetaObject Create(CreateAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Create)) { return(CallMethodNAry(action, args, "Create")); } return(base.Create(action, args)); }
public Table(CreateAction create, ReadAction read, UpdateAction update, DeleteAction delete, string name) { this.CreateAction = create; this.ReadAction = read; this.UpdateAction = update; this.DeleteAction = delete; this.Name = name; this.Refresh(); }
public async Task <IActionResult> Post([FromBody] CreateAction command) { command.Id = Guid.NewGuid(); command.CreatedAt = DateTime.UtcNow; await _busClient.PublishAsync(command); return(Accepted($"activities/{command.Id}")); }
private static FileStatus ToFileStatus(CreateAction createAction) { return(createAction switch { CreateAction.FILE_SUPERSEDED => FileStatus.FILE_SUPERSEDED, CreateAction.FILE_OPENED => FileStatus.FILE_OPENED, CreateAction.FILE_CREATED => FileStatus.FILE_CREATED, CreateAction.FILE_OVERWRITTEN => FileStatus.FILE_OVERWRITTEN, _ => FileStatus.FILE_OPENED });
/// <summary> /// Called by the unity's creation button in the game scene. /// </summary> public void CreateNewCubeAtOrigin() { GameObject newCube = Instantiate(playerCubePrefab).gameObject; newCube.transform.position = Vector3.zero; CreateAction createAction = new CreateAction(newCube); UserActionCache.Instance.AddActionPerformed(createAction); }
public async Task <JobResponse> Create(Job job) { job.Sender = CurrentSender(job.Sender); var relativeUrl = RelativeUrl(job.Sender, JobType.Direct, HttpMethod.Post); var documentBundle = DirectAsiceGenerator.CreateAsice(job, ClientConfiguration.Certificate, ClientConfiguration); var createAction = new CreateAction(job, documentBundle); var directJobResponse = await RequestHelper.Create(relativeUrl, createAction.Content(), CreateAction.DeserializeFunc).ConfigureAwait(false); _logger.LogDebug($"Successfully created Direct Job with JobId: {directJobResponse.JobId}."); return(directJobResponse); }
public void CanCreate_InRange_ReturnsTrue() { //Setup Gatherer subject = new(); var action = new CreateAction(0); //Act var can = subject.CanCreate(action); //Assert Assert.True(can, "Gatherer thinks it cannot create something it definitely can"); }
public void Create_OutOfRange_ReturnsNull() { //Setup Gatherer subject = new(); var action = new CreateAction(5); //Act var obj = subject.Create(action); //Assert Assert.Null(obj); }
public void CanCreate_OutOfRange_ReturnsFalse() { //Setup Gatherer subject = new(); var action = new CreateAction(5); //Act var can = subject.CanCreate(action); //Assert Assert.False(can, "Gatherer thinks it can create something it definitely cannot"); }
public void Create_Marker_ReturnsMarker() { //Setup Gatherer subject = new(); var action = new CreateAction(0); //Act var obj = subject.Create(action); //Assert Assert.IsAssignableFrom <Marker>(obj); }
private string GetLayerName(string directory, out CreateAction exaction) { while (true) { string layerName = null; Console.WriteLine("Please enter the name for the exported shapefile"); layerName = Console.ReadLine(); if (layerName != null && layerName.EndsWith(".shp", StringComparison.CurrentCultureIgnoreCase)) { layerName = layerName.Substring(0, layerName.IndexOf(".shp", StringComparison.CurrentCultureIgnoreCase)); } if (string.IsNullOrEmpty(layerName)) { Console.WriteLine("Invalid name"); continue; } if (File.Exists(string.Format("{0}\\{1}.shp", directory, layerName))) { while (true) { Console.WriteLine("Shapefile already exists. Type A to append or any other key to choose another name."); string action = Console.ReadLine(); if (Array.IndexOf(mergeactions, action) == -1) { Console.WriteLine("Invalid option."); continue; } if (action == "A" || action == "a") { exaction = CreateAction.Append; } else { return(GetLayerName(directory, out exaction)); } return(layerName); } } exaction = CreateAction.CreateNew; return(layerName); } }
public WorldObject Create(CreateAction action) { if (!CanCreate(action)) { return(null); } switch ((CreationIndex)action.ActionIndex) { case CreationIndex.MARKER: return(MarkerDefinition.ParseMarker(action.Data, Id)); default: return(null); } }
public void Create_NotACreatingUnit_FailsAction() { //Setup var unit = CreateUnit(); var state = CreateStateMock(CreateUnitList(unit)); AddUnitToState(unit, state); var action = new CreateAction(0); UnitActionCollection actions = new UnitActionCollection(); actions.AddAction(unit.Object.Id, action); var subject = new ActionExecutor(state.Object); //Act & Assert Assert.Throws <BadActionException>(() => subject.Execute(actions)); }
public void InitializesClassAndParentProperties() { //Arrange var businessCertificate = CoreDomainUtility.GetTestCertificate(); var clientConfiguration = CoreDomainUtility.GetClientConfiguration(); var directJob = new Job(DomainUtility.GetDirectDocument(), DomainUtility.GetSigner(), "reference", DomainUtility.GetExitUrls(), CoreDomainUtility.GetSender()); var serializedJob = SerializeUtility.Serialize(DataTransferObjectConverter.ToDataTransferObject(directJob)); var asiceBundle = DirectAsiceGenerator.CreateAsice(directJob, businessCertificate, clientConfiguration); //Act var action = new CreateAction(directJob, asiceBundle); //Assert Assert.Equal(directJob, action.RequestContent); Assert.Equal(serializedJob, action.RequestContentXml.InnerXml); Assert.Null(action.MultipartFormDataContent); }
private static FileStatus ToFileStatus(CreateAction createAction) { switch (createAction) { case CreateAction.FILE_SUPERSEDED: return(FileStatus.FILE_SUPERSEDED); case CreateAction.FILE_OPENED: return(FileStatus.FILE_OPENED); case CreateAction.FILE_CREATED: return(FileStatus.FILE_CREATED); case CreateAction.FILE_OVERWRITTEN: return(FileStatus.FILE_OVERWRITTEN); default: return(FileStatus.FILE_OPENED); } }
public async Task Throws_exception_on_invalid_manifest_in_attachment() { //Arrange var client = GetClientWithRequestValidator(new FakeHttpClientForDataResponse()); var serializedfunc = new Func <IRequestContent, string>(p => ContentUtility.GetDirectSignatureJobRequestBody()); var manifestBytes = Encoding.UTF8.GetBytes(XmlResource.Request.GetPortalManifest().OuterXml); var asiceArchive = new AsiceArchive(new List <AsiceAttachableProcessor>()); asiceArchive.AddAttachable("manifest.xml", manifestBytes); var documentBundle = new DocumentBundle(asiceArchive.GetBytes()); var createAction = new CreateAction(new FakeJob(), documentBundle, serializedfunc); //Act await Assert.ThrowsAsync <InvalidXmlException>(async() => await client.SendAsync(GetHttpRequestMessage(createAction.Content())).ConfigureAwait(false)).ConfigureAwait(false); //Assert }
public CreateResponse(byte[] buffer, int offset) : base(buffer, offset) { StructureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0); OplockLevel = (OplockLevel)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 2); Flags = (CreateResponseFlags)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 3); CreateAction = (CreateAction)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4); CreationTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 8); LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 16); LastWriteTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 24); ChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 32); AllocationSize = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 40); EndofFile = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 48); FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 56); Reserved2 = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 60); FileId = new FileID(buffer, offset + SMB2Header.Length + 64); CreateContextsOffsets = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 80); CreateContextsLength = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 84); if (CreateContextsLength > 0) { CreateContexts = CreateContext.ReadCreateContextList(buffer, offset + (int)CreateContextsOffsets); } }
void RunCreateAction(T instance) { if (InstanceCreateAction != null) { InstanceCreateAction.Invoke(instance); } else if (InstanceCreateMethod != null) { ObjectType.GetMethod(InstanceCreateMethod).Invoke(instance, new object[] { }); } else if (CreateAction != null) { CreateAction.Invoke(instance); } else if (CreateMethod != null) { ObjectType.GetMethod(CreateMethod).Invoke(instance, new object[] { }); } else { throw new Exception("Don't know how to Create(). Please set CreateAction or CreateMethod."); } }
/// <summary>Creates a new action. </summary> /// <param name="action">The <see cref="Action"/> to create. </param> /// <returns>The new action asynchronous. </returns> /// <seealso cref="M:Stackstorm.Api.Client.Apis.IActionsApi.CreateActionAsync(Action)"/> public async Task <Action> CreateActionAsync(CreateAction action) { return(await _host.PostApiRequestAsync <Action, CreateAction>("/v1/actions/", action)); }
public override MetaObject Create(CreateAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Create)) { return CallMethodNAry(action, args, "Create"); } return base.Create(action, args); }
public void setAction_Create(CreateAction action) { createAction_ = action; }
/// <summary> /// When overridden in a derived class provides the non-Meta implementation of creating an instance /// of the Dynamic object. /// /// When not overridden the call site requesting the action determines the behavior. /// </summary> protected virtual object Create(CreateAction action, params object[] args) { throw new NotSupportedException(); }
private string GetLayerName(string directory, out CreateAction exaction) { while (true) { string layerName = null; Console.WriteLine("Please enter the name for the exported shapefile"); layerName = Console.ReadLine(); if (layerName != null && layerName.EndsWith(".shp", StringComparison.CurrentCultureIgnoreCase)) layerName = layerName.Substring(0, layerName.IndexOf(".shp", StringComparison.CurrentCultureIgnoreCase)); if (string.IsNullOrEmpty(layerName)) { Console.WriteLine("Invalid name"); continue; } if (File.Exists(string.Format("{0}\\{1}.shp", directory, layerName))) { while (true) { Console.WriteLine("Shapefile already exists. Type A to append or any other key to choose another name."); string action = Console.ReadLine(); if (Array.IndexOf(mergeactions, action) == -1) { Console.WriteLine("Invalid option."); continue; } if (action == "A" || action == "a") exaction = CreateAction.Append; else return GetLayerName(directory, out exaction); return layerName; } } exaction = CreateAction.CreateNew; return layerName; } }
public Event PostCreate(CreateAction action) { return(new Event { Id = 1 }); }
public async Task SyncGroupAsync(Guid groupId, Guid scimAppSettingsId) { ScimGroupSyncState?syncState = await _authDbContext .ScimGroupSyncStates .SingleOrDefaultAsync(s => s.SCIMAppSettings.Id == scimAppSettingsId && s.UserGroup.Id == groupId); List <ScimUserSyncState> userSyncStates = await _authDbContext .ScimUserSyncStates .Where(s => s.SCIMAppSettings.Id == scimAppSettingsId && s.User.Groups.Any(g => g.Id == groupId)) .ToListAsync(); List <Gatekeeper.SCIM.Client.Schema.Core20.Group.GroupMembership> groupMemberships = new List <Gatekeeper.SCIM.Client.Schema.Core20.Group.GroupMembership>(); foreach (ScimUserSyncState userSyncState in userSyncStates) { groupMemberships.Add(new Gatekeeper.SCIM.Client.Schema.Core20.Group.GroupMembership { Value = userSyncState.ServiceId, }); } UserGroup group = await _authDbContext .UserGroup .SingleAsync(u => u.Id == groupId); Gatekeeper.SCIM.Client.Schema.Core20.Group scimGroup = new Gatekeeper.SCIM.Client.Schema.Core20.Group { ExternalId = group.Id.ToString(), DisplayName = group.Name, Members = groupMemberships, }; Gatekeeper.SCIM.Client.Client scimClient = await GetScimClient(scimAppSettingsId); if (syncState == null) { CreateAction <Gatekeeper.SCIM.Client.Schema.Core20.Group> createGroupAction = new CreateAction <Gatekeeper.SCIM.Client.Schema.Core20.Group>(scimGroup); CreateResult <Gatekeeper.SCIM.Client.Schema.Core20.Group> createUserResult = await scimClient.PerformAction <CreateResult <Gatekeeper.SCIM.Client.Schema.Core20.Group> >(createGroupAction); if (createUserResult.ResultStatus == StateEnum.Success && createUserResult.Resource != null && createUserResult.Resource.Id != null ) { syncState = new ScimGroupSyncState { UserGroup = group, SCIMAppSettingsId = scimAppSettingsId, ServiceId = createUserResult.Resource.Id, }; _authDbContext.Add(syncState); await _authDbContext.SaveChangesAsync(); } else { throw new Exception("SCIM initial sync failed"); } } else { scimGroup.Id = syncState.ServiceId; UpdateGroupAction updateGroup = new UpdateGroupAction(scimGroup); UpdateGroupResult updateGroupResult = await scimClient.PerformAction <UpdateGroupResult>(updateGroup); if (updateGroupResult.ResultStatus != StateEnum.Success) { throw new Exception("SCIM update failed"); } } }
public AutoCreateIndexer(CreateAction action) { baseDictionary = new Dictionary <K, T>(); Create = action; }
/// <summary> /// Creates and runs an Action that triggers reaction in all observables in the shared state. /// </summary> /// <param name="sharedState">The name of the shared state to use to create this action.</param> /// <param name="actionName">The name of this action.</param> /// <param name="scope">The scope of this action.</param> /// <param name="action">The action itself.</param> public static void RunInAction(this ISharedState sharedState, string actionName, object scope, Action action) { CreateAction(sharedState, actionName, scope, action)(); }
/// <summary> /// Creates and runs an Action that triggers reaction in all observables in the shared state. /// </summary> /// <param name="sharedState">The name of the shared state to use to create this action.</param> /// <param name="action">The action itself.</param> public static void RunInAction(this ISharedState sharedState, Action action) { CreateAction(sharedState, "<unnamed action>", null, action)(); }
public async Task SyncUserAsync(Guid userId, Guid scimAppSettingsId) { ScimUserSyncState?syncState = await _authDbContext .ScimUserSyncStates .SingleOrDefaultAsync(s => s.SCIMAppSettings.Id == scimAppSettingsId && s.User.Id == userId); AppUser user = await _authDbContext .Users .SingleAsync(u => u.Id == userId); Gatekeeper.SCIM.Client.Schema.Core20.User scimUser = new Gatekeeper.SCIM.Client.Schema.Core20.User { ExternalId = user.Id.ToString(), UserName = user.UserName, Emails = new List <Gatekeeper.SCIM.Client.Schema.Core20.User.EmailAttribute>() { new Gatekeeper.SCIM.Client.Schema.Core20.User.EmailAttribute { Value = user.Email, Primary = true }, }, DisplayName = user.UserName, Active = true, }; Gatekeeper.SCIM.Client.Client scimClient = await GetScimClient(scimAppSettingsId); if (syncState == null) { CreateAction <Gatekeeper.SCIM.Client.Schema.Core20.User> createUserAction = new CreateAction <Gatekeeper.SCIM.Client.Schema.Core20.User>(scimUser); CreateResult <Gatekeeper.SCIM.Client.Schema.Core20.User> createUserResult = await scimClient.PerformAction <CreateResult <Gatekeeper.SCIM.Client.Schema.Core20.User> >(createUserAction); if (createUserResult.ResultStatus == StateEnum.Success && createUserResult.Resource != null && createUserResult.Resource.Id != null ) { syncState = new ScimUserSyncState { User = user, SCIMAppSettingsId = scimAppSettingsId, ServiceId = createUserResult.Resource.Id, }; _authDbContext.Add(syncState); await _authDbContext.SaveChangesAsync(); } else { throw new Exception("SCIM initial sync failed"); } } else { scimUser.Id = syncState.ServiceId; UpdateUserAction updateUserAction = new UpdateUserAction(scimUser); UpdateUserResult updateUserResult = await scimClient.PerformAction <UpdateUserResult>(updateUserAction); if (updateUserResult.ResultStatus != StateEnum.Success) { throw new Exception("SCIM update failed"); } } }