RDMFieldDictionary.GetFidDef(fid) throws exceptions when a field definition is not found. I would like to get interfaces that will not thrown exeptions when a field definition is not found.
You can implement your own extension methods, such as RDMFieldDictionary.TryGetFidDef() interfaces.
using ThomsonReuters.RFA.RDM;using ThomsonReuters.RFA.Common;namespace RDMFieldDictExtension{ public static class RDMFieldDictExtension { public static RDMFidDef TryGetFidDef(this RDMFieldDictionary dict, short fieldId, out RFA_String error) { RDMFidDef fidDef = null; error = new RFA_String(); try { fidDef = dict.GetFidDef(fieldId); }catch (InvalidUsageException ex) { error.Set(ex.Status.StatusText.ToString()); return null; } error.Set("Success"); return fidDef; } public static RDMFidDef TryGetFidDef(this RDMFieldDictionary dict, RFA_String fieldName, out RFA_String error) { RDMFidDef fidDef = null; error = new RFA_String(); try { fidDef = dict.GetFidDef(fieldName); } catch (InvalidUsageException ex) { error.Set(ex.Status.StatusText.ToString()); return null; } error.Set("Success"); return fidDef; } }}
The sample usage is:
using RDMFieldDictExtension; …… RFA_String error; currentFidDef = rdmFieldDict.TryGetFidDef(new RFA_String("UNKNOW_FIELD"), out error); if(currentFidDef == null) { System.Console.WriteLine("Error: " + error.ToString()); } else { System.Console.WriteLine(currentFidDef.LongName); }
This would have to be done manually, for example iterate through getMinNegField() to getMaxFieldId() and create your own lookup tree.
Long term this is not an issue with the Elektron SDK which will eventually have a .NET native release. Using ETA/C from .NET does not throw exceptions, using EMA/C++ completely hides the dictionary so it is no longer a concern.