Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Add xml Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Роман Воронцов committed Mar 1, 2021
1 parent 33fe31d commit 7f44cb7
Show file tree
Hide file tree
Showing 322 changed files with 2,525 additions and 569 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*.nuget.props
*.nuget.targets
*.orig
*.DS_Store
*.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This method is available in both synchronous and asynchronous implementations.
## Response
| `Parameter` | `Description` | `The data type of the parameter` |
|:---------------------:|:---------------------------|:--------------------------------:|
| `Result` | Execution result | `IChatApiCreateInstanceResult`
| `Result` | Result of creating a Chat Api instance | `IChatApiCreateInstanceResult`

## Parameters of the `IChatApiCreateInstanceResult`
| `Parameter` | `Description` | `The data type of the parameter` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This method is available in both synchronous and asynchronous implementations.
| `PaidTill` | End date of the paid period | `DateTime`
| `Instance` | The unique identifier of the instance | `String`
| `IsActive` | An indicator of the activity instance | `Boolean`
| `TypeInstance` | Instance t ype | `ChatApiInstanceType`
| `TypeInstance` | Instance type | `ChatApiInstanceType`
| `PaymentsCount` | Number of paid months | `Integer`

## Example
Expand Down
File renamed without changes
89 changes: 56 additions & 33 deletions Src/ChatApi.Core/ChatApi.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>

<!-- Basic technical information about the project -->
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>

<!-- Generating a NuGet package (with docs) -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>

<!-- Information about the NuGet package -->
<Title>ChatApi.Core</Title>
<Authors>Roman Vorontsov</Authors>
<Description>ChatApi is an unofficial cross-platform libraries for interacting with the chat-api.com</Description>
<PackageLicenseUrl></PackageLicenseUrl>
<RepositoryUrl>https://github.com/Zodt/ChatApi</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<NeutralLanguage>en</NeutralLanguage>
<PackageIcon>ChatApi.png</PackageIcon>
<PackageVersion>1.0.1-alpha</PackageVersion>
<PackageTags>ChatApi, WhatsAppApi, WhatsApp-Api, WhatsApp</PackageTags>
<PackageProjectUrl></PackageProjectUrl>
<Description>
ChatApi is an unofficial cross-platform libraries for interacting with the chat-api.com
</Description>
<ReleaseNotes>
1. Refactoring code
2. Add xml doc
</ReleaseNotes>

<!-- NuGet Package license information -->
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageIcon>ChatApi.png</PackageIcon>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<!-- Information about the project repository -->
<RepositoryType>GitHub</RepositoryType>
<RepositoryUrl>https://github.com/Zodt/ChatApi</RepositoryUrl>

</PropertyGroup>

<ItemGroup>
<None Include="..\ChatApi.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>

<!-- References -->
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />

<!-- Resources -->
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>

<!-- NuGet project logo -->
<None Include="../../Images/ChatApi.png">
<Pack>True</Pack>
<PackagePath />
</None>

</ItemGroup>

</Project>
<!-- Copying a NuGet package to a specific directory -->
<Target Name="CopyCustomContent" AfterTargets="AfterBuild"
Condition="Exists('..\..\Src\$(ProjectName)\bin\$(Configuration)\$(ProjectName).$(PackageVersion).nupkg')">
<Copy SourceFiles="..\..\Src\$(ProjectName)\bin\$(Configuration)\$(ProjectName).$(PackageVersion).nupkg"
DestinationFolder="..\..\NuGet\$(PackageVersion)" SkipUnchangedFiles="false" ContinueOnError="true" />
</Target>

</Project>
89 changes: 73 additions & 16 deletions Src/ChatApi.Core/Collections/WhatsAppApiCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@

namespace ChatApi.Core.Collections
{
/// <summary>Provides the base class for a generic WhatsApp-collection.</summary>
/// <typeparam name="T">The type of elements in the collection.</typeparam>
public abstract class WhatsAppApiCollection<T> : Collection<T?>, IPrintableCollection, IEquatable<Collection<T?>?> where T : class, IEquatable<T?>
{
#region Overridden collection methods

/// <summary>
/// Adds an object to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1"></see>.
/// </summary>
/// <param name="item">The object to be added to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1"></see>. The value can be null for reference types.</param>
public new void Add(T item)
{
if (Items.Contains(item)) return;
Expand All @@ -22,39 +28,71 @@ public abstract class WhatsAppApiCollection<T> : Collection<T?>, IPrintableColle

#region AddRange

public void AddRange(IEnumerable<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IEnumerable`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IEnumerable`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IEnumerable<T> collection)
{
IList<T> list = enumerable.ToList();
if (collection is null) throw new ArgumentNullException(nameof(collection));

IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
base.Add(list[i]);
}
public void AddRange(IList<T> enumerable)

/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IList`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IList`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IList<T>? collection)
{
if (collection is null) throw new ArgumentNullException(nameof(collection));

// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < enumerable.Count; i++)
if (!Items.Contains(enumerable[i]))
base.Add(enumerable[i]);
for (int i = 0; i < collection.Count; i++)
if (!Items.Contains(collection[i]))
base.Add(collection[i]);
}
public void AddRange(ICollection<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.ICollection`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.ICollection`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(ICollection<T> collection)
{
IList<T> list = enumerable.ToList();
if (collection is null) throw new ArgumentNullException(nameof(collection));
IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
base.Add(list[i]);
}
public void AddRange(IReadOnlyList<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IReadOnlyList`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IReadOnlyList`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IReadOnlyList<T> collection)
{
if (collection is null) throw new ArgumentNullException(nameof(collection));
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < enumerable.Count; i++)
if (!Items.Contains(enumerable[i]))
base.Add(enumerable[i]);
for (int i = 0; i < collection.Count; i++)
if (!Items.Contains(collection[i]))
base.Add(collection[i]);
}
public void AddRange(IReadOnlyCollection<T> enumerable)
/// <summary>
/// Adds the elements of the specified collection to the end of the <see cref="T:System.Collections.Generic.IReadOnlyCollection`1"></see>.
/// </summary>
/// <param name="collection">The collection whose elements should be added to the end of the <see cref="T:System.Collections.Generic.IReadOnlyCollection`1"></see>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection">collection</paramref> is null.</exception>
public void AddRange(IReadOnlyCollection<T> collection)
{
IList<T> list = enumerable.ToList();
IList<T> list = collection.ToList();
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 0; i < list.Count; i++)
if (!Items.Contains(list[i]))
Expand All @@ -68,6 +106,7 @@ public void AddRange(IReadOnlyCollection<T> enumerable)

#region Equatable

/// <inheritdoc />
public bool Equals(Collection<T?>? other)
{
if (other is null || other.Count != Count) return false;
Expand All @@ -88,6 +127,7 @@ public bool Equals(Collection<T?>? other)
return true;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
Expand All @@ -102,8 +142,22 @@ public override int GetHashCode()
}
}

/// <inheritdoc />
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || obj is Collection<T?> self && Equals(self);

/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator == (WhatsAppApiCollection<T>? left, WhatsAppApiCollection<T>? right) => EquatableHelper.IsEquatable(left, right);
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator != (WhatsAppApiCollection<T>? left, WhatsAppApiCollection<T>? right) => !EquatableHelper.IsEquatable(left, right);

#endregion
Expand All @@ -128,6 +182,7 @@ private static string GetShift(int? shiftValue)
return stringBuilder.ToString();
}

/// <inheritdoc />
public string PrintMembers()
{
int shift = default;
Expand Down Expand Up @@ -155,6 +210,7 @@ public string PrintMembers()

return _stringBuilder.ToString();
}
/// <inheritdoc />
public string PrintMembers(int shift)
{
_stringBuilder.AppendLine("[");
Expand All @@ -167,11 +223,11 @@ public string PrintMembers(int shift)
int maxPrint = Count >= 3 ? 3 : Count;

string currentShift = GetShift(++shift);
if (this[0] is Printable)
if (this[0] is IPrintable)
for (int i = 0; i <= maxPrint - 1; i++)
_stringBuilder.AppendLine(string.Concat((this[i] as Printable)!.PrintMembers(shift-1), ", "));

else if (this[0] is string || !typeof(T).IsInterface)
else if (!typeof(T).IsInterface || !typeof(T).IsClass)
for (int i = 0; i <= maxPrint - 1; i++)
_stringBuilder.AppendLine(string.Concat(currentShift, this[i], ", "));

Expand All @@ -184,6 +240,7 @@ public string PrintMembers(int shift)
return _stringBuilder.ToString();
}

/// <inheritdoc />
public string PrintMembers(int countElementPrint, int shift)
{
_stringBuilder.AppendLine("[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IChatApiInstanceConnect : IConnect, IChatApiKey { }
}
1 change: 1 addition & 0 deletions Src/ChatApi.Core/Connect/Interfaces/IConnect.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IConnect { }
}
10 changes: 10 additions & 0 deletions Src/ChatApi.Core/Connect/Interfaces/IWhatsAppConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

namespace ChatApi.Core.Connect.Interfaces
{
/// <summary/>
public interface IWhatsAppConnect : IConnect, IEquatable<IWhatsAppConnect?>
{
/// <summary>
/// The unique identifier of the instance
/// </summary>
string? Token { get; }
/// <summary>
/// The prefix of the server. The old logic
/// </summary>
string? Server { get; }
/// <summary>
/// A unique token for accessing the server for this instance
/// </summary>
string? Instance { get; }
}
}
19 changes: 15 additions & 4 deletions Src/ChatApi.Core/Connect/WhatsAppConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,37 @@

namespace ChatApi.Core.Connect
{
/// <inheritdoc />
public class WhatsAppConnect : IWhatsAppConnect
{
/// <inheritdoc />
public string Token { get; }
/// <inheritdoc />
public string Server { get; }
/// <inheritdoc />
public string Instance { get; }

// ReSharper disable once MemberCanBePrivate.Global
/// <summary/>
public WhatsAppConnect(string server, string instance, string token) =>
(Server, Instance, Token) = (server, instance, token);

/// <summary/>
public WhatsAppConnect(string server, int instance, string token) :
this(server, instance.ToString(), token) { }

#region Equatable

/// <inheritdoc />
public bool Equals(IWhatsAppConnect? other) => other is not null &&
string.Equals(Token, other.Token, StringComparison.Ordinal) &&
string.Equals(Server, other.Server, StringComparison.Ordinal) &&
string.Equals(Instance, other.Instance, StringComparison.Ordinal);
string.Equals(Token, other.Token, StringComparison.Ordinal) &&
string.Equals(Server, other.Server, StringComparison.Ordinal) &&
string.Equals(Instance, other.Instance, StringComparison.Ordinal);
/// <inheritdoc />
public override bool Equals(object? obj) => ReferenceEquals(this, obj) ||
obj is IWhatsAppConnect other && Equals(other);
obj is IWhatsAppConnect other && Equals(other);

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
Expand All @@ -37,7 +46,9 @@ public override int GetHashCode()
}
}

/// <summary/>
public static bool operator == (WhatsAppConnect? left, WhatsAppConnect? right) => EquatableHelper.IsEquatable(left, right);
/// <summary/>
public static bool operator != (WhatsAppConnect? left, WhatsAppConnect? right) => !EquatableHelper.IsEquatable(left, right);

#endregion
Expand Down
Loading

0 comments on commit 7f44cb7

Please sign in to comment.