/// <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 MainFunction() { var columnTypes = GetColumns(Input) .Where(e => !string.IsNullOrEmpty(e.ColumnType)) .Where(t => t.IsChecked) .Where(t => !t.IsPrimaryKey) .Select(s => s.ColumnType) .ToList(); foreach (var item in columnTypes) { var inputType = "InputNumber"; if (item == "string" || item == "char" || item == "Guid") { inputType = "InputText"; } else if (inputType == "bool") { inputType = "InputCheckbox"; } else if (inputType == "DateTime") { inputType = "InputDate"; } OutputList.Add(inputType); } }
//wyluskanie kolejnych miast z tablicy poprzednikow private static void GetOptimalPath (int start, Int64 set) { if (p[start][set] == Int16.MaxValue) return; Int64 mask = powah - 1 - (1 << p[start][set]), maskedSet = mask & set; OutputList.Add(p[start][set]); GetOptimalPath(p[start][set], maskedSet); }
public void CheckButton() { OutputList.Clear(); if (CheckTextBox != "") { OutputList.Add("Text Box is not empty"); } if (CheckCheckBox == true) { OutputList.Add("Check Box is checked"); } if (CheckRadioButton == true) { OutputList.Add("Radio Button is checked"); } if (CheckCheckBox == true && CheckRadioButton == true) { CheckLabel = "Activated Label"; OutputList.Add("Label is not empty"); } switch (Index) { case choices.One: OutputList.Add("Number 1 was selected"); break; case choices.Two: OutputList.Add("Number 2 was selected"); break; case choices.Three: OutputList.Add("Number 3 was selected"); break; case choices.Four: OutputList.Add("Number 4 was selected"); break; default: break; } }
public override void Shift() { WindowList.Sort(); int i; for (i = 0; (i < WindowList.Count) && (WindowList[i].SequenceNumber == _windowBegin); i++) { _windowBegin = WindowList[i].RequiredAck; OutputList.Add(WindowList[i]); } for (int k = 0; k < i; k++) { WindowList.RemoveAt(0); } }
//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); } }
private void PrintChildren(TreeViewItemViewModel item, int level) { string prefix = string.Empty; for (int i = 0; i < level; i++) { prefix += " "; } OutputList.Add(prefix + item.Name); foreach (var child in item.Children) { if (child.IsExpanded) { PrintChildren(child, level + 1); } } }
/// <summary> /// Domyślny konstruktor /// </summary> public MainWindowViewModel() : base() { _extractOperation = new ExtractOperation(); _transformOperation = new TransformOperation(); _loadOperation = new LoadOperation(); _etlOperations = new List <IPipelineOperation> { _extractOperation, _transformOperation, _loadOperation }; OutputList.Add("Starting.."); Logger.NewLogAppeared += (sender, msg) => Application.Current.Dispatcher.Invoke(() => { OutputList.Add(msg); OnPropertyChanged("TabIndex"); }); }
public static TimeSpan TimeMeasured { get; private set; } //zmierzony czas wykonywania obliczen #endregion //rozwiazanie problemu dla podanych danych wejsciowych public static void SolveTsp (TspGraph input) { if (input.Dimension > 2 && input.Name != null && input.GraphMatrix != null) { //jesli udalo sie zainicjalizowac zasoby bez problemow, to mozna wykonac obliczenia bool allright = Init(input); if (allright) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); PathDistance = ComputeDistance(0, powah - 2); stopwatch.Stop(); TimeMeasured = stopwatch.Elapsed; OutputList.Add(0); GetOptimalPath(0, powah - 2); OutputList.Add(0); } else Console.WriteLine("Nie wykonano obliczeń, ponieważ wystąpił błąd."); } else Console.WriteLine("Przed uruchomieniem algorytmu wczytaj odpowiednio dane wejściowe.\n(Wciśnij dowolny klawisz aby wrócić)"); }
//This function is to generate a list of Vector3 for further usage. //As the rotation angles and accelerations are relatively small numbers, //while the Vector3 contains 3 float numbers with 1 degree accuracy, //The numbers are multiplied by 1000000000. This is also our standard of mass of objects. //Hence the final output of accelerations are numerically the same as drag forces. private void GenerateList(string fileName) { StreamReader stream = File.OpenText(fileName); string entireText = stream.ReadToEnd(); stream.Close(); using (StringReader reader = new StringReader(entireText)) { string currentText = reader.ReadLine(); float xRotation; float yRotation; float acceleration; do { xRotation = float.Parse(currentText, System.Globalization.CultureInfo.InvariantCulture.NumberFormat) * 1000000000; currentText = reader.ReadLine(); yRotation = float.Parse(currentText, System.Globalization.CultureInfo.InvariantCulture.NumberFormat) * 1000000000; currentText = reader.ReadLine(); acceleration = float.Parse(currentText, System.Globalization.CultureInfo.InvariantCulture.NumberFormat) * 1000000000; Vector3 temp = new Vector3(xRotation, yRotation, acceleration); OutputList.Add(temp); currentText = reader.ReadLine(); }while(currentText != null); } //Write object results to database //writeObjectRecord(); Application.Quit(); }
public void Dispose() { OutputList.Add("DISPOSE"); }
private async Task ExecuteAsync() { instructionPointer = 0; while (memory[instructionPointer] != HCF) { var(opCode, parameterModes) = CalculateOpCodeAndParameterModes(memory[instructionPointer]); switch (opCode) { case ADD: SetParameterValue(2, GetParameterValue(0) + GetParameterValue(1)); instructionPointer += 4; break; case MUL: SetParameterValue(2, GetParameterValue(0) * GetParameterValue(1)); instructionPointer += 4; break; case INP: //throw new InvalidOperationException("Encountered INP while inputs has ran out of data"); if (inputOverride.HasValue) { SetParameterValue(0, inputOverride.Value); } else { InputRequested?.Invoke(this, input); SetParameterValue(0, await input.ReceiveAsync()); } instructionPointer += 2; break; case OUT: var o = GetParameterValue(0); output.Post(o); OutputList.Add(o); OutputHappened?.Invoke(this, o); instructionPointer += 2; break; case JNZ: instructionPointer = GetParameterValue(0) != 0 ? GetParameterValue(1) : instructionPointer + 3; break; case JZ: instructionPointer = GetParameterValue(0) == 0 ? GetParameterValue(1) : instructionPointer + 3; break; case LT: SetParameterValue(2, GetParameterValue(0) < GetParameterValue(1) ? 1 : 0); instructionPointer += 4; break; case EQ: SetParameterValue(2, GetParameterValue(0) == GetParameterValue(1) ? 1 : 0); instructionPointer += 4; break; case SETREL: relativeBase += GetParameterValue(0); instructionPointer += 2; break; default: throw new InvalidOperationException($"Invalid instruction at {instructionPointer} : {memory[instructionPointer]}"); // returns parameter value in both immediate and position mode long GetParameterValue(int parameterIndex) { long parameter = ReadMemory(instructionPointer + parameterIndex + 1); long result; switch (parameterModes[parameterIndex]) { case ParameterModes.Position: result = ReadMemory(parameter); break; case ParameterModes.Immediate: result = parameter; break; case ParameterModes.Relative: result = ReadMemory(relativeBase + parameter); break; default: throw new ArgumentOutOfRangeException(); } return(result); } void SetParameterValue(int parameterIndex, long value) { var parameter = ReadMemory(instructionPointer + parameterIndex + 1); int result; switch (parameterModes[parameterIndex]) { case ParameterModes.Position: WriteMemory(parameter, value); break; case ParameterModes.Relative: WriteMemory(relativeBase + parameter, value); break; default: throw new ArgumentOutOfRangeException(); } } } if (memory.Length < instructionPointer + 1) { throw new InvalidOperationException("Missing HCF"); } } }
static StaticConstructorExample() { OutputList.Add(".CCTOR"); }
public void CreateOutput(IStream stream) { var filterchainOutput = FilterchainOutput.Create(this, stream); OutputList.Add(filterchainOutput); }
private async Task ExecuteAsync() { instructionPointer = 0; while (memory[instructionPointer] != HCF) { var(opCode, parameterModes) = CalculateOpCodeAndParameterModes(memory[instructionPointer]); switch (opCode) { case ADD: memory[memory[instructionPointer + 3]] = GetParameterValue(0) + GetParameterValue(1); instructionPointer += 4; break; case MUL: memory[memory[instructionPointer + 3]] = GetParameterValue(0) * GetParameterValue(1); instructionPointer += 4; break; case INP: //throw new InvalidOperationException("Encountered INP while inputs has ran out of data"); memory[memory[instructionPointer + 1]] = await input.ReceiveAsync(); instructionPointer += 2; break; case OUT: var o = GetParameterValue(0); output.Post(o); OutputList.Add(o); instructionPointer += 2; break; case JNZ: instructionPointer = GetParameterValue(0) != 0 ? GetParameterValue(1) : instructionPointer + 3; break; case JZ: instructionPointer = GetParameterValue(0) == 0 ? GetParameterValue(1) : instructionPointer + 3; break; case LT: memory[memory[instructionPointer + 3]] = GetParameterValue(0) < GetParameterValue(1) ? 1 : 0; instructionPointer += 4; break; case EQ: memory[memory[instructionPointer + 3]] = GetParameterValue(0) == GetParameterValue(1) ? 1 : 0; instructionPointer += 4; break; default: throw new InvalidOperationException($"Invalid instruction at {instructionPointer} : {memory[instructionPointer]}"); // returns parameter value in both immediate and position mode int GetParameterValue(int parameterIndex) { int parameter = memory[instructionPointer + parameterIndex + 1]; return(parameterModes[parameterIndex] == ParameterModes.Immediate ? parameter : memory[parameter]); } } if (memory.Length < instructionPointer + 1) { throw new InvalidOperationException("Missing HCF"); } } }