FastQuant.ParameterHelper.GetStrategyParameter C# (CSharp) Method

GetStrategyParameter() public method

public GetStrategyParameter ( string parameterName, object obj ) : object
parameterName string
obj object
return object
        public object GetStrategyParameter(string parameterName, object obj)
        {
            var field = obj.GetType().GetField(parameterName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            var property = obj.GetType().GetProperty(parameterName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (field != null && field.GetCustomAttributes(typeof(ParameterAttribute), true).Any())
                return field.GetValue(obj);

            if (property != null && property.GetCustomAttributes(typeof(ParameterAttribute), true).Any())
                return property.GetValue(obj);

            return null;
        }