internal void AddPropertyValuesToTagComment(object objItem, HubClassTagAttribute objAttribute) { if (objItem == null || objAttribute == null) { return; } Type objItemType = objItem.GetType(); StringBuilder sbdPropertyValues = new StringBuilder(byte.MaxValue); foreach (string strProperty in objAttribute.ListCommentProperties) { System.Reflection.PropertyInfo objProperty = objItemType.GetProperties().FirstOrDefault(p => p.Name == strProperty); if (objProperty == null) { throw new ArgumentOutOfRangeException("Could not find property " + strProperty + " on instance of type " + objItemType + "."); } string strPropertyValue = objProperty.GetValue(objItem)?.ToString(); if (!string.IsNullOrEmpty(strPropertyValue)) { sbdPropertyValues.Append(strPropertyValue).Append(' '); } } if (sbdPropertyValues.Length > 0) { sbdPropertyValues.Remove(sbdPropertyValues.Length - 1, 1); // Remove trailing whitespace } TagComment += sbdPropertyValues; }
public Tag(object myRuntimeObject, HubClassTagAttribute hubClassTag) { Id = Guid.NewGuid(); MyRuntimeObject = myRuntimeObject; MyRuntimeHubClassTag = hubClassTag; }
public SearchTag(PropertyInfo myPropertyInfo, HubClassTagAttribute hubClassTag) { MyPropertyInfo = myPropertyInfo; MyRuntimeHubClassTag = hubClassTag; SearchTags = new List <SearchTag>(); }
private static IEnumerable <Tag> ExtractTagsFromExtraProperties(object objPropertyHaver, HubClassTagAttribute objPropertyFilterAttribute) { PropertyInfo[] aPropertyInfos = objPropertyHaver.GetType().GetProperties(); foreach (string includeprop in objPropertyFilterAttribute.ListExtraProperties) { PropertyInfo propfound = aPropertyInfos.Find(x => x.Name == includeprop); if (propfound == null) { //sometimes we simply don't have a specialication (for example) if (includeprop == "Specialization") { continue; } throw new ArgumentOutOfRangeException("Could not find property " + includeprop + " on instance of type " + objPropertyHaver.GetType() + " with name " + objPropertyHaver.ToString() + "."); } object includeInstance = propfound.GetValue(objPropertyHaver); if (includeInstance != null && !string.IsNullOrEmpty(includeInstance.ToString())) { Tag instanceTag = new Tag(includeInstance, objPropertyFilterAttribute) { TagName = includeprop, TagValue = includeInstance.ToString() }; instanceTag.SetTagTypeEnumFromCLRType(objPropertyHaver.GetType()); yield return(instanceTag); } } }
private static IEnumerable <Tag> ExtractTagsFromExtraProperties(object objPropertyHaver, HubClassTagAttribute objPropertyFilterAttribute) { PropertyInfo[] aPropertyInfos = objPropertyHaver.GetType().GetProperties(); foreach (string includeprop in objPropertyFilterAttribute.ListExtraProperties) { var propfound = aPropertyInfos.FirstOrDefault(x => x.Name == includeprop); if (propfound == null) { throw new ArgumentOutOfRangeException("Could not find property " + includeprop + " on instance of type " + objPropertyHaver.GetType() + "."); } var includeInstance = propfound.GetValue(objPropertyHaver); if (includeInstance != null && !string.IsNullOrEmpty(includeInstance.ToString())) { var instanceTag = new Tag(includeInstance, objPropertyFilterAttribute) { TagName = includeprop, TagValue = includeInstance.ToString() }; instanceTag.SetTagTypeEnumFromCLRType(objPropertyHaver.GetType()); yield return(instanceTag); } } }