Skip to content

Commit

Permalink
Merge pull request #342 from zapadi/dev/rework-foundation
Browse files Browse the repository at this point in the history
Dev/rework foundation
  • Loading branch information
zapadi authored Jan 9, 2024
2 parents b2c7371 + c29cec1 commit 6bef83d
Show file tree
Hide file tree
Showing 65 changed files with 2,000 additions and 911 deletions.
18 changes: 17 additions & 1 deletion src/redmine-net-api/Authentication/IRedmineAuthentication.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
/*
Copyright 2011 - 2023 Adrian Popescu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System.Net;

namespace Redmine.Net.Api;
namespace Redmine.Net.Api.Authentication;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2011 - 2023 Adrian Popescu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System.Net;

namespace Redmine.Net.Api.Authentication;
Expand All @@ -8,7 +24,7 @@ namespace Redmine.Net.Api.Authentication;
public sealed class RedmineApiKeyAuthentication: IRedmineAuthentication
{
/// <inheritdoc />
public string AuthenticationType { get; } = "X-Redmine-API-Key";
public string AuthenticationType => "X-Redmine-API-Key";

/// <inheritdoc />
public string Token { get; init; }
Expand Down
18 changes: 17 additions & 1 deletion src/redmine-net-api/Authentication/RedmineBasicAuthentication.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2011 - 2023 Adrian Popescu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System;
using System.Net;
using System.Text;
Expand All @@ -11,7 +27,7 @@ namespace Redmine.Net.Api.Authentication
public sealed class RedmineBasicAuthentication: IRedmineAuthentication
{
/// <inheritdoc />
public string AuthenticationType { get; } = "Basic";
public string AuthenticationType => "Basic";

/// <inheritdoc />
public string Token { get; init; }
Expand Down
18 changes: 17 additions & 1 deletion src/redmine-net-api/Authentication/RedmineNoAuthentication.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2011 - 2023 Adrian Popescu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System.Net;

namespace Redmine.Net.Api.Authentication;
Expand All @@ -8,7 +24,7 @@ namespace Redmine.Net.Api.Authentication;
public sealed class RedmineNoAuthentication: IRedmineAuthentication
{
/// <inheritdoc />
public string AuthenticationType { get; } = "NoAuth";
public string AuthenticationType => "NoAuth";

/// <inheritdoc />
public string Token { get; init; }
Expand Down
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/ConflictException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ConflictException(string format, Exception innerException, params object[
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -82,5 +83,6 @@ private ConflictException(SerializationInfo serializationInfo, StreamingContext
{

}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/ForbiddenException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ForbiddenException(string format, Exception innerException, params object
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -83,5 +84,6 @@ private ForbiddenException(SerializationInfo serializationInfo, StreamingContext
{

}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public InternalServerErrorException(string format, Exception innerException, par
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -83,5 +84,6 @@ private InternalServerErrorException(SerializationInfo serializationInfo, Stream
{

}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public NameResolutionFailureException(string format, Exception innerException, p
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -82,5 +83,6 @@ private NameResolutionFailureException(SerializationInfo serializationInfo, Stre
{

}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/NotAcceptableException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public NotAcceptableException(string format, Exception innerException, params ob
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -82,5 +83,6 @@ private NotAcceptableException(SerializationInfo serializationInfo, StreamingCon
{

}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public NotFoundException(string format, Exception innerException, params object[
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -83,5 +84,6 @@ private NotFoundException(SerializationInfo serializationInfo, StreamingContext
{

}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/RedmineApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public RedmineApiException(string message, Exception inner, string errorCode, bo
/// <value>Value indicating whether the exception is transient or not.</value>
public bool IsTransient { get; }

#if !(NET8_0_OR_GREATER)
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
Expand All @@ -81,5 +82,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
info.AddValue(nameof(this.ErrorCode), this.ErrorCode);
info.AddValue(nameof(this.IsTransient), this.IsTransient);
}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/RedmineException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public RedmineException(string format, Exception innerException, params object[]
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -83,5 +84,6 @@ protected RedmineException(SerializationInfo serializationInfo, StreamingContext
{

}
#endif
}
}
2 changes: 2 additions & 0 deletions src/redmine-net-api/Exceptions/RedmineTimeoutException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public RedmineTimeoutException(string format, Exception innerException, params o
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -85,5 +86,6 @@ private RedmineTimeoutException(SerializationInfo serializationInfo, StreamingCo
{

}
#endif
}
}
3 changes: 2 additions & 1 deletion src/redmine-net-api/Exceptions/UnauthorizedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public UnauthorizedException(string format, Exception innerException, params obj
: base(string.Format(CultureInfo.InvariantCulture,format, args), innerException)
{
}

#if !(NET8_0_OR_GREATER)
/// <summary>
///
/// </summary>
Expand All @@ -87,5 +87,6 @@ private UnauthorizedException(SerializationInfo serializationInfo, StreamingCont
{

}
#endif
}
}
45 changes: 45 additions & 0 deletions src/redmine-net-api/Extensions/IntExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2011 - 2023 Adrian Popescu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

namespace Redmine.Net.Api.Extensions;

internal static class IntExtensions
{
public static bool Between(this int val, int from, int to)
{
return val >= from && val <= to;
}

public static bool Greater(this int val, int than)
{
return val > than;
}

public static bool GreaterOrEqual(this int val, int than)
{
return val >= than;
}

public static bool Lower(this int val, int than)
{
return val < than;
}

public static bool LowerOrEqual(this int val, int than)
{
return val <= than;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static async Task RemoveWatcherFromIssueAsync(this RedmineManager redmine
[Obsolete(RedmineConstants.OBSOLETE_TEXT)]
public static async Task<int> CountAsync<T>(this RedmineManager redmineManager, params string[] include) where T : class, new()
{
return await RedmineManagerExtensions.CountAsync<T>(redmineManager, include).ConfigureAwait(false);
return await redmineManager.CountAsync<T>(null, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -265,7 +265,7 @@ public static async Task<List<T>> GetObjectsAsync<T>(this RedmineManager redmine
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions(parameters);
return await redmineManager.GetObjectsAsync<T>(requestOptions).ConfigureAwait(false);
return await redmineManager.GetAsync<T>(requestOptions).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -281,7 +281,7 @@ public static async Task<T> GetObjectAsync<T>(this RedmineManager redmineManager
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions(parameters);
return await redmineManager.GetObjectAsync<T>(id, requestOptions).ConfigureAwait(false);
return await redmineManager.GetAsync<T>(id, requestOptions).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -296,7 +296,7 @@ public static async Task<T> CreateObjectAsync<T>(this RedmineManager redmineMana
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions();
return await redmineManager.CreateObjectAsync(entity, null, requestOptions).ConfigureAwait(false);
return await redmineManager.CreateAsync(entity, null, requestOptions).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -312,7 +312,7 @@ public static async Task<T> CreateObjectAsync<T>(this RedmineManager redmineMana
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions();
return await redmineManager.CreateObjectAsync(entity, ownerId, requestOptions, CancellationToken.None).ConfigureAwait(false);
return await redmineManager.CreateAsync(entity, ownerId, requestOptions, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -328,7 +328,7 @@ public static async Task UpdateObjectAsync<T>(this RedmineManager redmineManager
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions();
await redmineManager.UpdateObjectAsync(id, entity, requestOptions).ConfigureAwait(false);
await redmineManager.UpdateAsync(id, entity, requestOptions).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -343,7 +343,7 @@ public static async Task DeleteObjectAsync<T>(this RedmineManager redmineManager
where T : class, new()
{
var requestOptions = RedmineManagerExtensions.CreateRequestOptions();
await redmineManager.DeleteObjectAsync<T>(id, requestOptions).ConfigureAwait(false);
await redmineManager.DeleteAsync<T>(id, requestOptions).ConfigureAwait(false);
}

/// <summary>
Expand Down
Loading

0 comments on commit 6bef83d

Please sign in to comment.