protected virtual Type GetType(string typeName) { if (typeName == null) { throw new ArgumentNullException("typeName"); } return(TypeResolution.GetType(typeName)); }
private static readonly string[] Truths = { "true", "yes", "on", "1" }; // TODO Remove duplication with SecurityConfiguration private static object ParseArgument(ParameterInfo parameter, XmlElement config) { Debug.Assert(parameter != null); Debug.Assert(config != null); var name = parameter.Name; var type = parameter.ParameterType; string text; var attribute = config.GetAttributeNode(name); if (attribute != null) { text = attribute.Value; } else { var element = config[name]; if (element == null) { return(null); } text = element.InnerText; } if (type == typeof(IContextExpression)) { return(new WebDataBindingExpression(text)); } if (type == typeof(Type)) { return(TypeResolution.GetType(text)); } if (type == typeof(bool)) { text = text.Trim().ToLowerInvariant(); return(bool.TrueString.Equals(Array.IndexOf(Truths, text) >= 0 ? bool.TrueString : text)); } var converter = TypeDescriptor.GetConverter(type); return(converter.ConvertFromInvariantString(text)); }
protected virtual object GetFeatureByName(string name) { IDictionary features = Features; if (features == null || !features.Contains(name)) { throw new JsonRpcException(string.Format("There is no feature registered for '{0}' type of requests.", name)); } string featureTypeSpec = Mask.NullString((string)features[name]); if (featureTypeSpec.Length == 0) { throw new JsonRpcException("Missing feature type specification."); } Type featureType = TypeResolution.GetType(featureTypeSpec); return(Activator.CreateInstance(featureType, new object[] { this })); }