/// <summary> /// Parses a transaction from the specified stream. /// </summary> /// <param name="stream">A BlockchainStream containing the data to load.</param> /// <exception cref="System.ArgumentException">The specified stream is NULL or invalid.</exception> /// <exception cref="System.InvalidOperationException">The transaction could not be parsed from the specified stream.</exception> /// <returns>A Transaction parsed from the stream.</returns> internal static Transaction Parse(BlockchainStream stream) { Transaction returnValue; // Verify params if (stream == null) { throw new ArgumentException("The specified stream is NULL", nameof(stream)); } // Get the transaction version if (stream.TryReadInt(out int version)) { // Get number of inputs if (stream.TryReadVarInt(out VarInt inputCount) && inputCount.AsInt64 > 0) { InputList inputs; // Load inputs inputs = new InputList(); for (long i = 0; i < inputCount.AsInt64; i++) { Input nextInput; nextInput = InputParser.Parse(stream); inputs.Add(nextInput); } // Get number of outputs if (stream.TryReadVarInt(out VarInt outputCount) && outputCount.AsInt64 > 0) { OutputList outputs; // Load outputs outputs = new OutputList(); for (long i = 0; i < outputCount.AsInt64; i++) { Output nextOutput; nextOutput = OutputParser.Parse(stream); outputs.Add(nextOutput); } if (stream.TryReadUInt(out uint rawLockTime)) { LockTime lockTime; lockTime = ParseLockTime(rawLockTime); returnValue = new Transaction(version, lockTime, inputs, outputs); } else { throw new InvalidOperationException("The locktime could not be parsed"); } } else { throw new InvalidOperationException("The number of outputs could not be parsed"); } }
private void AddMouseInput(MouseButtons button, bool isMouseUp) { INPUT input = new INPUT(); input.Type = InputType.InputMouse; input.Data.Mouse = new MOUSEINPUT(); if (button == MouseButtons.Left) { input.Data.Mouse.dwFlags = isMouseUp ? MouseEventFlags.MOUSEEVENTF_LEFTUP : MouseEventFlags.MOUSEEVENTF_LEFTDOWN; } else if (button == MouseButtons.Right) { input.Data.Mouse.dwFlags = isMouseUp ? MouseEventFlags.MOUSEEVENTF_RIGHTUP : MouseEventFlags.MOUSEEVENTF_RIGHTDOWN; } else if (button == MouseButtons.Middle) { input.Data.Mouse.dwFlags = isMouseUp ? MouseEventFlags.MOUSEEVENTF_MIDDLEUP : MouseEventFlags.MOUSEEVENTF_MIDDLEDOWN; } else if (button == MouseButtons.XButton1) { input.Data.Mouse.mouseData = (uint)MouseEventDataXButtons.XBUTTON1; input.Data.Mouse.dwFlags = isMouseUp ? MouseEventFlags.MOUSEEVENTF_XUP : MouseEventFlags.MOUSEEVENTF_XDOWN; } else if (button == MouseButtons.XButton2) { input.Data.Mouse.mouseData = (uint)MouseEventDataXButtons.XBUTTON2; input.Data.Mouse.dwFlags = isMouseUp ? MouseEventFlags.MOUSEEVENTF_XUP : MouseEventFlags.MOUSEEVENTF_XDOWN; } InputList.Add(input); }
protected override void SetValuesInList() { for (int i = 0; i <= k_NumOfInputJumps; i++) { InputList.Add((int)(i * k_ValueOfOneJump)); } }
public async Task TestGetAmiIdsWorks() { Func <GetAmiIdsResult, string> showGetAmiIdsResult = (r) => $"Id={r.Id} NameRegex={r.NameRegex} SortAscending={r.SortAscending}"; Func <string, Func <GetAmiIdsInvokeArgs>, Task> check = (expected, args) => Assert.Output(() => GetAmiIds.Invoke(args()).Apply(x => showGetAmiIdsResult(x))) .ResolvesTo(expected); var owners = new InputList <string>(); owners.Add(Out("owner-1")); owners.Add(Out("owner-2")); Func <int, Inputs.GetAmiIdsFilterInputArgs> makeFilter = (int i) => { var values = new InputList <string>(); values.Add($"value-{i}-1"); values.Add($"value-{i}-2"); var f = new Inputs.GetAmiIdsFilterInputArgs() { Name = Out($"filter-{i}-name"), Values = values }; return(f); }; var filters = new InputList <Inputs.GetAmiIdsFilterInputArgs>(); filters.Add(makeFilter(1)); filters.Add(makeFilter(2)); var expectOwners = "[owners: owner-1, owner-2]"; var expectFilters = "[name=filter-1-name values=[value-1-1, value-1-2], name=filter-2-name values=[value-2-1, value-2-2]]"; var expect = $"Id=my-id {expectOwners} [filters: {expectFilters}] NameRegex=[a-z] SortAscending=True"; await check(expect, () => new GetAmiIdsInvokeArgs() { NameRegex = Out("[a-z]"), SortAscending = Out(true), Owners = owners, Filters = filters }); }
public void Display(Prompt source) { id.data.data = source.id.ToString(); prompt.data.data = source.prompt; reprompt.data.data = source.reprompt; foreach (var answer in source.acceptedResponses) { answers.Add(answer); } }
public void AddMouseWheel(int delta) { INPUT input = new INPUT(); input.Type = InputType.InputMouse; input.Data.Mouse = new MOUSEINPUT(); input.Data.Mouse.dwFlags = MouseEventFlags.MOUSEEVENTF_WHEEL; input.Data.Mouse.mouseData = (uint)delta; InputList.Add(input); }
public void AddMouseMove(int x, int y) { INPUT input = new INPUT(); input.Type = InputType.InputMouse; input.Data.Mouse = new MOUSEINPUT(); input.Data.Mouse.dx = (int)Math.Ceiling((double)(x * 65535) / NativeMethods.GetSystemMetrics(SystemMetric.SM_CXSCREEN)) + 1; input.Data.Mouse.dy = (int)Math.Ceiling((double)(y * 65535) / NativeMethods.GetSystemMetrics(SystemMetric.SM_CYSCREEN)) + 1; input.Data.Mouse.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE | MouseEventFlags.MOUSEEVENTF_ABSOLUTE; InputList.Add(input); }
public void AddConfiguration(string key, Output <string>?value) { if (value == null) { return; } _appSettings.Add(new NameValuePairArgs { Name = key, Value = value }); }
private void AddKeyInput(VirtualKeyCode keyCode, bool isKeyUp) { INPUT input = new INPUT(); input.Type = InputType.InputKeyboard; input.Data.Keyboard = new KEYBDINPUT(); input.Data.Keyboard.wVk = keyCode; if (isKeyUp) { input.Data.Keyboard.dwFlags = KeyboardEventFlags.KEYEVENTF_KEYUP; } InputList.Add(input); }
private InputList <AppServiceConnectionStringArgs> GenerateConnStrings(Persistence includedPersistence) { var connStrings = new InputList <AppServiceConnectionStringArgs>(); if (includedPersistence.HasFlag(Persistence.AzureSql)) { connStrings.Add(new AppServiceConnectionStringArgs { Name = "db", Type = "SQLAzure", #pragma warning disable CS8604 // Possible null reference argument. Cannot happen based on code flow Value = DbConnectionString #pragma warning restore CS8604 // Possible null reference argument. }); } return(connStrings); }
/// <summary> /// add a new input /// </summary> /// <param name="index">insert the new input at the index</param> public void AppendInput(Input input, int index = -1) { if (!InputList.Contains(input)) { input.SourceBlock = this; if (index > 0) { InputList.Insert(index, input); } else { InputList.Add(input); } FireUpdate(1 << (int)UpdateState.Inputs); } }
public bool Add(Body value) { InputList inputList = new InputList(); foreach (COOPType parametersType in value.parameters.types) { inputList.Add(parametersType); } if (inputsListToBody.ContainsKey(inputList)) { return(false); } inputsListToBody.Add(inputList, value); bodies.Add(value); return(true); }
public void AddInput(string nInput) { if (nInput != null) { InputList.Add(nInput); InputIndex = InputList.Count; if (InputList.Count > CMD_COUNT_MAX) { int numToRemove = InputList.Count - CMD_COUNT_MAX; for (int i = 0; i < numToRemove; i++) { InputList.RemoveRange(0, numToRemove); } } } }
//private SnapshotNodeType type=Type; // These two are for UI to construct. public void ConnectTo(uint connectToUid, int localIndex, int otherIndex, bool isConnectingFromInputSlot, string name = "") { Connection connection = new Connection(); connection.LocalIndex = localIndex; connection.LocalName = name; connection.OtherIndex = otherIndex; connection.OtherNode = connectToUid; if (isConnectingFromInputSlot) { InputList.Add(connection); } else { OutputList.Add(connection); } }
/// <summary> /// Adds an input to the console. If the input already exists, it will be updated with the new value. /// This updates the input regex if the input did not previously exist. /// </summary> /// <param name="inputName">The name of the input to add.</param> /// <param name="inputData">The data corresponding to the input.</param> /// <returns>true if the input was added, otherwise false.</returns> public bool AddInput(string inputName, InputData inputData) { bool existed = ConsoleInputs.ContainsKey(inputName); ConsoleInputs[inputName] = inputData; if (existed == false) { InputList.Add(inputData); UpdateInputRegex(); } else { int index = InputList.FindIndex((inpData) => inpData.Name == inputName); InputList.RemoveAt(index); InputList.Add(inputData); } return(true); }
public void AddKeyPressText(string text) { byte[] chars = Encoding.ASCII.GetBytes(text); for (int i = 0; i < chars.Length; i++) { ushort scanCode = chars[i]; INPUT input = new INPUT(); input.Type = InputType.InputKeyboard; input.Data.Keyboard = new KEYBDINPUT(); input.Data.Keyboard.wScan = scanCode; input.Data.Keyboard.dwFlags = KeyboardEventFlags.KEYEVENTF_UNICODE; if ((scanCode & 0xFF00) == 0xE000) { input.Data.Keyboard.dwFlags |= KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY; } InputList.Add(input); input.Data.Keyboard.dwFlags |= KeyboardEventFlags.KEYEVENTF_KEYUP; InputList.Add(input); } }
public static void Add <T, U>(this InputList <Union <T, U> > list, Input <U> value) => list.Add(value.ToOutput().Apply(v => (Union <T, U>)v));