public CSharpWriter(string flow, ProtocolModel model) { flow_ = flow; // class_name. string work_str; if (flow_ == "s2c") work_str = model.srv_name + '2' + model.cli_name; else work_str = model.cli_name + '2' + model.srv_name; bool is_upper = true; foreach (var c in work_str) { if (c == '_') { is_upper = true; continue; } if (c == '2') { is_upper = true; class_name += c; continue; } if (is_upper) { class_name += char.ToUpper(c); is_upper = false; continue; } class_name += c; } model_ = model; }
public HeaderWriter(string flow, ProtocolModel model) { flow_ = flow; // file_name. if (flow_ == "s2c") file_name = model.srv_name + '2' + model.cli_name; else file_name = model.cli_name + '2' + model.srv_name; // class_name. bool is_upper = true; foreach (var c in file_name) { if (c == '_') { is_upper = true; continue; } if (c == '2') { is_upper = true; class_name += c; continue; } if (is_upper) { class_name += char.ToUpper(c); is_upper = false; continue; } class_name += c; } model_ = model; }
void ReadXml() { Console.WriteLine("パスを入力して下さい。"); var path = Console.ReadLine(); FileStream fs = null; try { fs = new FileStream(path, FileMode.Open); } catch (Exception e) { Err(e.Message); } bool is_serialized = false; try { XmlSerializer serializer = new XmlSerializer(typeof(ProtocolModel)); protocol_model_ = (ProtocolModel)serializer.Deserialize(fs); is_serialized = true; Console.WriteLine("Protocolファイルのコンパイルを開始します。"); } catch (Exception) { fs.Seek(0, SeekOrigin.Begin); } try { XmlSerializer serializer = new XmlSerializer(typeof(EnumModel)); enum_model_ = (EnumModel)serializer.Deserialize(fs); is_serialized = true; Console.WriteLine("Enumファイルのコンパイルを開始します。"); } catch (Exception) { fs.Seek(0, SeekOrigin.Begin); } if (!is_serialized) { Err("正しくないファイルです。"); } }