public static IFieldOptions Create(PropertyInfo property, IEditableRoot editableRoot) { if (property == null) { throw new ArgumentNullException("property"); } if (editableRoot == null) { throw new ArgumentNullException("editableRoot"); } var crossRefAttr = property.GetCustomAttributes(typeof(CrossRefFieldAttribute), false).Select(d => d).FirstOrDefault() as CrossRefFieldAttribute; if (crossRefAttr == null) { throw new VeyronException("CrossRef attribute not found on Cross-reference field property"); } string valueAsText = "Unknown"; var crId = editableRoot.GetValueByPropertyName(property.Name) as int?; if (crId.HasValue) { var ancestor = editableRoot.GetAncestor(property); if (ancestor != null) { var crItem = DynamicTypeManager.Instance.GetCrossReferenceItem(ancestor.ProcessName, property.Name, crId.Value); if (crItem != null) { valueAsText = crItem.GetValueByPropertyName(crossRefAttr.RefFieldName) == null ? "Unknown" : crItem.GetValueByPropertyName(crossRefAttr.RefFieldName).ToString(); } } } var result = new SingleCrossRefFieldOptions { ValueAsText = valueAsText, ProcessSystemName = crossRefAttr.ReferenceTableName, FieldName = crossRefAttr.RefFieldName, AllowViewDetail = crossRefAttr.AllowViewDetail, AllowClear = crossRefAttr.AllowClear }; return result; }