/// <summary> /// Gathers dependencies of ColumnInfo, this includes all [Sql] properties on any object in data export / catalogue databases /// which references the fully qualified name of the ColumnInfo as well as it's immediate network friends that should share it's /// runtime name e.g. CatalogueItem and ExtractionInformation. /// </summary> /// <param name="c"></param> /// <returns></returns> public GatheredObject GatherDependencies(ColumnInfo c) { var allObjects = GetAllObjectsInAllDatabases(); var propertyFinder = new AttributePropertyFinder <SqlAttribute>(allObjects); var root = new GatheredObject(c); foreach (var o in allObjects) { //don't add a reference to the thing we are gathering dependencies on! if (Equals(o, c)) { continue; } foreach (var propertyInfo in propertyFinder.GetProperties(o)) { var sql = (string)propertyInfo.GetValue(o); if (sql != null && sql.Contains(c.Name)) { root.Children.Add(new GatheredObject(o)); } } } return(root); }
/// <summary> /// Returns the text drawn for the object e.g. ToString() + (UsefulProperty) /// </summary> /// <param name="m"></param> /// <returns></returns> private string GetUsefulProperties(IMapsDirectlyToDatabaseTable m) { StringBuilder sb = new StringBuilder(); var p = _usefulPropertyFinder.GetProperties(m).ToArray(); if (p.Length == 0) { return(null); } sb.Append("("); foreach (var propertyInfo in p) { var attr = _usefulPropertyFinder.GetAttribute(propertyInfo); var key = string.IsNullOrWhiteSpace(attr.DisplayName) ? propertyInfo.Name : attr.DisplayName; var val = propertyInfo.GetValue(m); sb.Append(key + "='" + val + "' "); } sb.Append(")"); return(sb.ToString()); }