private static Options GetOptionPairs(ElementRequest req, OptionsFromAttribute fromAttrib)
		{
			var fromProperty = req.Accessor.DeclaringType.GetProperties().FirstOrDefault(p => p.Name == fromAttrib.PropertyName);
			if (fromProperty == null)
			{
				throw new Exception(string.Format("Could not find options source property '{0}' on type '{1}'",
				                                  fromAttrib.PropertyName, req.Accessor.DeclaringType.Name));
			}
			return fromProperty.GetGetMethod().Invoke(req.Model, null) as Options;
		}
Esempio n. 2
0
        private static Options GetOptionPairs(ElementRequest req, OptionsFromAttribute fromAttrib)
        {
            var fromProperty = req.Accessor.DeclaringType.GetProperties()
                               .FirstOrDefault(p => p.Name == fromAttrib.PropertyName);

            if (fromProperty == null)
            {
                var message = string.Format("Could not find options source property '{0}' on type '{1}'",
                                            fromAttrib.PropertyName, req.Accessor.DeclaringType.Name);
                throw new Exception(message);
            }
            return(fromProperty.GetGetMethod().Invoke(req.Model, null) as Options);
        }