context: using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Globalization;
  using System.Linq;
  using System.Reflection;
  using System.Text;
  using System.Xml.Serialization;
  
  namespace BmwFileReader
  {
      public static class EcuFunctionStructs
      {
          [XmlInclude(typeof(EcuFaultCodeLabel)), XmlInclude(typeof(EcuFaultModeLabel)), XmlInclude(typeof(EcuEnvCondLabel))]
          [XmlType("FDat")]
          public class EcuFaultData
          {
              public EcuFaultData()
              {
                  EcuFaultCodeLabelList = null;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FAULTDATA:");
                  sb.Append(this.PropertyList(prefix + " "));
  #if false
                  if (EcuFaultCodeLabelList != null)
                  {
                      foreach (EcuFaultCodeLabel ecuFaultCodeLabel in EcuFaultCodeLabelList)
                      {
                          sb.Append(ecuFaultCodeLabel.ToString(prefix + " "));
                      }
                  }
  
                  if (EcuFaultModeLabelList != null)
                  {
                      foreach (EcuFaultModeLabel ecuFaultModeLabel in EcuFaultModeLabelList)
                      {
                          sb.Append(ecuFaultModeLabel.ToString(prefix + " "));
                      }
                  }
  
                  if (EcuEnvCondLabelList != null)
                  {
                      foreach (EcuEnvCondLabel ecuEnvCondLabel in EcuEnvCondLabelList)
                      {
                          sb.Append(ecuEnvCondLabel.ToString(prefix + " "));
                      }
                  }
  #endif
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              [XmlArray("EFCLL"), DefaultValue(null)] public List<EcuFaultCodeLabel> EcuFaultCodeLabelList { get; set; }
              [XmlArray("EFMLL"), DefaultValue(null)] public List<EcuFaultModeLabel> EcuFaultModeLabelList { get; set; }
              [XmlArray("EECLL"), DefaultValue(null)] public List<EcuEnvCondLabel> EcuEnvCondLabelList { get; set; }
          }
  
          [XmlInclude(typeof(EcuTranslation)), XmlInclude(typeof(EcuTranslation)), XmlInclude(typeof(EcuFuncStruct)), XmlInclude(typeof(EcuFaultCode))]
          [XmlType("Var")]
          public class EcuVariant
          {
              public EcuVariant()
              {
                  Id = string.Empty;
                  GroupId = string.Empty;
                  GroupFunctionIds = null;
                  Title = null;
              }
  
              public EcuVariant(string id, string groupId, EcuTranslation title, List<string> groupFunctionIds)
              {
                  Id = id;
                  GroupId = groupId;
                  GroupFunctionIds = groupFunctionIds;
                  Title = title;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "VARIANT:");
                  sb.Append(this.PropertyList(prefix + " "));
  
                  if (GroupFunctionIds != null)
                  {
                      sb.Append(prefix + " GROUPFUNC:");
                      foreach (string GroupFunctionId in GroupFunctionIds)
                      {
                          sb.Append(" " + GroupFunctionId);
                      }
                      sb.AppendLine();
                  }
  
                  if (Title != null)
                  {
                      sb.Append(Title.ToString(prefix + " "));
                  }
  
                  if (RefEcuVariantList != null)
                  {
                      foreach (RefEcuVariant refEcuVariant in RefEcuVariantList)
                      {
                          sb.Append(refEcuVariant.ToString(prefix + " "));
                      }
                  }
  
                  if (EcuFuncStructList != null)
                  {
                      foreach (EcuFuncStruct ecuFuncStruct in EcuFuncStructList)
                      {
                          sb.Append(ecuFuncStruct.ToString(prefix + " "));
                      }
                  }
  
                  if (EcuFaultCodeList != null)
                  {
                      foreach (EcuFaultCode ecuFaultCode in EcuFaultCodeList)
                      {
                          sb.Append(ecuFaultCode.ToString(prefix + " "));
                      }
                  }
  
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              public void ClearCompatIds()
              {
                  if (RefEcuVariantList != null)
                  {
                      foreach (RefEcuVariant refEcuVariant in RefEcuVariantList)
                      {
                          refEcuVariant.ClearCompatIds();
                      }
                  }
  
                  if (EcuFuncStructList != null)
                  {
                      foreach (EcuFuncStruct ecuFuncStruct in EcuFuncStructList)
                      {
                          ecuFuncStruct.ClearCompatIds();
                      }
                  }
              }
  
              [XmlElement, DefaultValue("")] public string Id { get; set; }
              [XmlElement("GId"), DefaultValue("")] public string GroupId { get; set; }
              [XmlElement("Tit"), DefaultValue(null)] public EcuTranslation Title { get; set; }
              [XmlArray("GFId"), XmlArrayItem("Str"), DefaultValue(null)] public List<string> GroupFunctionIds { get; set; }
              [XmlArray("RVL"), DefaultValue(null)] public List<RefEcuVariant> RefEcuVariantList { get; set; }
              [XmlArray("FSL"), DefaultValue(null)] public List<EcuFuncStruct> EcuFuncStructList { get; set; }
              [XmlArray("FCL"), DefaultValue(null)] public List<EcuFaultCode> EcuFaultCodeList { get; set; }
              [XmlIgnore] public Dictionary<Int64, EcuFaultCode> EcuFaultCodeDict { get; set; }
          }
  
          [XmlInclude(typeof(EcuFaultCodeLabel)), XmlInclude(typeof(EcuFaultModeLabel)), XmlInclude(typeof(EcuEnvCondLabel))]
          [XmlType("FCod")]
          public class EcuFaultCode
          {
              public EcuFaultCode()
              {
                  Id = string.Empty;
                  Code = string.Empty;
                  EcuFaultCodeLabelId = string.Empty;
              }
  
              public EcuFaultCode(string id, string code)
              {
                  Id = id;
                  Code = code;
                  EcuFaultCodeLabelId = string.Empty;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FAULTCODE:");
                  sb.Append(this.PropertyList(prefix + " "));
  
                  if (EcuFaultCodeLabel != null)
                  {
                      sb.Append(EcuFaultCodeLabel.ToString(prefix + " "));
                  }
  
                  if (EcuFaultModeLabelList != null)
                  {
                      foreach (EcuFaultModeLabel ecuFaultModeLabel in EcuFaultModeLabelList)
                      {
                          sb.Append(ecuFaultModeLabel.ToString(prefix + " "));
                      }
                  }
  
                  if (EcuEnvCondLabelList != null)
                  {
                      foreach (EcuEnvCondLabel ecuEnvCondLabel in EcuEnvCondLabelList)
                      {
                          sb.Append(ecuEnvCondLabel.ToString(prefix + " "));
                      }
                  }
  
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              [XmlElement, DefaultValue("")] public string Id { get; set; }
              [XmlElement, DefaultValue("")] public string Code { get; set; }
              [XmlIgnore, XmlElement, DefaultValue(null)] public EcuFaultCodeLabel EcuFaultCodeLabel { get; set; }
              [XmlElement("FCLIdL"), DefaultValue("")] public string EcuFaultCodeLabelId { get; set; }
              [XmlIgnore, XmlArray, DefaultValue(null)] public List<EcuFaultModeLabel> EcuFaultModeLabelList { get; set; }
              [XmlArray("FMLIdL"), XmlArrayItem("Str"), DefaultValue(null)] public List<string> EcuFaultModeLabelIdList { get; set; }
              [XmlIgnore, XmlArray, DefaultValue(null)] public List<EcuEnvCondLabel> EcuEnvCondLabelList { get; set; }
              [XmlArray("ECLIdL"), XmlArrayItem("Str"), DefaultValue(null)] public List<string> EcuEnvCondLabelIdList { get; set; }
          }
  
          [XmlType("FCLab")]
          public class EcuFaultCodeLabel
          {
              public EcuFaultCodeLabel()
              {
                  Id = string.Empty;
                  Code = string.Empty;
                  SaeCode = string.Empty;
                  Relevance = string.Empty;
                  DataType = string.Empty;
              }
  
              public EcuFaultCodeLabel(string id, string code, string saeCode, EcuTranslation title, string relevance, string dataType)
              {
                  Id = id;
                  Code = code;
                  SaeCode = saeCode;
                  Title = title;
                  Relevance = relevance;
                  DataType = dataType;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FAULTCODELABEL:");
                  sb.Append(this.PropertyList(prefix + " "));
  
                  if (Title != null)
                  {
                      sb.Append(Title.ToString(prefix + " "));
                  }
  
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              [XmlElement, DefaultValue("")] public string Id { get; set; }
              [XmlElement("Cod"), DefaultValue("")] public string Code { get; set; }
              [XmlElement("Sae"), DefaultValue("")] public string SaeCode { get; set; }
              [XmlElement("Tit"), DefaultValue(null)] public EcuTranslation Title { get; set; }
              [XmlElement("Rel"), DefaultValue("")] public string Relevance { get; set; }
              [XmlElement("DTyp"), DefaultValue("")] public string DataType { get; set; }
          }
  
          [XmlType("FMLab")]
          public class EcuFaultModeLabel
          {
              public EcuFaultModeLabel()
              {
                  Id = string.Empty;
                  Code = string.Empty;
                  Relevance = string.Empty;
                  Extended = string.Empty;
              }
  
              public EcuFaultModeLabel(string id, string code, EcuTranslation title, string relevance, string extended)
              {
                  Id = id;
                  Code = code;
                  Title = title;
                  Relevance = relevance;
                  Extended = extended;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FAULTMODELABEL:");
                  sb.Append(this.PropertyList(prefix + " "));
  
                  if (Title != null)
                  {
                      sb.Append(Title.ToString(prefix + " "));
                  }
  
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              [XmlElement, DefaultValue("")] public string Id { get; set; }
              [XmlElement("Cod"), DefaultValue("")] public string Code { get; set; }
              [XmlElement("Tit"), DefaultValue(null)] public EcuTranslation Title { get; set; }
              [XmlElement("Rel"), DefaultValue("")] public string Relevance { get; set; }
              [XmlElement("Ext"), DefaultValue("")] public string Extended { get; set; }
          }
  
          [XmlType("ECLab")]
          [XmlInclude(typeof(EcuTranslation)), XmlInclude(typeof(EcuResultStateValue))]
          public class EcuEnvCondLabel
          {
              public EcuEnvCondLabel()
              {
                  Id = string.Empty;
                  NodeClass = string.Empty;
                  Relevance = string.Empty;
                  BlockCount = string.Empty;
                  IdentType = string.Empty;
                  IdentStr = string.Empty;
                  Unit = string.Empty;
              }
  
              public EcuEnvCondLabel(string id, string nodeClass, EcuTranslation title, string relevance, string blockCount, string identType, string identStr, string unit)
              {
                  Id = id;
                  NodeClass = nodeClass;
                  Title = title;
                  Relevance = relevance;
                  BlockCount = blockCount;
                  IdentType = identType;
                  IdentStr = identStr;
                  Unit = unit;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FAULTMODELABEL:");
                  sb.Append(this.PropertyList(prefix + " "));
  
                  if (Title != null)
                  {
                      sb.Append(Title.ToString(prefix + " "));
                  }
  
                  if (EcuResultStateValueList != null)
                  {
                      foreach (EcuResultStateValue ecuResultStateValue in EcuResultStateValueList)
                      {
                          sb.Append(ecuResultStateValue.ToString(prefix + " "));
                      }
                  }
  
                  return sb.ToString();
              }
  
              public override string ToString()
              {
                  return ToString("");
              }
  
              [XmlElement, DefaultValue("")] public string Id { get; set; }
              [XmlElement("NC"), DefaultValue("")] public string NodeClass { get; set; }
              [XmlElement("Tit"), DefaultValue(null)] public EcuTranslation Title { get; set; }
              [XmlElement("Rel"), DefaultValue("")] public string Relevance { get; set; }
              [XmlElement("BCnt"), DefaultValue("")] public string BlockCount { get; set; }
              [XmlElement("ITyp"), DefaultValue("")] public string IdentType { get; set; }
              [XmlElement("IStr"), DefaultValue("")] public string IdentStr { get; set; }
              [XmlElement("Uni"), DefaultValue("")] public string Unit { get; set; }
              [XmlArray("RSVL"), DefaultValue(null)] public List<EcuResultStateValue> EcuResultStateValueList { get; set; }
              [XmlIgnore] public bool EcuResultStateValueListSpecified
              {
                  get
                  {
                      if (EcuResultStateValueList != null && EcuResultStateValueList.Count > 0)
                      {
                          return true;
                      }
                      return false;
                  }
              }
          }
  
          [XmlInclude(typeof(EcuTranslation)), XmlInclude(typeof(EcuJob))]
          [XmlType("FFStr")]
          public class EcuFixedFuncStruct
          {
              public enum NodeClassType
              {
                  Unknown,
                  Identification,
                  ReadState,
                  ControlActuator
              }
  
              public EcuFixedFuncStruct()
              {
                  Id = string.Empty;
                  NodeClass = string.Empty;
                  NodeClassName = string.Empty;
                  Title = null;
                  PrepOp = null;
                  ProcOp = null;
                  PostOp = null;
                  SortOrder = string.Empty;
                  Activation = string.Empty;
                  ActivationDurationMs = string.Empty;
              }
  
              public EcuFixedFuncStruct(string id, string nodeClass, string nodeClassName,
                  EcuTranslation title, EcuTranslation preOp, EcuTranslation procOp, EcuTranslation postOp,
                  string sortOrder, string activation, string activationDuringMs)
              {
                  Id = id;
                  NodeClass = nodeClass;
                  NodeClassName = nodeClassName;
                  Title = title;
                  PrepOp = preOp;
                  ProcOp = procOp;
                  PostOp = postOp;
                  SortOrder = sortOrder;
                  Activation = activation;
                  ActivationDurationMs = activationDuringMs;
              }
  
              public string ToString(string prefix)
              {
                  StringBuilder sb = new StringBuilder();
                  sb.AppendLine(prefix + "FIXEDFUNC:");
                  sb.Append(this.PropertyList(prefix + " "));
  
  
gt:                 if (Title != null)