public void WriteYaml(YamlWriter writer) { writer.WriteBeginListItem("Language", Language); if (UnversionedFields.Count > 0) { writer.WriteMap("Fields"); writer.IncreaseIndent(); foreach (var unversionedField in UnversionedFields) { unversionedField.WriteYaml(writer); } writer.DecreaseIndent(); } writer.WriteMap("Versions"); writer.IncreaseIndent(); foreach (var version in Versions) { version.WriteYaml(writer); } writer.DecreaseIndent(); }
public void WriteYaml(YamlWriter writer) { // at times we may receive an empty language with no fields or versions // we avoid writing it the output, as it's irrelevant if (UnversionedFields.Count == 0 && Versions.Count == 0) { return; } writer.WriteBeginListItem("Language", Language); if (UnversionedFields.Count > 0) { writer.WriteMap("Fields"); writer.IncreaseIndent(); foreach (var unversionedField in UnversionedFields) { unversionedField.WriteYaml(writer); } writer.DecreaseIndent(); } writer.WriteMap("Versions"); writer.IncreaseIndent(); foreach (var version in Versions) { version.WriteYaml(writer); } writer.DecreaseIndent(); }
public virtual void WriteSerializedUser(SyncUser userData, Stream outputStream) { Assert.ArgumentNotNull(userData, nameof(userData)); Assert.ArgumentNotNull(outputStream, "outputStream"); using (var writer = new YamlWriter(outputStream, 4096, true)) { writer.WriteMap("Username", userData.UserName); writer.WriteMap("Email", userData.Email); writer.WriteMap("Comment", userData.Comment ?? string.Empty); writer.WriteMap("Created", userData.CreationDate.ToString("O")); writer.WriteMap("IsApproved", userData.IsApproved.ToString()); if (userData.ProfileProperties.Any()) { writer.WriteMap("Properties"); writer.IncreaseIndent(); userData.ProfileProperties.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); userData.ProfileProperties.ForEach(profileProperty => { writer.WriteBeginListItem("Key", profileProperty.Name); writer.WriteMap("Value", GetSerializedProfileContent(profileProperty)); writer.WriteMap("ValueType", profileProperty.Content.GetType().AssemblyQualifiedName); writer.WriteMap("IsCustom", profileProperty.IsCustomProperty.ToString()); }); writer.DecreaseIndent(); } if (userData.Roles.Any()) { userData.Roles.Sort(); writer.WriteMap("Roles"); writer.IncreaseIndent(); userData.Roles.ForEach(roleName => { writer.WriteMap("MemberOf", roleName); }); writer.DecreaseIndent(); } } }
public void WriteYaml(YamlWriter writer) { writer.WriteBeginListItem("Version", VersionNumber.ToString()); if (Fields.Any()) { writer.WriteMap("Fields"); writer.IncreaseIndent(); foreach (var field in Fields) { field.WriteYaml(writer); } writer.DecreaseIndent(); } }
public void WriteYaml(YamlWriter writer) { writer.WriteBeginListItem("ID", Id.ToString("D")); if (!string.IsNullOrWhiteSpace(NameHint)) { writer.WriteMap("Hint", NameHint); } if (BlobId.HasValue) { writer.WriteMap("BlobID", BlobId.Value.ToString("D")); } if (Type != null) { writer.WriteMap("Type", Type); } writer.WriteMap("Value", Value); }