<commit_before>/*******************************************************************************
  * Copyright (C) 2015 AgGateway and ADAPT Contributors
  * Copyright (C) 2015 Deere and Company
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html <http://www.eclipse.org/legal/epl-v10.html>
  *
  * Contributors:
  *    <NAME> - initial API and implementation
  *******************************************************************************/
using AgGateway.ADAPT.Representation.UnitSystem.ExtensionMethods;
using System;
using System.IO;
using System.Reflection;

namespace AgGateway.ADAPT.Representation.UnitSystem
{
  public static class UnitSystemManager
  {
    private static string _unitSystemDataLocation = null;

    public static string UnitSystemDataLocation
    {
      get
      {
        if (_unitSystemDataLocation == null)
        {
          var assemblyLocation = AppDomain.CurrentDomain.BaseDirectory;
          var repSystemXml = Path.Combine(assemblyLocation, "Resources", "UnitSystem.xml");
          return repSystemXml;
        }
        else
        {
          return _unitSystemDataLocation;
        }
      }
      set { _unitSystemDataLocation = value; }
    }

    public static ApplicationDataModel.Common.UnitOfMeasure GetUnitOfMeasure(string code)
    {
      return InternalUnitSystemManager.Instance.UnitOfMeasures[code].ToModelUom();
    }

    public static ApplicationDataModel.Common.UnitOfMeasure FromUNRec20Code(string code)
    {
      var domainId = InternalUnitSystemManager.Instance.UnRec20CodeToDomainId[code];
      return GetUnitOfMeasure(domainId);
    }

    public static string GetUNRec20Code(ApplicationDataModel.Common.UnitOfMeasure uom)
    {
      return InternalUnitSystemManager.Instance.DomainIdToUnRec20Code[uom.Code];
    }
  }
}<commit_msg>Checking for presence of unit code before invoking indexer on it.<commit_after>/*******************************************************************************
  * Copyright (C) 2015 AgGateway and ADAPT Contributors
  * Copyright (C) 2015 Deere and Company
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html <http://www.eclipse.org/legal/epl-v10.html>
  *
  * Contributors:
  *    <NAME> - initial API and implementation
  *******************************************************************************/
using AgGateway.ADAPT.Representation.UnitSystem.ExtensionMethods;
using System;
using System.IO;
using System.Reflection;

namespace AgGateway.ADAPT.Representation.UnitSystem
{
  public static class UnitSystemManager
  {
    private static string _unitSystemDataLocation = null;

    public static string UnitSystemDataLocation
    {
      get
      {
        if (_unitSystemDataLocation == null)
        {
          var assemblyLocation = AppDomain.CurrentDomain.BaseDirectory;
          var repSystemXml = Path.Combine(assemblyLocation, "Resources", "UnitSystem.xml");
          return repSystemXml;
        }
        else
        {
          return _unitSystemDataLocation;
        }
      }
      set { _unitSystemDataLocation = value; }
    }

    public static ApplicationDataModel.Common.UnitOfMeasure GetUnitOfMeasure(string code)
    {
        if (InternalUnitSystemManager.Instance.UnitOfMeasures.Contains(code))
        {
            return InternalUnitSystemManager.Instance.UnitOfMeasures[code].ToModelUom();
        }
        return null;
    }

    public static ApplicationDataModel.Common.UnitOfMeasure FromUNRec20Code(string code)
    {
      var domainId = InternalUnitSystemManager.Instance.UnRec20CodeToDomainId[code];
      return GetUnitOfMeasure(domainId);
    }

    public static string GetUNRec20Code(ApplicationDataModel.Common.UnitOfMeasure uom)
    {
      return InternalUnitSystemManager.Instance.DomainIdToUnRec20Code[uom.Code];
    }
  }
}
{'fraction_non_alphanumeric': 0.14491017964071856, 'fraction_numerical': 0.010538922155688623, 'mean_word_length': 3.6041896361631753, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '251205', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1062, 'n_words': 250}