public StringBuilder GetSkipToken() { object[] skipTokenProperties = this.GetSkipTokenProperties(); bool flag = true; for (int i = 0; i < skipTokenProperties.Length; i++) { string str; object obj2 = skipTokenProperties[i]; if (obj2 == null) { str = "null"; } else if (!WebConvert.TryKeyPrimitiveToString(obj2, out str)) { throw new InvalidOperationException(System.Data.Services.Strings.Serializer_CannotConvertValue(obj2)); } if (!flag) { this.skipToken.Append(','); } this.skipToken.Append(str); flag = false; } return(this.skipToken); }
internal static bool TryKeyPrimitiveToString(object value, out string result) { if (IsBinaryValue(value)) { return(TryKeyBinaryToString(value, out result)); } return(WebConvert.TryKeyPrimitiveToString(value, out result)); }
private static string GetObjectKey(object resource, ResourceType resourceType, DataServiceProviderWrapper provider, string containerName) { StringBuilder builder = new StringBuilder(); builder.Append(containerName); builder.Append('('); IList <ResourceProperty> keyProperties = resourceType.KeyProperties; for (int i = 0; i < keyProperties.Count; i++) { string str; ResourceProperty resourceProperty = keyProperties[i]; object obj2 = WebUtil.GetPropertyValue(provider, resource, resourceType, resourceProperty, null); if (obj2 == null) { throw new InvalidOperationException(System.Data.Services.Strings.Serializer_NullKeysAreNotSupported(resourceProperty.Name)); } if (i == 0) { if (keyProperties.Count != 1) { builder.Append(resourceProperty.Name); builder.Append('='); } } else { builder.Append(','); builder.Append(resourceProperty.Name); builder.Append('='); } if (!WebConvert.TryKeyPrimitiveToString(obj2, out str)) { throw new InvalidOperationException(System.Data.Services.Strings.Serializer_CannotConvertValue(obj2)); } builder.Append(str); } builder.Append(')'); return(builder.ToString()); }
internal static string GetETagValue(object resource, ResourceType resourceType, ICollection <ResourceProperty> etagProperties, IDataService service, bool getMethod) { StringBuilder builder = new StringBuilder(); bool flag = true; builder.Append("W/\""); foreach (ResourceProperty property in etagProperties) { object obj2; string str; if (getMethod) { obj2 = GetPropertyValue(service.Provider, resource, resourceType, property, null); } else { obj2 = service.Updatable.GetValue(resource, property.Name); } if (flag) { flag = false; } else { builder.Append(','); } if (obj2 == null) { str = "null"; } else if (!WebConvert.TryKeyPrimitiveToString(obj2, out str)) { throw new InvalidOperationException(System.Data.Services.Strings.Serializer_CannotConvertValue(obj2)); } builder.Append(str); } builder.Append('"'); return(builder.ToString()); }
internal static bool TryKeyBinaryToString(object binaryValue, out string result) { byte[] buffer = (byte[])binaryValue.GetType().InvokeMember("ToArray", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, binaryValue, null, CultureInfo.InvariantCulture); return(WebConvert.TryKeyPrimitiveToString(buffer, out result)); }