PredictiveCodeSuggestions.AutoTemplates.AutoTemplateBuilder.LoadDataFile C# (CSharp) Method

LoadDataFile() private method

Loads the data file.
private LoadDataFile ( string fileName ) : void
fileName string Name of the file.
return void
    private void LoadDataFile(string fileName)
    {
      XDocument doc;
      try
      {
        doc = XDocument.Load(fileName);
      }
      catch
      {
        return;
      }

      var root = doc.Root;
      if (root == null)
      {
        return;
      }

      foreach (var element in root.Elements())
      {
        try
        {
          var template = new Record
          {
            Key = element.GetAttributeValue("k"),
            Template = element.Value
          };

          var variables = element.GetAttributeValue("v").Split('|');
          for (var index = 0; index < variables.Length - 1; index += 2)
          {
            template.TemplateVariables[variables[index]] = variables[index + 1];
          }

          this.templates.Add(template);
        }
        catch
        {
          continue;
        }
      }
    }