private static GetNamedPropertyValue ( ICustomTypeDescriptor item, string propertyName, bool usesCaseSensitivePropertyNameMatch, bool exceptionThrownIfNoMatch ) : object | ||
item | ICustomTypeDescriptor | /// The ICustomTypeDescriptor implementation, from /// which to extract a named property's value. /// |
propertyName | string | /// The name of the property. /// |
usesCaseSensitivePropertyNameMatch | bool | /// A value indicating whether the property name match should be /// case-sensitive. /// |
exceptionThrownIfNoMatch | bool | /// A value indicating whether an exception should be thrown if /// no matching property can be found. /// |
return | object |
private async Task CreateDeviceCollection() { string response; string endpoint = string.Format("{0}dbs/{1}/colls", _docDbEndpoint, _dbId); JObject body = new JObject(); body.Add("id", _collectionName); using (WebClient client = new WebClient()) { BuildHeaders(client); client.Headers.Add(AUTHORIZATION_HEADER_KEY, GetAuthorizationToken("POST", COLLECTION_RESOURCE_TYPE, _dbId)); response = await AzureRetryHelper.OperationWithBasicRetryAsync <string>(async() => await client.UploadStringTaskAsync(endpoint, "POST", body.ToString())); object json = JObject.Parse(response); _collectionId = ReflectionHelper.GetNamedPropertyValue( json, "_rid", true, false).ToString(); } }
public async Task InitializeDeviceCollection() { IEnumerable collections; string topResponse; string endpoint = string.Format("{0}dbs/{1}/colls", _docDbEndpoint, _dbId); using (WebClient client = new WebClient()) { BuildHeaders(client); client.Headers.Add(AUTHORIZATION_HEADER_KEY, GetAuthorizationToken("GET", COLLECTION_RESOURCE_TYPE, _dbId)); topResponse = await AzureRetryHelper.OperationWithBasicRetryAsync <string>(async() => await client.DownloadStringTaskAsync(endpoint)); } object topJson = JObject.Parse(topResponse); collections = ReflectionHelper.GetNamedPropertyValue( topJson, "DocumentCollections", true, false) as IEnumerable; if (collections != null) { foreach (object col in collections) { object id = ReflectionHelper.GetNamedPropertyValue( col, "id", true, false); if ((id != null) && (id.ToString() == this._collectionName)) { object rid = ReflectionHelper.GetNamedPropertyValue( col, "_rid", true, false); if (rid != null) { this._collectionId = rid.ToString(); return; } } } } if (string.IsNullOrWhiteSpace(_collectionId)) { await CreateDeviceCollection(); } }