/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static object GetValue(this IBHoMObject obj, string propName) { IBHoMObject bhom = obj as IBHoMObject; if (obj == null || propName == null) { return(null); } if (bhom.CustomData.ContainsKey(propName)) { if (!(bhom is CustomObject)) { Compute.RecordNote($"{propName} is stored in CustomData"); } return(bhom.CustomData[propName]); } else { IFragment fragment = null; Type fragmentType = Create.Type(propName, true); if (fragmentType != null) { List <IFragment> matches = bhom.Fragments.Where(fr => fragmentType.IsAssignableFrom(fr.GetType())).ToList(); if (matches.Count > 1) { Compute.RecordWarning($"{bhom} contains more than one fragment of type {fragmentType.IToText()}. The first one will be returned."); } fragment = matches.FirstOrDefault(); } if (fragment == null) { Compute.RecordWarning($"{bhom} does not contain a property: {propName}, or: CustomData[{propName}], or fragment of type {propName}."); } return(fragment); } }