public virtual void WriteSerializedRole(IRoleData roleData, Stream outputStream) { Assert.ArgumentNotNull(roleData, nameof(roleData)); Assert.ArgumentNotNull(outputStream, "outputStream"); var memberOfRoles = roleData.MemberOfRoles; using (var writer = new YamlWriter(outputStream, 4096, true)) { writer.WriteMap("Role", roleData.RoleName); if (memberOfRoles.Any()) { writer.WriteMap("MemberOf"); writer.IncreaseIndent(); foreach (var memberOfRole in memberOfRoles) { writer.WriteMap("Role", memberOfRole); } writer.DecreaseIndent(); } } }
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 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); }
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 virtual void WriteYaml(YamlWriter writer) { writer.WriteMap("ID", Id.ToString("D")); writer.WriteMap("Parent", ParentId.ToString("D")); writer.WriteMap("Template", TemplateId.ToString("D")); writer.WriteMap("Path", Path); writer.WriteMap("DB", DatabaseName); if (BranchId != default(Guid)) { writer.WriteMap("BranchID", BranchId.ToString()); } if (SharedFields.Any()) { writer.WriteMap("SharedFields"); writer.IncreaseIndent(); foreach (var field in SharedFields) { field.WriteYaml(writer); } writer.DecreaseIndent(); } if (Languages.Any()) { writer.WriteMap("Languages"); writer.IncreaseIndent(); foreach (var language in Languages) { language.WriteYaml(writer); } writer.DecreaseIndent(); } }
public virtual void WriteYaml(YamlWriter writer) { writer.WriteMap("ID", Id.ToString("D")); writer.WriteMap("Parent", ParentId.ToString("D")); writer.WriteMap("Template", TemplateId.ToString("D")); writer.WriteMap("Path", Path); writer.WriteMap("DB", DatabaseName); if (BranchId != default(Guid)) writer.WriteMap("BranchID", BranchId.ToString()); if (SharedFields.Any()) { writer.WriteMap("SharedFields"); writer.IncreaseIndent(); foreach (var field in SharedFields) { field.WriteYaml(writer); } writer.DecreaseIndent(); } if (Languages.Any()) { writer.WriteMap("Languages"); writer.IncreaseIndent(); foreach (var language in Languages) { language.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(); } } }