コード例 #1
0
        public static string GetTermResValue(eTermResKey termResourceKey, string prefixString = "", string suffixString = "", bool setToUpperCase = false)
        {
            object termResValue = null;

            try
            {
                //termResValue = (new FrameworkElement()).TryFindResource(termResourceKey.ToString());
                termResValue = Application.Current.Resources[termResourceKey.ToString()];
            }
            catch (Exception ex)
            {
                termResValue = null;
                Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}");
            }

            if (termResValue != null)
            {
                string strValue = prefixString + termResValue.ToString() + suffixString;
                if (setToUpperCase)
                {
                    strValue = strValue.ToUpper();
                }
                return(strValue);
            }
            else
            {
                //key not found
                return(string.Empty);
            }
        }
コード例 #2
0
 public static void LinkToTermResource(FrameworkElement obj, DependencyProperty objPropertyToLink, eTermResKey termResourceKey)
 {
     if (obj != null && objPropertyToLink != null) //&& termResourceKey != null ... termResourceKey is never null
     {
         obj.SetResourceReference(objPropertyToLink, termResourceKey.ToString());
     }
 }
コード例 #3
0
        public static string GetTerminologyValue(eTermResKey key)
        {
            KeyValuePair <string, string> result = new KeyValuePair <string, string>();

            switch (TERMINOLOGY_TYPE)
            {
            case eTerminologyType.Default:
                result = gingerTermDefaultList.Find(kvp => kvp.Key == key.ToString());
                break;

            case eTerminologyType.Gherkin:
                result = gingerTermGherkinList.Find(kvp => kvp.Key == key.ToString());
                break;

            case eTerminologyType.Testing:
                result = gingerTermTestingList.Find(kvp => kvp.Key == key.ToString());
                break;
            }
            return(result.Value);
        }