private void Generate() { if (!string.IsNullOrEmpty(ImportPathTextBox.Text) && !string.IsNullOrEmpty(ProtoFileTextBox.Text)) { List <string> messages = ProtoFileTools.Generate(ProtoFileTextBox.Text, ImportPathTextBox.Text); MessagesComboBox.ItemsSource = messages; } }
public static void SetMessages(string path, ObservableCollection <PbMessage> pbMessages) { try { byte[] bytes = null; object msgBody = SetMessage(pbMessages[0]); bytes = ProtoFileTools.MessageToBytes(msgBody); File.WriteAllBytes(path, bytes); } catch (Exception ex) { logger.Error(ex); } }
public static ObservableCollection <PbMessage> GetMessages(string path, string messageType) { ObservableCollection <PbMessage> pbMessages = new ObservableCollection <PbMessage>(); try { byte[] data = File.ReadAllBytes(path); object msgBody = ProtoFileTools.ParseMessage(data, messageType); if (msgBody == null) { return(null); } pbMessages.Add(GetMessage(msgBody, msgBody.GetType().Name, null)); } catch (Exception ex) { logger.Error(ex); } return(pbMessages); }