private string TypeNameForUri(Type type) { type = (Nullable.GetUnderlyingType(type) ?? type); if (ClientConvert.IsKnownType(type)) { if (ClientConvert.IsSupportedPrimitiveTypeForUri(type)) { return(ClientConvert.ToTypeName(type)); } throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Can't cast to unsupported type '{0}'", type.Name)); } return(null); }
internal override Expression VisitUnary(UnaryExpression u) { if (ResourceBinder.PatternRules.MatchConvertToAssignable(u)) { return(base.VisitUnary(u)); } if (u.NodeType == ExpressionType.Convert || u.NodeType == ExpressionType.ConvertChecked) { Type obj = Nullable.GetUnderlyingType(u.Operand.Type) ?? u.Operand.Type; Type type = Nullable.GetUnderlyingType(u.Type) ?? u.Type; if (ClientConvert.IsKnownType(obj) && ClientConvert.IsKnownType(type)) { return(base.Visit(u.Operand)); } } throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Initializing instances of the entity type {0} with the expression {1} is not supported.", this.type, u.ToString())); }