-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add - doc - Added MEMBER group property
--- We've added MEMBER, a group property that lists group members and is crucial for group vCards. --- Type: add Breaking: False Doc Required: True Backport Required: False Part: 1/1
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// | ||
// VisualCard Copyright (C) 2021-2024 Aptivi | ||
// | ||
// This file is part of VisualCard | ||
// | ||
// VisualCard is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// VisualCard is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY, without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
namespace VisualCard.Parts.Implementations | ||
{ | ||
/// <summary> | ||
/// Group member URI info | ||
/// </summary> | ||
[DebuggerDisplay("Member URI = {Member}")] | ||
public class MemberInfo : BaseCardPartInfo, IEquatable<MemberInfo> | ||
{ | ||
/// <summary> | ||
/// Encoded group member URI | ||
/// </summary> | ||
public string? MemberUri { get; } | ||
|
||
internal static BaseCardPartInfo FromStringVcardStatic(string value, string[] finalArgs, int altId, string[] elementTypes, string valueType, Version cardVersion) => | ||
new MemberInfo().FromStringVcardInternal(value, finalArgs, altId, elementTypes, valueType, cardVersion); | ||
|
||
internal override string ToStringVcardInternal(Version cardVersion) => | ||
MemberUri ?? ""; | ||
|
||
internal override BaseCardPartInfo FromStringVcardInternal(string value, string[] finalArgs, int altId, string[] elementTypes, string valueType, Version cardVersion) | ||
{ | ||
// Try to parse the source to ensure that it conforms the IETF RFC 1738: Uniform Resource Locators | ||
if (!Uri.TryCreate(value, UriKind.Absolute, out Uri uri)) | ||
throw new InvalidDataException($"source {value} is invalid"); | ||
value = uri.ToString(); | ||
|
||
// Populate the fields | ||
MemberInfo _source = new(altId, finalArgs, elementTypes, valueType, value); | ||
return _source; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) => | ||
Equals((MemberInfo)obj); | ||
|
||
/// <summary> | ||
/// Checks to see if both the parts are equal | ||
/// </summary> | ||
/// <param name="other">The target <see cref="MemberInfo"/> instance to check to see if they equal</param> | ||
/// <returns>True if all the part elements are equal. Otherwise, false.</returns> | ||
public bool Equals(MemberInfo other) => | ||
Equals(this, other); | ||
|
||
/// <summary> | ||
/// Checks to see if both the parts are equal | ||
/// </summary> | ||
/// <param name="source">The source <see cref="MemberInfo"/> instance to check to see if they equal</param> | ||
/// <param name="target">The target <see cref="MemberInfo"/> instance to check to see if they equal</param> | ||
/// <returns>True if all the part elements are equal. Otherwise, false.</returns> | ||
public bool Equals(MemberInfo source, MemberInfo target) | ||
{ | ||
// We can't perform this operation on null. | ||
if (source is null || target is null) | ||
return false; | ||
|
||
// Check all the properties | ||
return | ||
source.MemberUri == target.MemberUri | ||
; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() | ||
{ | ||
int hashCode = 881496785; | ||
hashCode = hashCode * -1521134295 + base.GetHashCode(); | ||
hashCode = hashCode * -1521134295 + EqualityComparer<string?>.Default.GetHashCode(MemberUri); | ||
return hashCode; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public static bool operator ==(MemberInfo left, MemberInfo right) => | ||
left.Equals(right); | ||
|
||
/// <inheritdoc/> | ||
public static bool operator !=(MemberInfo left, MemberInfo right) => | ||
!(left == right); | ||
|
||
internal override bool EqualsInternal(BaseCardPartInfo source, BaseCardPartInfo target) => | ||
((MemberInfo)source) == ((MemberInfo)target); | ||
|
||
internal MemberInfo() { } | ||
|
||
internal MemberInfo(int altId, string[] arguments, string[] elementTypes, string valueType, string source) : | ||
base(arguments, altId, elementTypes, valueType) | ||
{ | ||
MemberUri = source; | ||
} | ||
} | ||
} |