private string GetMetadata([NotNull] string name) { XName dataName = Namespace + name; XElement dataNode = MetadataElement.Elements(dataName).SingleOrDefault(); return(dataNode == null ? null : dataNode.Value); }
public T Read <T>(MetadataElement metadataElement) { var name = AsMetadataKey(metadataElement); var value = _metadataCollection[name]; if (value == null) { return(default);
public void when_region_not_valid_then_should_fail(string region) { var metadataElement = new MetadataElement { CallBackUrl = new Uri("https://api.imdcloud:9090/message"), Region = region }; var result = validator.TestValidate(metadataElement); result.ShouldHaveValidationErrorFor(m => m.Region); }
private Metadata ToMetadata(MetadataElement metadata) { return(new Metadata { Contacts = metadata.Contacts.Cast <ContactElement>().Select(c => ToContact(c)).ToList(), ExcludeArtifactEndpoints = metadata.ExcludeArtifactEndpoints, Organization = ToOrganization(metadata.Organization), RequestedAttributes = metadata.RequestedAttributes.Select(a => ToAttribute(a)).ToList() }); }
public void when_callback_is_valid_then_should_pass() { var region = "eu-central-1"; var metadataElement = new MetadataElement { CallBackUrl = new Uri("https://api.imdcloud:9090/message"), Region = region }; var result = validator.TestValidate(metadataElement); result.ShouldNotHaveValidationErrorFor(m => m.CallBackUrl); }
public void when_callback_url_is_not_valid_then_should_fail(Uri callbackUrl) { var region = "eu-central-1"; var metadataElement = new MetadataElement { CallBackUrl = callbackUrl, Region = region }; var result = validator.TestValidate(metadataElement); result.ShouldHaveValidationErrorFor(m => m.CallBackUrl); }
public void UpdateMetadata(string key, string value) { if (_cacheMetadata.TryGetValue(key, out var index)) { MetadataElement metadata = new MetadataElement(key, value); _metadata.metadata[index] = metadata; } else { MetadataElement metadata = new MetadataElement(key, value); _metadata.metadata.Add(metadata); _cacheMetadata.Add(key, _metadata.metadata.Count - 1); } }
public void Write <T>(MetadataElement metadataElement, T value) { var stringValue = value as string; var valueToWrite = stringValue ?? JsonConvert.SerializeObject(value); if (!valueToWrite.StartsWith(Utf8Token, StringComparison.OrdinalIgnoreCase)) { valueToWrite = Utf8Token + Uri.EscapeDataString(valueToWrite); } var name = AsMetadataKey(metadataElement); _metadataCollection[name] = valueToWrite; }
public void LoadMetadata() { try { ReadOperation <string> operation = IOFactory.GetReadTextOperation(_pathToMetadata); operation.DoOperationSync(); string result = operation.GetResult(); _metadata = JsonUtility.FromJson <MetadataContainer>(result); for (int i = 0; i < _metadata.metadata.Count; i++) { MetadataElement element = _metadata.metadata[i]; _cacheMetadata.Add(element.key, i); } } catch (Exception e) { Debug.Log("Error at LoadMetadata : " + e.Message); throw; } }
/// <summary> /// Sets the metadata property with the specified name. /// </summary> /// <param name="name">The name.</param> /// <param name="value">The value.</param> /// <remarks></remarks> private void SetMetadata([NotNull] string name, [NotNull] string value) { XName dataName = Namespace + name; XElement dataNode = MetadataElement.Elements(dataName).SingleOrDefault(); if (dataNode == null) { dataNode = new XElement(dataName, value); MetadataElement.Add(dataNode); HasChanges = true; return; } if (dataNode.Value.Equals(value)) { return; } dataNode.SetValue(value); HasChanges = true; }
public T Read <T>(MetadataElement metadataElement) { var name = AsMetadataKey(metadataElement); var value = _metadataCollection[name]; if (value == null) { return(default(T)); } if (value.StartsWith(Utf8Token, StringComparison.OrdinalIgnoreCase)) { value = Uri.UnescapeDataString(value.Substring(Utf8Token.Length)); } if (typeof(T) == typeof(string)) { return((T)(object)value); } return(JsonConvert.DeserializeObject <T>(value)); }
private Metadata ToMetadata(MetadataElement metadata) { return new Metadata { Contacts = metadata.Contacts.Cast<ContactElement>().Select(c => ToContact(c)).ToList(), ExcludeArtifactEndpoints = metadata.ExcludeArtifactEndpoints, Organization = ToOrganization(metadata.Organization), RequestedAttributes = metadata.RequestedAttributes.Select(a => ToAttribute(a)).ToList() }; }
private static string AsMetadataKey(MetadataElement metadataElement) => $"x-amz-meta-{metadataElement.ToString().ToLower()}";
private void Deserialize() { _element = new MetadataElement(); Deserialize(_element); }