Пример #1
0
        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;
        }
Пример #2
0
 public Tag(object myRuntimeObject, HubClassTagAttribute hubClassTag)
 {
     Id = Guid.NewGuid();
     MyRuntimeObject      = myRuntimeObject;
     MyRuntimeHubClassTag = hubClassTag;
 }
Пример #3
0
 public SearchTag(PropertyInfo myPropertyInfo, HubClassTagAttribute hubClassTag)
 {
     MyPropertyInfo       = myPropertyInfo;
     MyRuntimeHubClassTag = hubClassTag;
     SearchTags           = new List <SearchTag>();
 }
Пример #4
0
 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);
         }
     }
 }
Пример #5
0
 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);
         }
     }
 }