//3 структура private void button9_Click(object sender, RoutedEventArgs e) { if (textBox7.Text != "") { Test4SendStruct test4SendStruct; test4SendStruct.name = textBox7.Text; test4SendStruct.fre = textBox7.Text; test4SendStruct.ab = textBox7.Text; test4SendStruct.cd = textBox7.Text; test4SendStruct.count2 = new int[10000]; int[] ab = new int[10000]; for (int i = 0; i < 1000; i++) { Random rand = new Random(); ab[i] = rand.Next(0, 1000); } vc = new VMS(test4SendStruct); try { metaClassFor = new MetaClassForStructandtherdata(vc); // создаем объект BinaryFormatter BinaryFormatter formatter = new BinaryFormatter(); formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full; var stream = new MemoryStream(); formatter.Serialize(stream, metaClassFor); masterSyncStruct.send_multi_message(stream); Console.WriteLine(stream); } catch (Exception ex) { //Console.WriteLine(ex); logger.Error(ex); } } }
private void DisplayStruct(object meta) { try { Thread.Sleep(1000); metaClassFor = slaveSyncSruct.metaClass; var strucDeserization = metaClassFor.struct_which_need_transfer; Type type = strucDeserization.GetType(); this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { if (ms.testSendStruct.ab != null) { richTextBox.AppendText("testSendStruct \r\n"); richTextBox.AppendText(ms.testSendStruct.ab + "\r\n"); richTextBox.AppendText(ms.testSendStruct.cd + "\r\n"); richTextBox.AppendText(ms.testSendStruct.fre + "\r\n"); richTextBox.AppendText(ms.testSendStruct.name + "\r\n"); } if (ms.test2SendStruct.ab != null) { richTextBox.AppendText("test2SendStruct \r\n"); richTextBox.AppendText(ms.test2SendStruct.ab + "\r\n"); richTextBox.AppendText(ms.test2SendStruct.cd + "\r\n"); richTextBox.AppendText(ms.test2SendStruct.fre + "\r\n"); richTextBox.AppendText(ms.test2SendStruct.name + "\r\n"); richTextBox.AppendText(Convert.ToString(ms.test2SendStruct.count + "\r\n")); richTextBox.AppendText(Convert.ToString(ms.test2SendStruct.count2 + "\r\n")); } } ); } catch (Exception ex) { logger.Error(ex); //Console.WriteLine(ex); } }
private void button6_Click(object sender, RoutedEventArgs e) { if (textBox7.Text != "") { try { //Console.WriteLine("Запуск"); logger.Trace("Запуск"); TestSendStruct testSend; testSend.name = textBox7.Text; testSend.fre = textBox7.Text; testSend.ab = textBox7.Text; testSend.cd = textBox7.Text; MMS ms1 = new MMS(testSend); metaClassFor = new MetaClassForStructandtherdata(ms1); // создаем объект BinaryFormatter BinaryFormatter formatter = new BinaryFormatter(); formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full; var stream = new MemoryStream(); formatter.Serialize(stream, metaClassFor); //Console.WriteLine("Отправка данных"); logger.Trace("Отправка данных"); masterSyncStruct.send_multi_message(stream); Console.WriteLine(stream); } catch (Exception ex) { Console.WriteLine(ex); logger.Error(ex); } } }
private void button8_Click(object sender, RoutedEventArgs e) { if (textBox7.Text != "") { Test2SendStruct test2SendStruct; test2SendStruct.name = textBox7.Text; test2SendStruct.fre = textBox7.Text; test2SendStruct.ab = textBox7.Text; test2SendStruct.cd = textBox7.Text; test2SendStruct.count = 1; test2SendStruct.count2 = 2; ms = new MMS(test2SendStruct); try { metaClassFor = new MetaClassForStructandtherdata(ms); // создаем объект BinaryFormatter BinaryFormatter formatter = new BinaryFormatter(); formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full; var stream = new MemoryStream(); formatter.Serialize(stream, metaClassFor); masterSyncStruct.send_multi_message(stream); Console.WriteLine(stream); } catch (Exception ex) { //Console.WriteLine(ex); logger.Error(ex); } } }