public static string ConvertToUriLiteral(object value, ODataVersion version, IEdmModel model) { if (value == null) { value = new ODataNullValue(); } if (model == null) { model = Microsoft.OData.Edm.Library.EdmCoreModel.Instance; } ODataNullValue nullValue = value as ODataNullValue; if (nullValue != null) { return(ExpressionConstants.KeywordNull); } ODataCollectionValue collectionValue = value as ODataCollectionValue; if (collectionValue != null) { return(ODataUriConversionUtils.ConvertToUriCollectionLiteral(collectionValue, model, version)); } ODataComplexValue complexValue = value as ODataComplexValue; if (complexValue != null) { return(ODataUriConversionUtils.ConvertToUriComplexLiteral(complexValue, model, version)); } ODataEnumValue enumValue = value as ODataEnumValue; if (enumValue != null) { return(ODataUriConversionUtils.ConvertToUriEnumLiteral(enumValue, version)); } // Try to convert uints to their underlying type first according to the model. value = model.ConvertToUnderlyingTypeIfUIntValue(value); return(ODataUriConversionUtils.ConvertToUriPrimitiveLiteral(value, version)); }
public static string ConvertToUriLiteral(object value, ODataVersion version, IEdmModel model) { if (value == null) { value = new ODataNullValue(); } if (model == null) { model = Microsoft.OData.Edm.Library.EdmCoreModel.Instance; } ODataNullValue nullValue = value as ODataNullValue; if (nullValue != null) { return(ExpressionConstants.KeywordNull); } ODataCollectionValue collectionValue = value as ODataCollectionValue; if (collectionValue != null) { return(ODataUriConversionUtils.ConvertToUriCollectionLiteral(collectionValue, model, version)); } ODataComplexValue complexValue = value as ODataComplexValue; if (complexValue != null) { return(ODataUriConversionUtils.ConvertToUriComplexLiteral(complexValue, model, version)); } ODataEnumValue enumValue = value as ODataEnumValue; if (enumValue != null) { return(ODataUriConversionUtils.ConvertToUriEnumLiteral(enumValue, version)); } return(ODataUriConversionUtils.ConvertToUriPrimitiveLiteral(value, version)); }
public static string ConvertToUriLiteral(object value, ODataVersion version, IEdmModel model) { if (value == null) { value = new ODataNullValue(); } if (model == null) { model = Microsoft.OData.Edm.Library.EdmCoreModel.Instance; } ODataNullValue nullValue = value as ODataNullValue; if (nullValue != null) { return(ExpressionConstants.KeywordNull); } ODataCollectionValue collectionValue = value as ODataCollectionValue; if (collectionValue != null) { return(ODataUriConversionUtils.ConvertToUriCollectionLiteral(collectionValue, model, version)); } ODataComplexValue complexValue = value as ODataComplexValue; if (complexValue != null) { return(ODataUriConversionUtils.ConvertToUriComplexLiteral(complexValue, model, version)); } ODataEnumValue enumValue = value as ODataEnumValue; if (enumValue != null) { return(ODataUriConversionUtils.ConvertToUriEnumLiteral(enumValue, version)); } ODataEntry entry = value as ODataEntry; if (entry != null) { return(ODataUriConversionUtils.ConvertToUriEntityLiteral(entry, model)); } ODataEntityReferenceLink link = value as ODataEntityReferenceLink; if (link != null) { return(ODataUriConversionUtils.ConvertToUriEntityReferenceLiteral(link, model)); } ODataEntityReferenceLinks links = value as ODataEntityReferenceLinks; if (links != null) { return(ODataUriConversionUtils.ConvertToUriEntityReferencesLiteral(links, model)); } var list = value as IEnumerable <ODataEntry>; if (list != null) { return(ODataUriConversionUtils.ConvertToUriEntitiesLiteral(list, model)); } // Try to convert uints to their underlying type first according to the model. value = model.ConvertToUnderlyingTypeIfUIntValue(value); return(ODataUriConversionUtils.ConvertToUriPrimitiveLiteral(value, version)); }