示例#1
0
        /// <summary>
        /// Returns Custom attributes used in the user strategy
        /// </summary>
        private Dictionary <int, Tuple <string, Type> > GetCustomAttributes(Type strategyType)
        {
            try
            {
                // Contains custom defined attributes in the given assembly
                Dictionary <int, Tuple <string, Type> > customAttributes = null;

                // Get Custom Attributes
                if (strategyType != null)
                {
                    // Get custom attributes from the given assembly
                    customAttributes = LoadCustomStrategy.GetCustomAttributes(strategyType);
                }

                return(customAttributes);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "GetCustomAttributes");
                return(null);
            }
        }
        public void GetCustomAttributesTestCase()
        {
            // Load Assembly file from the selected file
            Assembly assembly = Assembly.LoadFrom(_assemblyName);

            // Contains custom defined attributes in the given assembly
            Dictionary <int, Tuple <string, Type> > customAttributes = null;

            // Get Constructor information for the given assembly
            var strategyDetails = LoadCustomStrategy.GetConstructorDetails(assembly);

            if (strategyDetails != null)
            {
                // Get Strategy Type
                var strategyType = strategyDetails.Item1;

                // Get custom attributes from the given assembly
                customAttributes = LoadCustomStrategy.GetCustomAttributes(strategyType);
            }

            Assert.IsNotNull(strategyDetails, "Constructor Information for the given assembly was not found.");
            Assert.IsNotNull(customAttributes, "Custom attributes were not found in the given assembly.");
            Assert.AreEqual(3, customAttributes.Count, "Count of read custom attributes was not equal to expected value.");
        }
示例#3
0
 /// <summary>
 /// Get custom attributes of type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static Dictionary <int, Tuple <string, Type> > GetCustomAttributes(Type type)
 {
     return(LoadCustomStrategy.GetCustomAttributes(type));
 }