public bool IsThereAnyRoverOnThePosition(InputObject inputModel, Rover currentRover) { bool result = inputModel.RoverList.Any(x => x.RoverGuid != currentRover.RoverGuid && x.RoverPosition.X == currentRover.RoverPosition.X && x.RoverPosition.Y == currentRover.RoverPosition.Y); return(result); }
public async virtual Task <ResultObject> DoItAsync(InputObject inputObject) { return(new ResultObject { Value1 = inputObject.Value1 + "-result", Value2 = inputObject.Value2 + 1 }); }
public void Remove(InputObject obj) { if(isRunning) { removeStack.Add(obj); } else { objects.Remove(obj); } }
public void Add(InputObject obj) { if(isRunning) { addStack.Add(obj); } else { objects.Add(obj); } }
private void Start() { _forwardsInput = new InputObject("Forwards", Key.W); _backwardsInput = new InputObject("Backwards", Key.S); _leftInput = new InputObject("Left", Key.A); _rightInput = new InputObject("Right", Key.D); _jumpInput = new InputObject("Jump", Key.Space); }
// Update is called once per frame public void netUpdate(InputObject inputMessage) { string outgoingMessage = JsonUtility.ToJson(inputMessage) + "\n"; SendMessage(outgoingMessage); ReceiveFrameData(); frame++; }
protected override void ProcessRecord() { if (InputObject == null) { return; } _menu.Add(Text == null ? InputObject.ToString() : Text.GetString(InputObject)).Data = InputObject; }
public bool isValidSize(InputObject inputObject) { if (inputObject.Size > 0) { return(true); } // FYI Override ToString Method -- InputObject throw new Exception($"Size - {inputObject.Size} is Invalid for {inputObject}"); }
public void Handle_All_With_Data() { #region Prepare var inputObject = new InputObject() { Entities = new List <Entity>() { new Entity() { ID = 1, Name = "Something 1" }, new Entity() { ID = 2, Name = "Something 2" }, new Entity() { ID = 3, Name = "Something 3" }, }, Links = new List <Link>() { new Link() { FromEntityId = 1, ToEntityId = 2 }, new Link() { FromEntityId = 1, ToEntityId = 3 }, new Link() { FromEntityId = 2, ToEntityId = 3 } } }; var originalEntity = _cloneProcessor.GetInitialEntity(inputObject, 2); var originalEntityCopy = _cloneProcessor.CreateCloneAndAssignId(inputObject, originalEntity); #endregion #region Act _cloneProcessor.HandleAllTo(inputObject, originalEntity, originalEntityCopy); #endregion #region Assert Assert.Equal(4, inputObject.Links.Count); #endregion }
private void OnMouseWheel(InputObject input) { if (input.Handled) { return; } ZoomBy(Mathf.Clamp(-input.Position.Z, -1, 1)); }
protected override void Execute(NativeActivityContext context) { var dyn = InputObject.Get(context) as IDictionary <string, object>; var prop = PropertyName.Get(context); var result = dyn[prop]; context.SetValue(Result, result); Console.WriteLine("{0} = {1}", prop, result); }
/// <summary> /// </summary> protected override void ProcessRecord() { bool isUnique = true; if (_lastObject == null) { // always write first object, but return nothing // on "MSH> get-unique" if (AutomationNull.Value == InputObject) { return; } } else if (OnType) { isUnique = (InputObject.InternalTypeNames[0] != _lastObject.InternalTypeNames[0]); } else if (AsString) { string inputString = InputObject.ToString(); if (_lastObjectAsString == null) { _lastObjectAsString = _lastObject.ToString(); } if (string.Equals( inputString, _lastObjectAsString, StringComparison.CurrentCulture)) { isUnique = false; } else { _lastObjectAsString = inputString; } } else // compare as objects { if (_comparer == null) { _comparer = new ObjectCommandComparer( true, // ascending (doesn't matter) CultureInfo.CurrentCulture, true); // case-sensitive } isUnique = (_comparer.Compare(InputObject, _lastObject) != 0); } if (isUnique) { WriteObject(InputObject); _lastObject = InputObject; } }
private void loadImage(String path) { if (reader != null) { reader.Dispose(); } origPath = path; reader = new ImageStream(path); timer.Restart(); }
private void loadCameraStream(int cameraId) { if (reader != null) { reader.Dispose(); } origPath = cameraId.ToString(); reader = new CameraStream(cameraId); timer.Restart(); }
void CommandButtonReleased(InputObject _this) { if (!inputObjectDict.ContainsKey(_this)) { Debug.LogError("No CommandButton in Dict"); return; } int index = inputObjectDict[_this]; GameManager.Instance.SelectCommand(index); }
public string GetHtmlAfterTransformData() { try { // Get Onedrive file download address. Stream req = Request.InputStream; req.Seek(0, SeekOrigin.Begin); string json = new StreamReader(req).ReadToEnd(); InputObject inputOjbect = null; try { inputOjbect = JsonConvert.DeserializeObject <InputObject>(json); } catch (Exception) { return(string.Empty); } string downloadUri = inputOjbect.Downloaduri; string accessToken = inputOjbect.AccessToken; string fileId = inputOjbect.FileId; // Download the file in Onedrive. var webclient = new WebClient(); byte[] data = webclient.DownloadData(downloadUri); // Get the file name. var fileName = webclient.ResponseHeaders.GetValues("Content-Disposition").FirstOrDefault(); fileName = fileName.Replace("\"", ""); var parse = new WriteRawDataToFile(); if (fileName.ToLower().EndsWith(".docx")) { parse = new WordParse(data, accessToken, fileId); } else if (fileName.ToLower().EndsWith(".xlsx")) { parse = new ExcelParse(data, accessToken, fileId); } else if (fileName.ToLower().EndsWith(".pptx")) { parse = new PowerPointParse(data, accessToken, fileId); } else { return(string.Empty); } return(parse.TempDataToHtmlAndUploadToOneDrive()); } catch (Exception x) { Response.StatusCode = 400; return(x.Message); } }
public void Remove(InputObject obj) { if (isRunning) { removeStack.Add(obj); } else { objects.Remove(obj); } }
public void Add(InputObject obj) { if (isRunning) { addStack.Add(obj); } else { objects.Add(obj); } }
protected override void ProcessRecord() { Item currentItem = InputObject.BaseObject() as Item; var ruleContext = new RuleContext { Item = currentItem }; WriteObject(!rules.Rules.Any() || rules.Rules.Any(rule => rule.Evaluate(ruleContext))); }
// Update is called once per frame void Update () { //Get the mouse position on the screen and send a raycast into the game world from that position. Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); LayerMask layMask = 1 << 8; RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero, Mathf.Infinity, layMask); InputObject pointedInputObject = null; pointedGameObject = null; if(hit.collider != null) { pointedGameObject = hit.collider.gameObject; pointedInputObject = pointedGameObject.GetComponent<InputObject>() as InputObject; } //If something was hit, the RaycastHit2D.collider will not be null. if (pointedInputObject != null) { pointedInputObject.WhenHangingOver(); } if (Input.GetMouseButton(0)) { if(objectDraggingFrom == null) { if(pointedInputObject != null) { objectDraggingFrom = pointedInputObject; objectDraggingFrom.WhenDragged(); } } else { objectDraggingFrom.WhenDragging(); } isPressed = true; } else { if(isPressed && objectDraggingFrom != null && pointedInputObject != null) { objectDraggingFrom.WhenMouseReleased(); if(objectDraggingFrom == pointedInputObject) { pointedInputObject.WhenReleased(); } else { objectDraggingFrom.WhenDraggedInto(pointedInputObject); } objectDraggingFrom = null; } isPressed = false; } }
protected override void ProcessRecord() { base.ProcessRecord(); // initialize SYSTEMTIME // int structMemLen = Marshal.SizeOf(typeof(SYSTEMTIME)); int structMemLen = Marshal.SizeOf(typeof(NativeMethods.SYSTEMTIME)); // 20140312 // byte[] buffer = new byte[structMemLen]; var buffer = new byte[structMemLen]; // SYSTEMTIME sysTime = new SYSTEMTIME(Date); // 20140312 // NativeMethods.SYSTEMTIME sysTime = new NativeMethods.SYSTEMTIME(Date); var sysTime = new NativeMethods.SYSTEMTIME(Date); // get memory size of SYSTEMTIME IntPtr dataPtr = Marshal.AllocHGlobal(structMemLen); Marshal.StructureToPtr(sysTime, dataPtr, true); Marshal.Copy(dataPtr, buffer, 0, structMemLen); Marshal.FreeHGlobal(dataPtr); IntPtr hndProc = IntPtr.Zero; IntPtr lpAddress = IntPtr.Zero; // 20140312 // int procId = InputObject.Current.ProcessId; // int inputHandle = InputObject.Current.NativeWindowHandle; int procId = InputObject.GetCurrent().ProcessId; int inputHandle = InputObject.GetCurrent().NativeWindowHandle; try { // inject new SYSTEMTIME into process memory injectMemory(procId, buffer, out hndProc, out lpAddress); // set DateTime to object via pointer to injected SYSTEMTIME NativeMethods.SendMessage((IntPtr)inputHandle, DTM_SETSYSTEMTIME, (IntPtr)GDT_VALID, lpAddress); } finally { // release memory and close handle if (lpAddress != (IntPtr)0 || lpAddress != IntPtr.Zero) { // we don't really care about the result because if release fails there is nothing we can do about it // bool relState = NativeMethods.VirtualFreeEx(hndProc, lpAddress, 0, FreeType.Release); bool relState = NativeMethods.VirtualFreeEx(hndProc, lpAddress, 0, NativeMethods.FreeType.Release); } if (hndProc != (IntPtr)0 || hndProc != IntPtr.Zero) { NativeMethods.CloseHandle(hndProc); } } }
/// <summary> /// Create a clone of the Entity object, assign new ID and add it to the InputObject /// </summary> /// <param name="inputObject">Input Object from the json file</param> /// <param name="original">Original Entity that should be cloned</param> /// <returns>Cloned object</returns> public Entity CreateCloneAndAssignId(InputObject inputObject, Entity original) { // Create copy, assign new ID and add it to the list of entities Entity clone = (Entity)original.Clone(); clone.ID = inputObject.Entities.LastOrDefault().ID + 1; inputObject.Entities.Add(clone); return(clone); }
/// <summary> /// Handle all links that have InitialEntity as TO ID. /// </summary> /// <param name="inputObject">Input Object from the json file</param> /// <param name="initialEntity">InitialEntity gotten from the passed argument ID</param> /// <param name="initialCopy">InitialEntity Copy created as first step with new ID</param> public void HandleAllTo(InputObject inputObject, Entity initialEntity, Entity initialCopy) { // Get all links for InitialEntity's ID where its ID is in TO field in links array var toList = inputObject.Links.Where(w => w.ToEntityId == initialEntity.ID).ToList(); // Itterate over the enumerable and copy for new ID foreach (var to in toList) { inputObject.Links.Add(CreateLinkForObjects(to.FromEntityId, initialCopy.ID)); } }
private static void ControlOnMouseWheel(object sender, MouseEventArgs args) { if (MouseInputApi != InputApi.Windows) { return; } var io = new InputObject(Key.Unknown, InputState.Change, InputType.MouseWheel, new Vector3(CursorX, CursorY, args.Delta), new Vector3(_deltaX, _deltaY, args.Delta)); Process(ref io); }
protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } foreach (var hashtable in InputObject.Select(inputObject => inputObject.ConvertToHashtable())) { WriteObject(this, hashtable); } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (NoWait.Expression != null) { targetCommand.AddParameter("NoWait", NoWait.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (ServiceDisplayName.Expression != null) { targetCommand.AddParameter("DisplayName", ServiceDisplayName.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (DependentServices.Expression != null) { targetCommand.AddParameter("DependentServices", DependentServices.Get(context)); } if (RequiredServices.Expression != null) { targetCommand.AddParameter("RequiredServices", RequiredServices.Get(context)); } if (ServiceDisplayName.Expression != null) { targetCommand.AddParameter("DisplayName", ServiceDisplayName.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (EventName.Expression != null) { targetCommand.AddParameter("EventName", EventName.Get(context)); } if (SourceIdentifier.Expression != null) { targetCommand.AddParameter("SourceIdentifier", SourceIdentifier.Get(context)); } if (Action.Expression != null) { targetCommand.AddParameter("Action", Action.Get(context)); } if (MessageData.Expression != null) { targetCommand.AddParameter("MessageData", MessageData.Get(context)); } if (SupportEvent.Expression != null) { targetCommand.AddParameter("SupportEvent", SupportEvent.Get(context)); } if (Forward.Expression != null) { targetCommand.AddParameter("Forward", Forward.Get(context)); } if (MaxTriggerCount.Expression != null) { targetCommand.AddParameter("MaxTriggerCount", MaxTriggerCount.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (Audit.Expression != null) { targetCommand.AddParameter("Audit", Audit.Get(context)); } if (AllCentralAccessPolicies.Expression != null) { targetCommand.AddParameter("AllCentralAccessPolicies", AllCentralAccessPolicies.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public InputObject InputModel(string inputValues) { if (string.IsNullOrEmpty(inputValues)) { throw new CustomException("input value can not be empty"); } InputObject inputModel = new InputObject(); inputModel.RoverList = new List <Rover>(); var rows = GetRows(inputValues); var plateue = rows.First(); Position _plateuePosition = new Position { X = TryParseInt(plateue.Substring(0, 1)), Y = TryParseInt(plateue.Substring(1, 1)) }; inputModel.Plateau = new Plateau { PlateauPosition = _plateuePosition }; for (int i = 1; i < rows.Length; i++) { if ((i % 2) - 1 == 0) { char[] roverPosition = rows[i].ToCharArray(); if (roverPosition.Length != 3) { throw new CustomException("Rover position is not in the expected format!!"); } inputModel.RoverList.Add(new Rover { RoverGuid = Guid.NewGuid(), RoverPosition = new RoverPosition { X = TryParseInt(roverPosition[0].ToString()), Y = TryParseInt(roverPosition[1].ToString()), CurrentDirectionType = MapDirectionType(roverPosition[2].ToString()), }, CommandParameters = rows[i + 1] }); } } return(inputModel); }
// Additional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Namespace.Expression != null) { targetCommand.AddParameter("Namespace", Namespace.Get(context)); } if (OperationTimeoutSec.Expression != null) { targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (Query.Expression != null) { targetCommand.AddParameter("Query", Query.Get(context)); } if (QueryDialect.Expression != null) { targetCommand.AddParameter("QueryDialect", QueryDialect.Get(context)); } if (Property.Expression != null) { targetCommand.AddParameter("Property", Property.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (ResourceUri != null) { targetCommand.AddParameter("ResourceUri", ResourceUri.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
private void AddInputObject(ObjectUrl inputObjectUrl, Command command) { if (outputObjects.TryGetValue(inputObjectUrl, out OutputObject outputObject) && mergeCounter > outputObject.Counter) { // Object was output by ourselves, so reading it as input should be ignored return; } inputObjects[inputObjectUrl] = new InputObject { Command = command, Counter = mergeCounter }; }
/// <summary> /// Gets the Entity for the entity_id supplied by json /// </summary> /// <param name="inputObject">Input Object from the json file</param> /// <param name="entityId">Id supplied in the arguments</param> /// <returns>Entity object from the json file</returns> public Entity GetInitialEntity(InputObject inputObject, long entityId) { // Get the initial Entity from the arguments Entity initialEntity = inputObject.Entities.Where(w => w.ID == entityId).FirstOrDefault(); // Check if initial Entity exist, if not, throw error if (initialEntity == null) { throw new RootObjectNotFound($"Entity with id {entityId} not found"); } return(initialEntity); }
private void OnMouseInputEnded(InputObject input) { var hitElement = GlobalHitTest(); if (input.InputType == InputType.MouseButton1) { hitElement?.MouseButton1Up.Fire((int)input.Position.X, (int)input.Position.Y); } else if (input.InputType == InputType.MouseButton2) { hitElement?.MouseButton2Up.Fire((int)input.Position.X, (int)input.Position.Y); } }
private void HandleInput() { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); Vector3 pointToLook = Vector3.zero; bool clicked; //Determine a lookat point Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); Plane groundPlane = new Plane(Vector3.up, Vector3.zero); float rayLength; if (groundPlane.Raycast(cameraRay, out rayLength)) { pointToLook = cameraRay.GetPoint(rayLength); } clicked = Input.GetMouseButton(0); InputObject io = new InputObject(Time.time, movement, pointToLook, clicked); LagQueue.Enqueue(io); }
public void StartFight(InputObject _inputObject) { stage = GameStage.Fight; fightStage = FightStage.StandBy; CommandManager.Instance.StartFight(); ExecuteAllCommand(); }
private void AddInputObject(IExecuteContext executeContext, ObjectUrl inputObjectUrl, Command command) { OutputObject outputObject; if (outputObjects.TryGetValue(inputObjectUrl, out outputObject) && mergeCounter > outputObject.Counter) { // Object was outputed by ourself, so reading it as input should be ignored. return; } inputObjects[inputObjectUrl] = new InputObject { Command = command, Counter = mergeCounter }; }
public void WhenDraggedInto(InputObject _inputObject) { if (DraggedIntoEvent != null) DraggedIntoEvent(this, _inputObject); }