Merge branch 'feature/backend-refactor' into feature/files-mapping

This commit is contained in:
Maksim Chegulov 2022-03-10 12:19:18 +03:00
commit 26066ccb7f
286 changed files with 7845 additions and 8539 deletions

View File

@ -29,34 +29,30 @@ dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_property = false:silent
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_other_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
# Expression-level preferences
dotnet_style_coalesce_expression = true:warning
dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_object_initializer = true:warning
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_simplified_boolean_expressions = true:warning
dotnet_style_prefer_simplified_interpolation = true:suggestion
# Field preferences
dotnet_style_readonly_field = true:warning
@ -64,6 +60,13 @@ dotnet_style_readonly_field = true:warning
# Parameter preferences
dotnet_code_quality_unused_parameters = all:warning
# Suppression preferences
dotnet_remove_unnecessary_suppression_exclusions = none
# New line preferences
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_style_allow_statement_immediately_after_block_experimental = false
#### C# Coding Conventions ####
# var preferences
@ -72,44 +75,48 @@ csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
# Expression-bodied members
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
csharp_style_conditional_delegate_call = true:warning
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_prefer_static_local_function = true:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Code-block preferences
csharp_prefer_braces = true:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:warning
csharp_prefer_simple_using_statement = false:silent
csharp_style_namespace_declarations = file_scoped:warning
# Expression-level preferences
csharp_prefer_simple_default_expression = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_inlined_variable_declaration = true:warning
csharp_style_pattern_local_over_anonymous_function = true:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_throw_expression = true:warning
csharp_prefer_simple_default_expression = false:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = false:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = false:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_range_operator = false:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:silent
csharp_using_directive_placement = outside_namespace:warning
# New line preferences
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:silent
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
#### C# Formatting Rules ####
@ -126,7 +133,7 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
@ -162,32 +169,32 @@ csharp_preserve_single_line_statements = true
# Naming rules
dotnet_naming_rule.private_or_internal_field_should_be_begin_with_underscore.severity = warning
dotnet_naming_rule.private_or_internal_field_should_be_begin_with_underscore.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_should_be_begin_with_underscore.style = begin_with_underscore
dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = warning
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Naming styles
dotnet_naming_style.pascal_case.required_prefix =
@ -200,5 +207,58 @@ dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
# Default severity for analyzer diagnostics with category 'Style'
dotnet_analyzer_diagnostic.category-Style.severity = silent
dotnet_naming_style.begin_with_underscore.required_prefix = _
dotnet_naming_style.begin_with_underscore.required_suffix =
dotnet_naming_style.begin_with_underscore.word_separator =
dotnet_naming_style.begin_with_underscore.capitalization = camel_case
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
dotnet_diagnostic.CA1001.severity = warning
dotnet_diagnostic.CA1805.severity = warning
dotnet_diagnostic.CA1841.severity = warning
[*.{cs,vb}]
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:warning
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_allow_multiple_blank_lines_experimental = false:silent
dotnet_style_allow_statement_immediately_after_block_experimental = false:silent
dotnet_code_quality_unused_parameters = all:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = always_for_clarity:silent
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_diagnostic.CA1715.severity = warning
dotnet_diagnostic.CA1716.severity = silent
dotnet_diagnostic.CA5397.severity = warning

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -85,7 +85,7 @@ public sealed class ApiDateTime : IComparable<ApiDateTime>, IComparable
public static ApiDateTime Parse(string data, TimeZoneInfo tz, TenantManager tenantManager, TimeZoneConverter timeZoneConverter)
{
if (string.IsNullOrEmpty(data)) throw new ArgumentNullException(nameof(data));
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(data);
var offsetPart = data.Substring(data.Length - 6, 6);
if (DateTime.TryParseExact(data, Formats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var dateTime))

View File

@ -1,11 +1,9 @@
global using System;
global using System.Collections.Generic;
global using System.ComponentModel;
global using System.ComponentModel;
global using System.Globalization;
global using System.Linq;
global using System.Linq.Expressions;
global using System.Net;
global using System.Net.Http;
global using System.Reflection;
global using System.Runtime.Serialization;
global using System.Security;
@ -14,8 +12,7 @@ global using System.Security.Claims;
global using System.Text.Encodings.Web;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Web;
global using System.Xml.Linq;

View File

@ -25,7 +25,7 @@
namespace ASC.Web.Api.Models;
public class EmployeeWraper
public class EmployeeDto
{
public Guid Id { get; set; }
public string DisplayName { get; set; }
@ -33,9 +33,9 @@ public class EmployeeWraper
public string AvatarSmall { get; set; }
public string ProfileUrl { get; set; }
public static EmployeeWraper GetSample()
public static EmployeeDto GetSample()
{
return new EmployeeWraper
return new EmployeeDto
{
Id = Guid.Empty,
DisplayName = "Mike Zanyatski",
@ -46,16 +46,16 @@ public class EmployeeWraper
}
[Scope]
public class EmployeeWraperHelper
public class EmployeeDtoHelper
{
protected UserPhotoManager UserPhotoManager { get; }
protected UserManager UserManager { get; }
protected readonly UserPhotoManager UserPhotoManager;
protected readonly UserManager UserManager;
private readonly ApiContext _httpContext;
private readonly DisplayUserSettingsHelper _displayUserSettingsHelper;
private readonly CommonLinkUtility _commonLinkUtility;
public EmployeeWraperHelper(
public EmployeeDtoHelper(
ApiContext httpContext,
DisplayUserSettingsHelper displayUserSettingsHelper,
UserPhotoManager userPhotoManager,
@ -67,15 +67,14 @@ public class EmployeeWraperHelper
_httpContext = httpContext;
_displayUserSettingsHelper = displayUserSettingsHelper;
_commonLinkUtility = commonLinkUtility;
}
public EmployeeWraper Get(UserInfo userInfo)
public EmployeeDto Get(UserInfo userInfo)
{
return Init(new EmployeeWraper(), userInfo);
return Init(new EmployeeDto(), userInfo);
}
public EmployeeWraper Get(Guid userId)
public EmployeeDto Get(Guid userId)
{
try
{
@ -87,7 +86,7 @@ public class EmployeeWraperHelper
}
}
protected EmployeeWraper Init(EmployeeWraper result, UserInfo userInfo)
protected EmployeeDto Init(EmployeeDto result, UserInfo userInfo)
{
result.Id = userInfo.Id;
result.DisplayName = _displayUserSettingsHelper.GetFullUserName(userInfo);

View File

@ -25,7 +25,7 @@
namespace ASC.Web.Api.Models;
public class EmployeeWraperFull : EmployeeWraper
public class EmployeeFullDto : EmployeeDto
{
public string FirstName { get; set; }
public string LastName { get; set; }
@ -39,7 +39,7 @@ public class EmployeeWraperFull : EmployeeWraper
public ApiDateTime Terminated { get; set; }
public string Department { get; set; }
public ApiDateTime WorkFrom { get; set; }
public List<GroupWrapperSummary> Groups { get; set; }
public List<GroupSummaryDto> Groups { get; set; }
public string Location { get; set; }
public string Notes { get; set; }
public string AvatarMax { get; set; }
@ -55,9 +55,9 @@ public class EmployeeWraperFull : EmployeeWraper
public MobilePhoneActivationStatus MobilePhoneActivationStatus { get; set; }
public bool IsSSO { get; set; }
public new static EmployeeWraperFull GetSample()
public new static EmployeeFullDto GetSample()
{
return new EmployeeWraperFull
return new EmployeeFullDto
{
Avatar = "url to big avatar",
AvatarSmall = "url to small avatar",
@ -71,7 +71,7 @@ public class EmployeeWraperFull : EmployeeWraper
UserName = "Mike.Zanyatski",
LastName = "Zanyatski",
Title = "Manager",
Groups = new List<GroupWrapperSummary> { GroupWrapperSummary.GetSample() },
Groups = new List<GroupSummaryDto> { GroupSummaryDto.GetSample() },
AvatarMedium = "url to medium avatar",
Birthday = ApiDateTime.GetSample(),
Department = "Marketing",
@ -89,13 +89,13 @@ public class EmployeeWraperFull : EmployeeWraper
}
[Scope]
public class EmployeeWraperFullHelper : EmployeeWraperHelper
public class EmployeeFullDtoHelper : EmployeeDtoHelper
{
private readonly ApiContext _context;
private readonly WebItemSecurity _webItemSecurity;
private readonly ApiDateTimeHelper _apiDateTimeHelper;
public EmployeeWraperFullHelper(
public EmployeeFullDtoHelper(
ApiContext context,
UserManager userManager,
UserPhotoManager userPhotoManager,
@ -135,9 +135,9 @@ public class EmployeeWraperFullHelper : EmployeeWraperHelper
return lambda;
}
public EmployeeWraperFull GetFull(UserInfo userInfo)
public EmployeeFullDto GetFull(UserInfo userInfo)
{
var result = new EmployeeWraperFull
var result = new EmployeeFullDto
{
UserName = userInfo.UserName,
FirstName = userInfo.FirstName,
@ -189,7 +189,7 @@ public class EmployeeWraperFullHelper : EmployeeWraperHelper
if (_context.Check("groups") || _context.Check("department"))
{
var groups = UserManager.GetUserGroups(userInfo.Id)
.Select(x => new GroupWrapperSummary(x, UserManager))
.Select(x => new GroupSummaryDto(x, UserManager))
.ToList();
if (groups.Count > 0)
@ -232,7 +232,7 @@ public class EmployeeWraperFullHelper : EmployeeWraperHelper
return result;
}
private void FillConacts(EmployeeWraperFull employeeWraperFull, UserInfo userInfo)
private void FillConacts(EmployeeFullDto employeeWraperFull, UserInfo userInfo)
{
if (userInfo.ContactsList == null)
{

View File

@ -27,24 +27,24 @@ using GroupInfo = ASC.Core.Users.GroupInfo;
namespace ASC.Web.Api.Models;
public class GroupWrapperSummary
public class GroupSummaryDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Manager { get; set; }
protected GroupWrapperSummary() { }
protected GroupSummaryDto() { }
public GroupWrapperSummary(GroupInfo group, UserManager userManager)
public GroupSummaryDto(GroupInfo group, UserManager userManager)
{
Id = group.ID;
Name = group.Name;
Manager = userManager.GetUsers(userManager.GetDepartmentManager(group.ID)).UserName;
}
public static GroupWrapperSummary GetSample()
public static GroupSummaryDto GetSample()
{
return new GroupWrapperSummary
return new GroupSummaryDto
{
Id = Guid.Empty,
Manager = "Jake.Zazhitski",

View File

@ -12,6 +12,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<WarningsAsErrors></WarningsAsErrors>
<NoWarn>$(NoWarn);NU1605</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View File

@ -0,0 +1,12 @@
namespace System;
public static class ArgumentNullOrEmptyException
{
public static void ThrowIfNullOrEmpty(string argument, [CallerArgumentExpression("argument")] string? paramName = null)
{
if (string.IsNullOrEmpty(argument))
{
throw new ArgumentNullException(paramName);
}
}
}

View File

@ -31,8 +31,8 @@ public static class StreamExtension
public static void StreamCopyTo(this Stream srcStream, Stream dstStream, int length)
{
if (srcStream == null) throw new ArgumentNullException(nameof(srcStream));
if (dstStream == null) throw new ArgumentNullException(nameof(dstStream));
ArgumentNullException.ThrowIfNull(srcStream);
ArgumentNullException.ThrowIfNull(dstStream);
var buffer = new byte[BufferSize];
int totalRead = 0;

View File

@ -28,7 +28,7 @@ public class TempStream
public Stream GetBuffered(Stream srcStream)
{
if (srcStream == null) throw new ArgumentNullException(nameof(srcStream));
ArgumentNullException.ThrowIfNull(srcStream);
if (!srcStream.CanSeek || srcStream.CanTimeout)
{
//Buffer it

View File

@ -1,28 +1,23 @@
global using System;
global using System.Collections;
global using System.Collections;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Configuration;
global using System.Diagnostics;
global using System.Globalization;
global using System.IO;
global using System.Linq;
global using System.Net;
global using System.Net.Mail;
global using System.Reflection;
global using System.Runtime.Caching;
global using System.Runtime.CompilerServices;
global using System.Runtime.Loader;
global using System.Runtime.Serialization;
global using System.Security.Cryptography;
global using System.Security.Principal;
global using System.ServiceModel;
global using System.Text;
global using System.Text.RegularExpressions;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Web;
global using System.Xml.Linq;
global using System.Xml.XPath;
global using System.ServiceModel;
global using System.Runtime.Serialization;
global using ARSoft.Tools.Net;
global using ARSoft.Tools.Net.Dns;

View File

@ -88,10 +88,7 @@ public class AscRandom : Random
public override void NextBytes(byte[] buffer)
{
if (buffer == null)
{
throw new ArgumentNullException(nameof(buffer));
}
ArgumentNullException.ThrowIfNull(buffer);
for (var i = 0; i < buffer.Length; i++)
{

View File

@ -45,7 +45,9 @@ public class AuthorizingException : Exception
throw new ArgumentNullException(nameof(actions));
}
Subject = subject ?? throw new ArgumentNullException(nameof(subject));
ArgumentNullException.ThrowIfNull(subject);
Subject = subject;
Actions = actions;
var sactions = "";
@ -80,10 +82,8 @@ public class AuthorizingException : Exception
internal static string FormatErrorMessage(ISubject subject, IAction[] actions, ISubject[] denySubjects,
IAction[] denyActions)
{
if (subject == null)
{
throw new ArgumentNullException(nameof(subject));
}
ArgumentNullException.ThrowIfNull(subject);
if (actions == null || actions.Length == 0)
{
throw new ArgumentNullException(nameof(actions));

View File

@ -36,8 +36,9 @@ public class AzObjectSecurityProviderHelper
public AzObjectSecurityProviderHelper(ISecurityObjectId objectId, ISecurityObjectProvider secObjProvider)
{
ArgumentNullException.ThrowIfNull(objectId);
_currObjIdAsProvider = false;
CurrentObjectId = objectId ?? throw new ArgumentNullException(nameof(objectId));
CurrentObjectId = objectId;
_currSecObjProvider = secObjProvider;
if (_currSecObjProvider == null && CurrentObjectId is ISecurityObjectProvider securityObjectProvider)

View File

@ -46,10 +46,8 @@ public sealed class Role : IRole
{
throw new ArgumentException(nameof(id));
}
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(name);
ID = id;
Name = name;

View File

@ -106,40 +106,28 @@ public static class Hasher
private static byte[] S2B(string str)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
ArgumentNullException.ThrowIfNull(str);
return Encoding.UTF8.GetBytes(str);
}
private static string B2S(byte[] data)
{
if (data == null)
{
throw new ArgumentNullException(nameof(data));
}
ArgumentNullException.ThrowIfNull(data);
return Encoding.UTF8.GetString(data);
}
private static byte[] S642B(string str)
{
if (str == null)
{
throw new ArgumentNullException(nameof(str));
}
ArgumentNullException.ThrowIfNull(str);
return Convert.FromBase64String(str);
}
private static string B2S64(byte[] data)
{
if (data == null)
{
throw new ArgumentNullException(nameof(data));
}
ArgumentNullException.ThrowIfNull(data);
return Convert.ToBase64String(data);
}

View File

@ -34,8 +34,10 @@ public class SecurityObjectId : ISecurityObjectId
public SecurityObjectId(object id, Type objType)
{
ArgumentNullException.ThrowIfNull(objType);
SecurityId = id;
ObjectType = objType ?? throw new ArgumentNullException(nameof(objType));
ObjectType = objType;
}
public override int GetHashCode()

View File

@ -45,10 +45,7 @@ public class DnsLookup
/// <returns>list of MxRecord</returns>
public List<MxRecord> GetDomainMxRecords(string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var mxRecords = DnsResolve<MxRecord>(domainName, RecordType.Mx);
@ -65,15 +62,8 @@ public class DnsLookup
/// <returns>true if exists and vice versa</returns>
public bool IsDomainMxRecordExists(string domainName, string mxRecord)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
if (string.IsNullOrEmpty(mxRecord))
{
throw new ArgumentNullException(nameof(mxRecord));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(mxRecord);
var mxDomain = DomainName.Parse(mxRecord);
@ -93,10 +83,7 @@ public class DnsLookup
/// <returns>true if any DNS record exists and vice versa</returns>
public bool IsDomainExists(string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var dnsMessage = GetDnsMessage(domainName);
@ -112,10 +99,7 @@ public class DnsLookup
/// <returns>list of ARecord</returns>
public List<ARecord> GetDomainARecords(string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var aRecords = DnsResolve<ARecord>(domainName, RecordType.A);
@ -131,10 +115,7 @@ public class DnsLookup
/// <returns>list of IPAddress</returns>
public List<IPAddress> GetDomainIPs(string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var addresses = _sDnsResolver.ResolveHost(domainName);
@ -150,10 +131,7 @@ public class DnsLookup
/// <returns>list of TxtRecord</returns>
public List<TxtRecord> GetDomainTxtRecords(string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var txtRecords = DnsResolve<TxtRecord>(domainName, RecordType.Txt);
@ -206,14 +184,9 @@ public class DnsLookup
/// <returns>true if exists and vice versa</returns>
public bool IsDomainPtrRecordExists(IPAddress ipAddress, string domainName)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
if (ipAddress == null)
{
throw new ArgumentNullException(nameof(ipAddress));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
ArgumentNullException.ThrowIfNull(ipAddress);
var domain = DomainName.Parse(domainName);
@ -238,10 +211,7 @@ public class DnsLookup
private DnsMessage GetDnsMessage(string domainName, RecordType? type = null)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var domain = DomainName.Parse(domainName);
@ -257,10 +227,7 @@ public class DnsLookup
private List<T> DnsResolve<T>(string domainName, RecordType type)
{
if (string.IsNullOrEmpty(domainName))
{
throw new ArgumentNullException(nameof(domainName));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domainName);
var dnsMessage = GetDnsMessage(domainName, type);

View File

@ -69,7 +69,8 @@ public class DisposableHttpContext : IDisposable
public DisposableHttpContext(HttpContext ctx)
{
_context = ctx ?? throw new ArgumentNullException(nameof(ctx));
ArgumentNullException.ThrowIfNull(ctx);
_context = ctx;
}
public void Dispose()

View File

@ -11,6 +11,7 @@
<Copyright>(c) Ascensio System SIA. All rights reserved</Copyright>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>

View File

@ -78,10 +78,7 @@ public class BaseCommonLinkUtility
{
var u = HttpContextAccessor?.HttpContext.Request.GetUrlRewriter();
if (u == null)
{
throw new ArgumentNullException(nameof(u));
}
ArgumentNullException.ThrowIfNull(u);
uriBuilder = new UriBuilder(u.Scheme, LocalHost, u.Port);
}
@ -120,10 +117,7 @@ public class BaseCommonLinkUtility
{
var u = HttpContextAccessor?.HttpContext?.Request.GetUrlRewriter();
if (u == null)
{
throw new ArgumentNullException(nameof(u));
}
ArgumentNullException.ThrowIfNull(u);
result = new UriBuilder(u.Scheme, u.Host, u.Port);

View File

@ -170,10 +170,7 @@ public class BillingClient
public IDictionary<string, Dictionary<string, decimal>> GetProductPriceInfo(params string[] productIds)
{
if (productIds == null)
{
throw new ArgumentNullException(nameof(productIds));
}
ArgumentNullException.ThrowIfNull(productIds);
var parameters = productIds.Select(pid => Tuple.Create("ProductId", pid)).ToList();
parameters.Add(Tuple.Create("PaymentSystemId", AvangatePaymentSystemId.ToString()));

View File

@ -153,10 +153,7 @@ public class LicenseReader
private static void SaveLicense(Stream licenseStream, string path)
{
if (licenseStream == null)
{
throw new ArgumentNullException(nameof(licenseStream));
}
ArgumentNullException.ThrowIfNull(licenseStream);
if (licenseStream.CanSeek)
{

View File

@ -259,10 +259,7 @@ public class TariffService : ITariffService
public void SetTariff(int tenantId, Tariff tariff)
{
if (tariff == null)
{
throw new ArgumentNullException(nameof(tariff));
}
ArgumentNullException.ThrowIfNull(tariff);
var q = QuotaService.GetTenantQuota(tariff.QuotaId);
if (q == null)
@ -423,10 +420,8 @@ public class TariffService : ITariffService
public IDictionary<string, Dictionary<string, decimal>> GetProductPriceInfo(params string[] productIds)
{
if (productIds == null)
{
throw new ArgumentNullException(nameof(productIds));
}
ArgumentNullException.ThrowIfNull(productIds);
try
{
var key = "biling-prices" + string.Join(",", productIds);

View File

@ -151,10 +151,7 @@ public class CoreSettings
public void SaveSetting(string key, string value, int tenant = Tenant.DefaultTenant)
{
if (string.IsNullOrEmpty(key))
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(key);
byte[] bytes = null;
if (value != null)
@ -167,10 +164,7 @@ public class CoreSettings
public string GetSetting(string key, int tenant = Tenant.DefaultTenant)
{
if (string.IsNullOrEmpty(key))
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(key);
var bytes = TenantService.GetTenantSettings(tenant, key);

View File

@ -84,10 +84,7 @@ public class PaymentManager
public void ActivateKey(string key)
{
if (string.IsNullOrEmpty(key))
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(key);
var now = DateTime.UtcNow;
var actionUrl = "/partnerapi/ActivateKey?code=" + HttpUtility.UrlEncode(key) + "&portal=" + HttpUtility.UrlEncode(_tenantManager.GetCurrentTenant().Alias);

View File

@ -185,10 +185,7 @@ public class TenantManager
public Tenant SetTenantVersion(Tenant tenant, int version)
{
if (tenant == null)
{
throw new ArgumentNullException(nameof(tenant));
}
ArgumentNullException.ThrowIfNull(tenant);
if (tenant.Version != version)
{

View File

@ -80,15 +80,8 @@ public class SecurityContext
public string AuthenticateMe(string login, string passwordHash)
{
if (login == null)
{
throw new ArgumentNullException(nameof(login));
}
if (passwordHash == null)
{
throw new ArgumentNullException(nameof(passwordHash));
}
ArgumentNullException.ThrowIfNull(login);
ArgumentNullException.ThrowIfNull(passwordHash);
var tenantid = _tenantManager.GetCurrentTenant().Id;
var u = _userManager.GetUsersByPasswordHash(tenantid, login, passwordHash);
@ -109,10 +102,7 @@ public class SecurityContext
{
var request = _httpContextAccessor?.HttpContext.Request;
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
ArgumentNullException.ThrowIfNull(request);
ipFrom = "from " + (request.Headers["X-Forwarded-For"].ToString() ?? request.GetUserHostAddress());
address = "for " + request.GetUrlRewriter();
@ -170,10 +160,7 @@ public class SecurityContext
{
var request = _httpContextAccessor?.HttpContext.Request;
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
ArgumentNullException.ThrowIfNull(request);
address = "for " + request.GetUrlRewriter();
ipFrom = "from " + (request.Headers["X-Forwarded-For"].ToString() ?? request.GetUserHostAddress());

View File

@ -145,14 +145,8 @@ public class DBResourceManager : ResourceManager
CultureInfo culture,
string filename)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
if (string.IsNullOrEmpty(filename))
{
throw new ArgumentNullException(nameof(filename));
}
ArgumentNullException.ThrowIfNull(culture);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(filename);
_dbContext = dbContext;
_logger = option.CurrentValue;

View File

@ -23,8 +23,6 @@
*
*/
using System.Diagnostics.Metrics;
using AutoMapper.QueryableExtensions;
namespace ASC.Core.Data;
@ -81,10 +79,7 @@ class DbQuotaService : IQuotaService
public TenantQuota SaveTenantQuota(TenantQuota quota)
{
if (quota == null)
{
throw new ArgumentNullException(nameof(quota));
}
ArgumentNullException.ThrowIfNull(quota);
CoreDbContext.AddOrUpdate(r => r.Quotas, _mapper.Map<TenantQuota, DbQuota>(quota));
CoreDbContext.SaveChanges();
@ -111,10 +106,7 @@ class DbQuotaService : IQuotaService
public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
{
if (row == null)
{
throw new ArgumentNullException(nameof(row));
}
ArgumentNullException.ThrowIfNull(row);
using var tx = CoreDbContext.Database.BeginTransaction();

View File

@ -169,10 +169,7 @@ public class DbSettingsManager
public bool SaveSettingsFor<T>(T settings, int tenantId, Guid userId) where T : ISettings
{
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}
ArgumentNullException.ThrowIfNull(settings);
try
{

View File

@ -40,14 +40,8 @@ public class DbSubscriptionService : ISubscriptionService
public string[] GetRecipients(int tenant, string sourceId, string actionId, string objectId)
{
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
var q = GetQuery(tenant, sourceId, actionId)
.Where(r => r.Object == (objectId ?? string.Empty))
@ -60,14 +54,8 @@ public class DbSubscriptionService : ISubscriptionService
public IEnumerable<SubscriptionRecord> GetSubscriptions(int tenant, string sourceId, string actionId)
{
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
var q = GetQuery(tenant, sourceId, actionId);
@ -92,10 +80,7 @@ public class DbSubscriptionService : ISubscriptionService
public SubscriptionRecord GetSubscription(int tenant, string sourceId, string actionId, string recipientId, string objectId)
{
if (recipientId == null)
{
throw new ArgumentNullException(nameof(recipientId));
}
ArgumentNullException.ThrowIfNull(recipientId);
var q = GetQuery(tenant, sourceId, actionId)
.Where(r => r.Recipient == recipientId)
@ -106,18 +91,9 @@ public class DbSubscriptionService : ISubscriptionService
public bool IsUnsubscribe(int tenant, string sourceId, string actionId, string recipientId, string objectId)
{
if (recipientId == null)
{
throw new ArgumentNullException(nameof(recipientId));
}
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(recipientId);
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
var q = UserDbContext.Subscriptions
.Where(r => r.Source == sourceId &&
@ -140,18 +116,9 @@ public class DbSubscriptionService : ISubscriptionService
public string[] GetSubscriptions(int tenant, string sourceId, string actionId, string recipientId, bool checkSubscribe)
{
if (recipientId == null)
{
throw new ArgumentNullException(nameof(recipientId));
}
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(recipientId);
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
var q = GetQuery(tenant, sourceId, actionId)
.Where(r => r.Recipient == recipientId)
@ -168,10 +135,7 @@ public class DbSubscriptionService : ISubscriptionService
public void SaveSubscription(SubscriptionRecord s)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
ArgumentNullException.ThrowIfNull(s);
var subs = new Subscription
{
@ -194,15 +158,8 @@ public class DbSubscriptionService : ISubscriptionService
public void RemoveSubscriptions(int tenant, string sourceId, string actionId, string objectId)
{
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
using var tr = UserDbContext.Database.BeginTransaction();
var q = UserDbContext.Subscriptions
@ -228,14 +185,8 @@ public class DbSubscriptionService : ISubscriptionService
public IEnumerable<SubscriptionMethod> GetSubscriptionMethods(int tenant, string sourceId, string actionId, string recipientId)
{
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
var q = UserDbContext.SubscriptionMethods
.Where(r => r.Tenant == -1 || r.Tenant == tenant)
@ -278,10 +229,7 @@ public class DbSubscriptionService : ISubscriptionService
public void SetSubscriptionMethod(SubscriptionMethod m)
{
if (m == null)
{
throw new ArgumentNullException(nameof(m));
}
ArgumentNullException.ThrowIfNull(m);
using var tr = UserDbContext.Database.BeginTransaction();
@ -320,14 +268,8 @@ public class DbSubscriptionService : ISubscriptionService
private IQueryable<Subscription> GetQuery(int tenant, string sourceId, string actionId)
{
if (sourceId == null)
{
throw new ArgumentNullException(nameof(sourceId));
}
if (actionId == null)
{
throw new ArgumentNullException(nameof(actionId));
}
ArgumentNullException.ThrowIfNull(sourceId);
ArgumentNullException.ThrowIfNull(actionId);
return
UserDbContext.Subscriptions

View File

@ -114,10 +114,7 @@ public class DbTenantService : ITenantService
public IEnumerable<Tenant> GetTenants(string login, string passwordHash)
{
if (string.IsNullOrEmpty(login))
{
throw new ArgumentNullException(nameof(login));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(login);
IQueryable<TenantUserSecurity> query() => TenantsQuery()
.Where(r => r.Status == TenantStatus.Active)
@ -205,10 +202,7 @@ public class DbTenantService : ITenantService
public Tenant GetTenant(string domain)
{
if (string.IsNullOrEmpty(domain))
{
throw new ArgumentNullException(nameof(domain));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(domain);
domain = domain.ToLowerInvariant();
@ -229,79 +223,76 @@ public class DbTenantService : ITenantService
.FirstOrDefault();
}
public Tenant SaveTenant(CoreSettings coreSettings, Tenant t)
public Tenant SaveTenant(CoreSettings coreSettings, Tenant tenant)
{
if (t == null)
{
throw new ArgumentNullException("tenant");
}
ArgumentNullException.ThrowIfNull(tenant);
using var tx = TenantDbContext.Database.BeginTransaction();
if (!string.IsNullOrEmpty(t.MappedDomain))
if (!string.IsNullOrEmpty(tenant.MappedDomain))
{
var baseUrl = coreSettings.GetBaseDomain(t.HostedRegion);
var baseUrl = coreSettings.GetBaseDomain(tenant.HostedRegion);
if (baseUrl != null && t.MappedDomain.EndsWith("." + baseUrl, StringComparison.InvariantCultureIgnoreCase))
if (baseUrl != null && tenant.MappedDomain.EndsWith("." + baseUrl, StringComparison.InvariantCultureIgnoreCase))
{
ValidateDomain(t.MappedDomain.Substring(0, t.MappedDomain.Length - baseUrl.Length - 1), t.Id, false);
ValidateDomain(tenant.MappedDomain.Substring(0, tenant.MappedDomain.Length - baseUrl.Length - 1), tenant.Id, false);
}
else
{
ValidateDomain(t.MappedDomain, t.Id, false);
ValidateDomain(tenant.MappedDomain, tenant.Id, false);
}
}
if (t.Id == Tenant.DefaultTenant)
if (tenant.Id == Tenant.DefaultTenant)
{
t.Version = TenantDbContext.TenantVersion
tenant.Version = TenantDbContext.TenantVersion
.Where(r => r.DefaultVersion == 1 || r.Id == 0)
.OrderByDescending(r => r.Id)
.Select(r => r.Id)
.FirstOrDefault();
t.LastModified = DateTime.UtcNow;
tenant.LastModified = DateTime.UtcNow;
var tenant = _mapper.Map<Tenant, DbTenant>(t);
var dbTenant = _mapper.Map<Tenant, DbTenant>(tenant);
tenant = TenantDbContext.Tenants.Add(tenant).Entity;
dbTenant = TenantDbContext.Tenants.Add(dbTenant).Entity;
TenantDbContext.SaveChanges();
t.Id = tenant.Id;
tenant.Id = dbTenant.Id;
}
else
{
var tenant = TenantDbContext.Tenants
.Where(r => r.Id == t.Id)
var dbTenant = TenantDbContext.Tenants
.Where(r => r.Id == tenant.Id)
.FirstOrDefault();
if (tenant != null)
if (dbTenant != null)
{
tenant.Alias = t.Alias.ToLowerInvariant();
tenant.MappedDomain = !string.IsNullOrEmpty(t.MappedDomain) ? t.MappedDomain.ToLowerInvariant() : null;
tenant.Version = t.Version;
tenant.VersionChanged = t.VersionChanged;
tenant.Name = t.Name ?? t.Alias;
tenant.Language = t.Language;
tenant.TimeZone = t.TimeZone;
tenant.TrustedDomainsRaw = t.GetTrustedDomains();
tenant.TrustedDomainsEnabled = t.TrustedDomainsType;
tenant.CreationDateTime = t.CreationDateTime;
tenant.Status = t.Status;
tenant.StatusChanged = t.StatusChangeDate;
tenant.PaymentId = t.PaymentId;
tenant.LastModified = t.LastModified = DateTime.UtcNow;
tenant.Industry = t.Industry;
tenant.Spam = t.Spam;
tenant.Calls = t.Calls;
dbTenant.Alias = tenant.Alias.ToLowerInvariant();
dbTenant.MappedDomain = !string.IsNullOrEmpty(tenant.MappedDomain) ? tenant.MappedDomain.ToLowerInvariant() : null;
dbTenant.Version = tenant.Version;
dbTenant.VersionChanged = tenant.VersionChanged;
dbTenant.Name = tenant.Name ?? tenant.Alias;
dbTenant.Language = tenant.Language;
dbTenant.TimeZone = tenant.TimeZone;
dbTenant.TrustedDomainsRaw = tenant.GetTrustedDomains();
dbTenant.TrustedDomainsEnabled = tenant.TrustedDomainsType;
dbTenant.CreationDateTime = tenant.CreationDateTime;
dbTenant.Status = tenant.Status;
dbTenant.StatusChanged = tenant.StatusChangeDate;
dbTenant.PaymentId = tenant.PaymentId;
dbTenant.LastModified = tenant.LastModified = DateTime.UtcNow;
dbTenant.Industry = tenant.Industry;
dbTenant.Spam = tenant.Spam;
dbTenant.Calls = tenant.Calls;
}
TenantDbContext.SaveChanges();
}
if (string.IsNullOrEmpty(t.PartnerId) && string.IsNullOrEmpty(t.AffiliateId) && string.IsNullOrEmpty(t.Campaign))
if (string.IsNullOrEmpty(tenant.PartnerId) && string.IsNullOrEmpty(tenant.AffiliateId) && string.IsNullOrEmpty(tenant.Campaign))
{
var p = TenantDbContext.TenantPartner
.Where(r => r.TenantId == t.Id)
.Where(r => r.TenantId == tenant.Id)
.FirstOrDefault();
if (p != null)
@ -313,10 +304,10 @@ public class DbTenantService : ITenantService
{
var tenantPartner = new DbTenantPartner
{
TenantId = t.Id,
PartnerId = t.PartnerId,
AffiliateId = t.AffiliateId,
Campaign = t.Campaign
TenantId = tenant.Id,
PartnerId = tenant.PartnerId,
AffiliateId = tenant.AffiliateId,
Campaign = tenant.Campaign
};
TenantDbContext.TenantPartner.Add(tenantPartner);
@ -325,7 +316,7 @@ public class DbTenantService : ITenantService
tx.Commit();
//CalculateTenantDomain(t);
return t;
return tenant;
}
public void RemoveTenant(int id, bool auto = false)

View File

@ -115,10 +115,7 @@ public class EFUserService : IUserService
public UserInfo GetUserByPasswordHash(int tenant, string login, string passwordHash)
{
if (string.IsNullOrEmpty(login))
{
throw new ArgumentNullException(nameof(login));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(login);
if (Guid.TryParse(login, out var userId))
{
@ -430,10 +427,7 @@ public class EFUserService : IUserService
public Group SaveGroup(int tenant, Group group)
{
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}
ArgumentNullException.ThrowIfNull(group);
if (group.Id == default)
{
@ -452,10 +446,7 @@ public class EFUserService : IUserService
public UserInfo SaveUser(int tenant, UserInfo user)
{
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
ArgumentNullException.ThrowIfNull(user);
if (string.IsNullOrEmpty(user.UserName))
{
@ -501,29 +492,26 @@ public class EFUserService : IUserService
return user;
}
public UserGroupRef SaveUserGroupRef(int tenant, UserGroupRef r)
public UserGroupRef SaveUserGroupRef(int tenant, UserGroupRef userGroupRef)
{
if (r == null)
{
throw new ArgumentNullException("userGroupRef");
}
ArgumentNullException.ThrowIfNull(userGroupRef);
r.LastModified = DateTime.UtcNow;
r.Tenant = tenant;
userGroupRef.LastModified = DateTime.UtcNow;
userGroupRef.Tenant = tenant;
using var tr = UserDbContext.Database.BeginTransaction();
var user = GetUserQuery(tenant).FirstOrDefault(a => a.Tenant == tenant && a.Id == r.UserId);
var user = GetUserQuery(tenant).FirstOrDefault(a => a.Tenant == tenant && a.Id == userGroupRef.UserId);
if (user != null)
{
user.LastModified = r.LastModified;
UserDbContext.AddOrUpdate(r => r.UserGroups, _mapper.Map<UserGroupRef, UserGroup>(r));
user.LastModified = userGroupRef.LastModified;
UserDbContext.AddOrUpdate(r => r.UserGroups, _mapper.Map<UserGroupRef, UserGroup>(userGroupRef));
}
UserDbContext.SaveChanges();
tr.Commit();
return r;
return userGroupRef;
}
public void SetUserPasswordHash(int tenant, Guid id, string passwordHash)

View File

@ -10,9 +10,9 @@ public class DbVoipCall
public Guid AnsweredBy { get; set; }
public DateTime DialDate { get; set; }
public int DialDuration { get; set; }
public string RecordSid { get; set; }
public string RecordUrl { get; set; }
public int RecordDuration { get; set; }
public string Sid { get; set; }
public string Uri { get; set; }
public int Duration { get; set; }
public decimal RecordPrice { get; set; }
public int ContactId { get; set; }
public decimal Price { get; set; }
@ -30,6 +30,7 @@ public static class DbVoipCallExtension
return modelBuilder;
}
public static void MySqlAddDbVoipCall(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<DbVoipCall>(entity =>
@ -89,19 +90,19 @@ public static class DbVoipCallExtension
.HasColumnName("price")
.HasColumnType("decimal(10,4)");
entity.Property(e => e.RecordDuration).HasColumnName("record_duration");
entity.Property(e => e.Duration).HasColumnName("record_duration");
entity.Property(e => e.RecordPrice)
.HasColumnName("record_price")
.HasColumnType("decimal(10,4)");
entity.Property(e => e.RecordSid)
entity.Property(e => e.Sid)
.HasColumnName("record_sid")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.RecordUrl)
entity.Property(e => e.Uri)
.HasColumnName("record_url")
.HasColumnType("text")
.HasCharSet("utf8")
@ -160,18 +161,18 @@ public static class DbVoipCallExtension
.HasColumnType("numeric(10,4)")
.HasDefaultValueSql("NULL");
entity.Property(e => e.RecordDuration).HasColumnName("record_duration");
entity.Property(e => e.Duration).HasColumnName("record_duration");
entity.Property(e => e.RecordPrice)
.HasColumnName("record_price")
.HasColumnType("numeric(10,4)");
entity.Property(e => e.RecordSid)
entity.Property(e => e.Sid)
.HasColumnName("record_sid")
.HasMaxLength(50)
.HasDefaultValueSql("NULL");
entity.Property(e => e.RecordUrl).HasColumnName("record_url");
entity.Property(e => e.Uri).HasColumnName("record_url");
entity.Property(e => e.Status).HasColumnName("status");

View File

@ -1,16 +1,11 @@
global using System;
global using System.Collections;
global using System.Collections;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Configuration;
global using System.Data.Common;
global using System.Diagnostics;
global using System.Globalization;
global using System.IO;
global using System.Linq;
global using System.Linq.Expressions;
global using System.Net;
global using System.Net.Http;
global using System.Reflection;
global using System.Resources;
global using System.Runtime.Caching;
@ -25,8 +20,6 @@ global using System.Text;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Text.RegularExpressions;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Web;
global using System.Xml;

View File

@ -143,51 +143,49 @@ public class HostedSolution
TenantService.ValidateDomain(address);
}
public void RegisterTenant(TenantRegistrationInfo ri, out Tenant tenant)
public void RegisterTenant(TenantRegistrationInfo registrationInfo, out Tenant tenant)
{
if (ri == null)
{
throw new ArgumentNullException("registrationInfo");
}
if (string.IsNullOrEmpty(ri.Address))
ArgumentNullException.ThrowIfNull(registrationInfo);
if (string.IsNullOrEmpty(registrationInfo.Address))
{
throw new Exception("Address can not be empty");
}
if (string.IsNullOrEmpty(ri.Email))
if (string.IsNullOrEmpty(registrationInfo.Email))
{
throw new Exception("Account email can not be empty");
}
if (ri.FirstName == null)
if (registrationInfo.FirstName == null)
{
throw new Exception("Account firstname can not be empty");
}
if (ri.LastName == null)
if (registrationInfo.LastName == null)
{
throw new Exception("Account lastname can not be empty");
}
if (!UserFormatter.IsValidUserName(ri.FirstName, ri.LastName))
if (!UserFormatter.IsValidUserName(registrationInfo.FirstName, registrationInfo.LastName))
{
throw new Exception("Incorrect firstname or lastname");
}
if (string.IsNullOrEmpty(ri.PasswordHash))
if (string.IsNullOrEmpty(registrationInfo.PasswordHash))
{
ri.PasswordHash = Guid.NewGuid().ToString();
registrationInfo.PasswordHash = Guid.NewGuid().ToString();
}
// create tenant
tenant = new Tenant(ri.Address.ToLowerInvariant())
tenant = new Tenant(registrationInfo.Address.ToLowerInvariant())
{
Name = ri.Name,
Language = ri.Culture.Name,
TimeZone = ri.TimeZoneInfo.Id,
HostedRegion = ri.HostedRegion,
PartnerId = ri.PartnerId,
AffiliateId = ri.AffiliateId,
Campaign = ri.Campaign,
Industry = ri.Industry,
Spam = ri.Spam,
Calls = ri.Calls
Name = registrationInfo.Name,
Language = registrationInfo.Culture.Name,
TimeZone = registrationInfo.TimeZoneInfo.Id,
HostedRegion = registrationInfo.HostedRegion,
PartnerId = registrationInfo.PartnerId,
AffiliateId = registrationInfo.AffiliateId,
Campaign = registrationInfo.Campaign,
Industry = registrationInfo.Industry,
Spam = registrationInfo.Spam,
Calls = registrationInfo.Calls
};
tenant = TenantService.SaveTenant(CoreSettings, tenant);
@ -195,24 +193,24 @@ public class HostedSolution
// create user
var user = new UserInfo
{
UserName = ri.Email.Substring(0, ri.Email.IndexOf('@')),
LastName = ri.LastName,
FirstName = ri.FirstName,
Email = ri.Email,
MobilePhone = ri.MobilePhone,
UserName = registrationInfo.Email.Substring(0, registrationInfo.Email.IndexOf('@')),
LastName = registrationInfo.LastName,
FirstName = registrationInfo.FirstName,
Email = registrationInfo.Email,
MobilePhone = registrationInfo.MobilePhone,
WorkFromDate = TenantUtil.DateTimeNow(tenant.TimeZone),
ActivationStatus = ri.ActivationStatus
ActivationStatus = registrationInfo.ActivationStatus
};
user = UserService.SaveUser(tenant.Id, user);
UserService.SetUserPasswordHash(tenant.Id, user.Id, ri.PasswordHash);
UserService.SetUserPasswordHash(tenant.Id, user.Id, registrationInfo.PasswordHash);
UserService.SaveUserGroupRef(tenant.Id, new UserGroupRef(user.Id, Constants.GroupAdmin.ID, UserGroupRefType.Contains));
// save tenant owner
tenant.OwnerId = user.Id;
tenant = TenantService.SaveTenant(CoreSettings, tenant);
SettingsManager.SaveSettings(new TenantControlPanelSettings { LimitedAccess = ri.LimitedControlPanel }, tenant.Id);
SettingsManager.SaveSettings(new TenantControlPanelSettings { LimitedAccess = registrationInfo.LimitedControlPanel }, tenant.Id);
}
public Tenant SaveTenant(Tenant tenant)

View File

@ -47,10 +47,7 @@ public class SenderChannel : ISenderChannel
public void SendAsync(INoticeMessage message)
{
if (message == null)
{
throw new ArgumentNullException(nameof(message));
}
ArgumentNullException.ThrowIfNull(message);
_firstSink.ProcessMessageAsync(message);
}

View File

@ -34,7 +34,7 @@ class DirectSubscriptionProvider : ISubscriptionProvider
public DirectSubscriptionProvider(string sourceID, SubscriptionManager subscriptionManager, IRecipientProvider recipientProvider)
{
if (string.IsNullOrEmpty(sourceID)) throw new ArgumentNullException(nameof(sourceID));
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(sourceID);
_sourceId = sourceID;
_subscriptionManager = subscriptionManager ?? throw new ArgumentNullException(nameof(subscriptionManager));
_recipientProvider = recipientProvider ?? throw new ArgumentNullException(nameof(recipientProvider));
@ -43,40 +43,23 @@ class DirectSubscriptionProvider : ISubscriptionProvider
public object GetSubscriptionRecord(INotifyAction action, IRecipient recipient, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
return _subscriptionManager.GetSubscriptionRecord(_sourceId, action.ID, recipient.ID, objectID);
}
public string[] GetSubscriptions(INotifyAction action, IRecipient recipient, bool checkSubscribe = true)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
return _subscriptionManager.GetSubscriptions(_sourceId, action.ID, recipient.ID, checkSubscribe);
}
public IRecipient[] GetRecipients(INotifyAction action, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
return _subscriptionManager.GetRecipients(_sourceId, action.ID, objectID)
.Select(r => _recipientProvider.GetRecipient(r))
@ -86,90 +69,54 @@ class DirectSubscriptionProvider : ISubscriptionProvider
public string[] GetSubscriptionMethod(INotifyAction action, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
return _subscriptionManager.GetSubscriptionMethod(_sourceId, action.ID, recipient.ID);
}
public void UpdateSubscriptionMethod(INotifyAction action, IRecipient recipient, params string[] senderNames)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
_subscriptionManager.UpdateSubscriptionMethod(_sourceId, action.ID, recipient.ID, senderNames);
}
public bool IsUnsubscribe(IDirectRecipient recipient, INotifyAction action, string objectID)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(recipient);
ArgumentNullException.ThrowIfNull(action);
return _subscriptionManager.IsUnsubscribe(_sourceId, recipient.ID, action.ID, objectID);
}
public void Subscribe(INotifyAction action, string objectID, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
_subscriptionManager.Subscribe(_sourceId, action.ID, objectID, recipient.ID);
}
public void UnSubscribe(INotifyAction action, string objectID, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
_subscriptionManager.Unsubscribe(_sourceId, action.ID, objectID, recipient.ID);
}
public void UnSubscribe(INotifyAction action)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
_subscriptionManager.UnsubscribeAll(_sourceId, action.ID);
}
public void UnSubscribe(INotifyAction action, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
_subscriptionManager.UnsubscribeAll(_sourceId, action.ID, objectID);
}

View File

@ -47,7 +47,7 @@ class InterceptorStorage
public void Add(ISendInterceptor interceptor)
{
if (interceptor == null) throw new ArgumentNullException(nameof(interceptor));
ArgumentNullException.ThrowIfNull(interceptor);
if (string.IsNullOrEmpty(interceptor.Name)) throw new ArgumentException("empty name property", nameof(interceptor));
switch (interceptor.Lifetime)

View File

@ -73,15 +73,8 @@ public class NotifyEngine : INotifyEngine
internal void RegisterSendMethod(Action<DateTime> method, string cron)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
if (string.IsNullOrEmpty(cron))
{
throw new ArgumentNullException(nameof(cron));
}
ArgumentNullException.ThrowIfNull(method);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(cron);
var w = new SendMethodWrapper(method, cron, _logger);
lock (_sendMethods)
@ -99,10 +92,7 @@ public class NotifyEngine : INotifyEngine
internal void UnregisterSendMethod(Action<DateTime> method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ArgumentNullException.ThrowIfNull(method);
lock (_sendMethods)
{
@ -418,10 +408,7 @@ public class NotifyEngine : INotifyEngine
private SendResponse CreateNoticeMessageFromNotifyRequest(NotifyRequest request, string sender, IServiceScope serviceScope, out NoticeMessage noticeMessage)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
ArgumentNullException.ThrowIfNull(request);
var recipientProvider = request.GetRecipientsProvider(serviceScope);
var recipient = request.Recipient as IDirectRecipient;

View File

@ -100,10 +100,7 @@ public class NotifyRequest
internal NotifyRequest Split(IRecipient recipient)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(recipient);
var newRequest = new NotifyRequest(NotifySource, NotifyAction, ObjectID, recipient)
{

View File

@ -39,10 +39,7 @@ public class SendInterceptorSkeleton : ISendInterceptor
throw new ArgumentException("Empty name.", nameof(name));
}
if (sendInterceptor == null)
{
throw new ArgumentNullException(nameof(sendInterceptor));
}
ArgumentNullException.ThrowIfNull(sendInterceptor);
_method = sendInterceptor;
Name = name;

View File

@ -76,7 +76,8 @@ public class NoticeMessage : INoticeMessage
public void AddArgument(params ITagValue[] tagValues)
{
if (tagValues == null) throw new ArgumentNullException(nameof(tagValues));
ArgumentNullException.ThrowIfNull(tagValues);
Array.ForEach(tagValues,
tagValue =>
{

View File

@ -98,10 +98,7 @@ class NotifyClientImpl : INotifyClient
public void SendNoticeToAsync(INotifyAction action, string objectID, IRecipient[] recipients, string[] senderNames, bool checkSubsciption, params ITagValue[] args)
{
if (recipients == null)
{
throw new ArgumentNullException(nameof(recipients));
}
ArgumentNullException.ThrowIfNull(recipients);
BeginSingleRecipientEvent("__syspreventduplicateinterceptor");
@ -120,14 +117,8 @@ class NotifyClientImpl : INotifyClient
private NotifyRequest CreateRequest(INotifyAction action, string objectID, IRecipient recipient, ITagValue[] args, string[] senders, bool checkSubsciption)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
var request = new NotifyRequest(_notifySource, action, objectID, recipient)
{

View File

@ -41,10 +41,7 @@ public abstract class NotifySource : INotifySource
protected NotifySource(string id, UserManager userManager, IRecipientProvider recipientsProvider, SubscriptionManager subscriptionManager)
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(id);
Id = id;
_userManager = userManager;

View File

@ -53,10 +53,7 @@ public abstract class PatternFormatter : IPatternFormatter
public string[] GetTags(IPattern pattern)
{
if (pattern == null)
{
throw new ArgumentNullException(nameof(pattern));
}
ArgumentNullException.ThrowIfNull(pattern);
var findedTags = new List<string>(SearchTags(pattern.Body));
Array.ForEach(SearchTags(pattern.Subject), tag => { if (!findedTags.Contains(tag)) findedTags.Add(tag); });
@ -65,18 +62,9 @@ public abstract class PatternFormatter : IPatternFormatter
public void FormatMessage(INoticeMessage message, ITagValue[] tagsValues)
{
if (message == null)
{
throw new ArgumentNullException(nameof(message));
}
if (message.Pattern == null)
{
throw new ArgumentException(nameof(message));
}
if (tagsValues == null)
{
throw new ArgumentNullException(nameof(tagsValues));
}
ArgumentNullException.ThrowIfNull(message);
ArgumentNullException.ThrowIfNull(message.Pattern);
ArgumentNullException.ThrowIfNull(tagsValues);
BeforeFormat(message, tagsValues);

View File

@ -33,10 +33,7 @@ public class TagValue : ITagValue
public TagValue(string tag, object value)
{
if (string.IsNullOrEmpty(tag))
{
throw new ArgumentNullException(nameof(tag));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(tag);
Tag = tag;
Value = value;

View File

@ -58,10 +58,7 @@ public class RecipientProviderImpl : IRecipientProvider
public virtual IRecipient[] GetGroupEntries(IRecipientsGroup group)
{
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}
ArgumentNullException.ThrowIfNull(group);
var result = new List<IRecipient>();
if (TryParseGuid(group.ID, out var groupID))
@ -79,10 +76,7 @@ public class RecipientProviderImpl : IRecipientProvider
public virtual IRecipientsGroup[] GetGroups(IRecipient recipient)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(recipient);
var result = new List<IRecipientsGroup>();
if (TryParseGuid(recipient.ID, out var recID))
@ -110,10 +104,7 @@ public class RecipientProviderImpl : IRecipientProvider
public virtual string[] GetRecipientAddresses(IDirectRecipient recipient, string senderName)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(recipient);
if (TryParseGuid(recipient.ID, out var userID))
{

View File

@ -47,14 +47,8 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual string[] GetSubscriptionMethod(INotifyAction action, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
var senders = _subscriptionProvider.GetSubscriptionMethod(action, recipient);
if (senders == null || senders.Length == 0)
@ -75,10 +69,7 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual IRecipient[] GetRecipients(INotifyAction action, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
var recipents = new List<IRecipient>(5);
var directRecipients = _subscriptionProvider.GetRecipients(action, objectID) ?? new IRecipient[0];
@ -89,14 +80,8 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual bool IsUnsubscribe(IDirectRecipient recipient, INotifyAction action, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
return _subscriptionProvider.IsUnsubscribe(recipient, action, objectID);
}
@ -104,48 +89,30 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual void Subscribe(INotifyAction action, string objectID, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
_subscriptionProvider.Subscribe(action, objectID, recipient);
}
public virtual void UnSubscribe(INotifyAction action, string objectID, IRecipient recipient)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
_subscriptionProvider.UnSubscribe(action, objectID, recipient);
}
public void UnSubscribe(INotifyAction action, string objectID)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
_subscriptionProvider.UnSubscribe(action, objectID);
}
public void UnSubscribe(INotifyAction action)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
_subscriptionProvider.UnSubscribe(action);
}
@ -161,32 +128,17 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual void UpdateSubscriptionMethod(INotifyAction action, IRecipient recipient, params string[] senderNames)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
if (senderNames == null)
{
throw new ArgumentNullException(nameof(senderNames));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
ArgumentNullException.ThrowIfNull(senderNames);
_subscriptionProvider.UpdateSubscriptionMethod(action, recipient, senderNames);
}
public virtual object GetSubscriptionRecord(INotifyAction action, IRecipient recipient, string objectID)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
var subscriptionRecord = _subscriptionProvider.GetSubscriptionRecord(action, recipient, objectID);
@ -212,14 +164,8 @@ public class TopSubscriptionProvider : ISubscriptionProvider
public virtual string[] GetSubscriptions(INotifyAction action, IRecipient recipient, bool checkSubscription = true)
{
if (recipient == null)
{
throw new ArgumentNullException(nameof(recipient));
}
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(recipient);
var objects = new List<string>();
var direct = _subscriptionProvider.GetSubscriptions(action, recipient, checkSubscription) ?? Array.Empty<string>();

View File

@ -44,15 +44,8 @@ public class AzManager
ISecurityObjectProvider securityObjProvider, out ISubject denySubject,
out IAction denyAction)
{
if (subject == null)
{
throw new ArgumentNullException(nameof(subject));
}
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
ArgumentNullException.ThrowIfNull(subject);
var acl = GetAzManagerAcl(subject, action, objectId, securityObjProvider);
denySubject = acl.DenySubject;

View File

@ -36,14 +36,8 @@ class PermissionProvider : IPermissionProvider
public IEnumerable<Ace> GetAcl(ISubject subject, IAction action, ISecurityObjectId objectId, ISecurityObjectProvider secObjProvider)
{
if (subject == null)
{
throw new ArgumentNullException(nameof(subject));
}
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(subject);
ArgumentNullException.ThrowIfNull(action);
return _authorizationManager
.GetAcesWithInherits(subject.ID, action.ID, objectId, secObjProvider)

View File

@ -23,8 +23,6 @@
*
*/
using static ASC.Security.Cryptography.EmailValidationKeyProvider;
namespace ASC.Security.Cryptography;
[Scope]
@ -69,10 +67,7 @@ public class EmailValidationKeyProvider
public string GetEmailKey(int tenantId, string email)
{
if (string.IsNullOrEmpty(email))
{
throw new ArgumentNullException(nameof(email));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(email);
email = FormatEmail(tenantId, email);
@ -84,10 +79,7 @@ public class EmailValidationKeyProvider
private string FormatEmail(int tenantId, string email)
{
if (email == null)
{
throw new ArgumentNullException(nameof(email));
}
ArgumentNullException.ThrowIfNull(email);
try
{
@ -116,14 +108,8 @@ public class EmailValidationKeyProvider
private ValidationResult ValidateEmailKeyInternal(string email, string key, TimeSpan validInterval)
{
if (string.IsNullOrEmpty(email))
{
throw new ArgumentNullException(nameof(email));
}
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(email);
ArgumentNullException.ThrowIfNull(key);
email = FormatEmail(_tenantManager.GetCurrentTenant().Id, email);
var parts = key.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

View File

@ -41,10 +41,7 @@ public class UserFormatter : IComparer<UserInfo>
public string GetUserName(UserInfo userInfo, DisplayUserNameFormat format)
{
if (userInfo == null)
{
throw new ArgumentNullException(nameof(userInfo));
}
ArgumentNullException.ThrowIfNull(userInfo);
return string.Format(GetUserDisplayFormat(format), userInfo.FirstName, userInfo.LastName);
}

View File

@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<NoWarn>NU1701</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>

View File

@ -47,10 +47,7 @@ public static class ActionInvoker
int sleepMs = 1000,
bool isSleepExponential = true)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}
ArgumentNullException.ThrowIfNull(action);
var countAttempts = 0;
while (countAttempts++ < maxAttempts)

View File

@ -50,14 +50,9 @@ public static class EnumerableExtensions
Func<TEntry, TKey> keySelector,
Func<TEntry, TKey> parentKeySelector)
{
if (elements == null)
throw new ArgumentNullException(nameof(elements));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
if (parentKeySelector == null)
throw new ArgumentNullException(nameof(parentKeySelector));
ArgumentNullException.ThrowIfNull(elements);
ArgumentNullException.ThrowIfNull(keySelector);
ArgumentNullException.ThrowIfNull(parentKeySelector);
var dic = elements.ToDictionary(keySelector, x => new TreeNode<TEntry>(x));
@ -76,8 +71,7 @@ public static class EnumerableExtensions
public static IEnumerable<IEnumerable<TEntry>> MakeParts<TEntry>(this IEnumerable<TEntry> collection, int partLength)
{
if (collection == null)
throw new ArgumentNullException(nameof(collection));
ArgumentNullException.ThrowIfNull(collection);
if (partLength <= 0)
throw new ArgumentOutOfRangeException(nameof(partLength), partLength, "Length must be positive integer");

View File

@ -1,20 +1,14 @@
global using System;
global using System.Collections.Generic;
global using System.ComponentModel.DataAnnotations;
global using System.ComponentModel.DataAnnotations;
global using System.ComponentModel.DataAnnotations.Schema;
global using System.Configuration;
global using System.Data;
global using System.Data.Common;
global using System.Diagnostics;
global using System.IO;
global using System.Linq;
global using System.Reflection;
global using System.Security.Cryptography;
global using System.ServiceModel;
global using System.Text;
global using System.Text.RegularExpressions;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Xml;
global using System.Xml.Linq;
global using System.Xml.XPath;

View File

@ -51,8 +51,8 @@ public class BackupPortalTask : PortalTaskBase
public void Init(int tenantId, string fromConfigPath, string toFilePath, int limit)
{
if (string.IsNullOrEmpty(toFilePath))
throw new ArgumentNullException(nameof(toFilePath));
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(toFilePath);
BackupFilePath = toFilePath;
Limit = limit;
Init(tenantId, fromConfigPath);

View File

@ -62,10 +62,7 @@ public class RestorePortalTask : PortalTaskBase
public void Init(string toConfigPath, string fromFilePath, int tenantId = -1, ColumnMapper columnMapper = null, string upgradesPath = null)
{
if (fromFilePath == null)
{
throw new ArgumentNullException(nameof(fromFilePath));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(fromFilePath);
if (!File.Exists(fromFilePath))
{

View File

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,6 +1,4 @@
global using System;
global using System.Collections.Generic;
global using System.Globalization;
global using System.Globalization;
global using System.Security.Cryptography;
global using System.Text;
@ -20,4 +18,3 @@ global using Microsoft.AspNetCore.Http;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Options;
global using Microsoft.Extensions.Primitives;

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -83,10 +83,7 @@ public abstract class BaseStorage : IDataStore
public Task<Uri> GetPreSignedUriAsync(string domain, string path, TimeSpan expire, IEnumerable<string> headers)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
if (string.IsNullOrEmpty(Tenant) && IsSupportInternalUri)
{

View File

@ -55,25 +55,10 @@ public class CrossModuleTransferUtility
public Task CopyFileAsync(string srcDomain, string srcPath, string destDomain, string destPath)
{
if (srcDomain == null)
{
throw new ArgumentNullException(nameof(srcDomain));
}
if (srcPath == null)
{
throw new ArgumentNullException(nameof(srcPath));
}
if (destDomain == null)
{
throw new ArgumentNullException(nameof(destDomain));
}
if (destPath == null)
{
throw new ArgumentNullException(nameof(destPath));
}
ArgumentNullException.ThrowIfNull(srcDomain);
ArgumentNullException.ThrowIfNull(srcPath);
ArgumentNullException.ThrowIfNull(destDomain);
ArgumentNullException.ThrowIfNull(destPath);
return InternalCopyFileAsync(srcDomain, srcPath, destDomain, destPath);
}

View File

@ -82,10 +82,7 @@ public class DiscDataStore : BaseStorage
public string GetPhysicalPath(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var pathMap = GetPath(domain);
@ -99,10 +96,7 @@ public class DiscDataStore : BaseStorage
public Stream GetReadStream(string domain, string path, bool withDecription)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);
@ -116,10 +110,7 @@ public class DiscDataStore : BaseStorage
public override Task<Stream> GetReadStreamAsync(string domain, string path, int offset)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);
@ -158,15 +149,8 @@ public class DiscDataStore : BaseStorage
QuotaController.QuotaUsedCheck(buffered.Length);
}
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
if (buffered == null)
{
throw new ArgumentNullException(nameof(stream));
}
ArgumentNullException.ThrowIfNull(path);
ArgumentNullException.ThrowIfNull(stream);
//Try seek to start
return InternalSaveAsync(domain, path, buffered);
@ -260,10 +244,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteAsync(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);
@ -283,10 +264,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteFilesAsync(string domain, List<string> paths)
{
if (paths == null)
{
throw new ArgumentNullException(nameof(paths));
}
ArgumentNullException.ThrowIfNull(paths);
foreach (var path in paths)
{
@ -308,10 +286,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteFilesAsync(string domain, string folderPath, string pattern, bool recursive)
{
if (folderPath == null)
{
throw new ArgumentNullException(nameof(folderPath));
}
ArgumentNullException.ThrowIfNull(folderPath);
//Return dirs
var targetDir = GetTarget(domain, folderPath);
@ -334,10 +309,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteFilesAsync(string domain, string folderPath, DateTime fromDate, DateTime toDate)
{
if (folderPath == null)
{
throw new ArgumentNullException(nameof(folderPath));
}
ArgumentNullException.ThrowIfNull(folderPath);
//Return dirs
var targetDir = GetTarget(domain, folderPath);
@ -381,15 +353,8 @@ public class DiscDataStore : BaseStorage
public override Task<Uri> MoveAsync(string srcdomain, string srcpath, string newdomain, string newpath, bool quotaCheckFileSize = true)
{
if (srcpath == null)
{
throw new ArgumentNullException(nameof(srcpath));
}
if (newpath == null)
{
throw new ArgumentNullException(nameof(srcpath));
}
ArgumentNullException.ThrowIfNull(srcpath);
ArgumentNullException.ThrowIfNull(newpath);
var target = GetTarget(srcdomain, srcpath);
var newtarget = GetTarget(newdomain, newpath);
@ -423,10 +388,7 @@ public class DiscDataStore : BaseStorage
public override Task<bool> IsDirectoryAsync(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
//Return dirs
var targetDir = GetTarget(domain, path);
@ -439,10 +401,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteDirectoryAsync(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
//Return dirs
var targetDir = GetTarget(domain, path);
@ -512,10 +471,7 @@ public class DiscDataStore : BaseStorage
public override Task DeleteExpiredAsync(string domain, string folderPath, TimeSpan oldThreshold)
{
if (folderPath == null)
{
throw new ArgumentNullException(nameof(folderPath));
}
ArgumentNullException.ThrowIfNull(folderPath);
//Return dirs
var targetDir = GetTarget(domain, folderPath);
@ -562,10 +518,7 @@ public class DiscDataStore : BaseStorage
public override IAsyncEnumerable<string> ListDirectoriesRelativeAsync(string domain, string path, bool recursive)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
//Return dirs
var targetDir = GetTarget(domain, path);
@ -587,10 +540,7 @@ public class DiscDataStore : BaseStorage
public override IAsyncEnumerable<string> ListFilesRelativeAsync(string domain, string path, string pattern, bool recursive)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
//Return dirs
var targetDir = GetTarget(domain, path);
@ -612,10 +562,7 @@ public class DiscDataStore : BaseStorage
public override Task<bool> IsFileAsync(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
//Return dirs
var target = GetTarget(domain, path);
@ -649,15 +596,8 @@ public class DiscDataStore : BaseStorage
public override Task<Uri> CopyAsync(string srcdomain, string srcpath, string newdomain, string newpath)
{
if (srcpath == null)
{
throw new ArgumentNullException(nameof(srcpath));
}
if (newpath == null)
{
throw new ArgumentNullException(nameof(srcpath));
}
ArgumentNullException.ThrowIfNull(srcpath);
ArgumentNullException.ThrowIfNull(newpath);
var target = GetTarget(srcdomain, srcpath);
var newtarget = GetTarget(newdomain, newpath);
@ -701,10 +641,7 @@ public class DiscDataStore : BaseStorage
public Stream GetWriteStream(string domain, string path, FileMode fileMode)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);
CreateDirectory(target);
@ -714,10 +651,7 @@ public class DiscDataStore : BaseStorage
public void Decrypt(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);
@ -802,10 +736,7 @@ public class DiscDataStore : BaseStorage
public void Encrypt(string domain, string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
ArgumentNullException.ThrowIfNull(path);
var target = GetTarget(domain, path);

View File

@ -1,19 +1,12 @@
global using System;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Collections.Concurrent;
global using System.Globalization;
global using System.IO;
global using System.Linq;
global using System.Net;
global using System.Net.Http;
global using System.Runtime.Serialization;
global using System.Security.Cryptography;
global using System.ServiceModel;
global using System.Text;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Web;
global using Amazon;

View File

@ -29,10 +29,7 @@ public static class TenantPath
{
public static string CreatePath(string tenant)
{
if (tenant == null)
{
throw new ArgumentNullException(nameof(tenant));
}
ArgumentNullException.ThrowIfNull(tenant);
if (long.TryParse(tenant, NumberStyles.Integer, CultureInfo.InvariantCulture, out var tenantId))
{

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,12 +1,7 @@
global using System;
global using System.Collections.Generic;
global using System.Data;
global using System.Data;
global using System.Diagnostics;
global using System.Globalization;
global using System.IO;
global using System.Linq;
global using System.Net;
global using System.Net.Http;
global using System.Net.Http.Headers;
global using System.Reflection;
global using System.Runtime.Serialization;
@ -14,8 +9,6 @@ global using System.Security.Cryptography.Pkcs;
global using System.Security.Cryptography.X509Certificates;
global using System.Text;
global using System.Text.Json.Serialization;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Web;
global using System.Xml.Linq;
global using System.Xml.XPath;

View File

@ -107,20 +107,9 @@ public class OAuth20TokenHelper
var clientSecret = loginProvider.ClientSecret;
var redirectUri = loginProvider.RedirectUri;
if (string.IsNullOrEmpty(authCode))
{
throw new ArgumentNullException(nameof(authCode));
}
if (string.IsNullOrEmpty(clientID))
{
throw new ArgumentNullException(nameof(clientID));
}
if (string.IsNullOrEmpty(clientSecret))
{
throw new ArgumentNullException(nameof(clientSecret));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(authCode);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(clientID);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(clientSecret);
var data = $"code={HttpUtility.UrlEncode(authCode)}&client_id={HttpUtility.UrlEncode(clientID)}&client_secret={HttpUtility.UrlEncode(clientSecret)}";

View File

@ -31,10 +31,7 @@ public static class RequestHelper
public static string PerformRequest(string uri, string contentType = "", string method = "GET", string body = "", Dictionary<string, string> headers = null, int timeout = 30000)
{
if (string.IsNullOrEmpty(uri))
{
throw new ArgumentNullException(nameof(uri));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(uri);
var request = new HttpRequestMessage();
request.RequestUri = new Uri(uri);

View File

@ -73,20 +73,9 @@ public class DocuSignLoginProvider : Consumer, IOAuthProvider
public OAuth20Token GetAccessToken(string authCode)
{
if (string.IsNullOrEmpty(authCode))
{
throw new ArgumentNullException(nameof(authCode));
}
if (string.IsNullOrEmpty(ClientID))
{
throw new ArgumentException(nameof(ClientID));
}
if (string.IsNullOrEmpty(ClientSecret))
{
throw new ArgumentException(nameof(ClientSecret));
}
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(authCode);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(ClientID);
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(ClientSecret);
var data = $"grant_type=authorization_code&code={authCode}";
var headers = new Dictionary<string, string> { { "Authorization", AuthHeader } };

View File

@ -204,10 +204,7 @@ public class LoginProfile
public static bool HasProfile(HttpRequest request)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
ArgumentNullException.ThrowIfNull(request);
return new Uri(request.GetDisplayUrl()).HasProfile();
}
@ -239,10 +236,7 @@ public class LoginProfile
internal void SetField(string name, string value)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
ArgumentNullException.ThrowIfNull(name);
if (!string.IsNullOrEmpty(value))
{
@ -328,10 +322,7 @@ public class LoginProfile
internal void FromSerializedString(string serialized)
{
if (serialized == null)
{
throw new ArgumentNullException(nameof(serialized));
}
ArgumentNullException.ThrowIfNull(serialized);
_fields = serialized.Split(PairSeparator).ToDictionary(x => x.Split(KeyValueSeparator)[0], y => y.Split(KeyValueSeparator)[1]);
}
@ -355,10 +346,7 @@ public class LoginProfile
protected LoginProfile(Signature signature, InstanceCrypto instanceCrypto, SerializationInfo info) : this(signature, instanceCrypto)
{
if (info == null)
{
throw new ArgumentNullException(nameof(info));
}
ArgumentNullException.ThrowIfNull(info);
var transformed = (string)info.GetValue(QueryParamName, typeof(string));
FromTransport(transformed);

View File

@ -5,6 +5,7 @@
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,26 +1,23 @@
global using System;
global using System.Collections.Generic;
global using System.Data;
global using System.Linq;
global using System.Data;
global using ASC.Common;
global using ASC.Common.Mapping;
global using ASC.Core;
global using ASC.Core.Common.EF;
global using ASC.Feed.Models;
global using ASC.Core.Common.EF.Model;
global using ASC.Core.Tenants;
global using ASC.Core.Users;
global using ASC.Common.Mapping;
global using ASC.Feed.Mapping;
global using ASC.Feed.Data;
global using ASC.Feed.Core;
global using AutoMapper;
global using ASC.Feed.Data;
global using ASC.Feed.Mapping;
global using ASC.Feed.Models;
global using Autofac;
global using AutoMapper;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore.Migrations;
global using Microsoft.EntityFrameworkCore.Infrastructure;
global using Microsoft.EntityFrameworkCore.Migrations;
global using Newtonsoft.Json;

View File

@ -5,6 +5,7 @@
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,7 +1,4 @@
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Net;
global using System.Net;
global using System.Net.Sockets;
global using System.Runtime.Serialization;
global using System.Web;
@ -16,10 +13,10 @@ global using ASC.Core.Common.EF.Context;
global using ASC.Core.Common.EF.Model;
global using ASC.Core.Common.Settings;
global using AutoMapper;
global using AutoMapper.QueryableExtensions;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Http.Extensions;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Options;
global using AutoMapper;
global using AutoMapper.QueryableExtensions;

View File

@ -5,6 +5,7 @@
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,8 +1,4 @@
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Web;
global using System.Web;
global using ASC.Common;
global using ASC.Common.Logging;
@ -10,24 +6,24 @@ global using ASC.Common.Mapping;
global using ASC.Core;
global using ASC.Core.Common.EF;
global using ASC.Core.Common.EF.Model;
global using ASC.MessagingSystem.Mapping;
global using ASC.MessagingSystem.Core;
global using ASC.MessagingSystem.Core.Sender;
global using ASC.MessagingSystem.Data;
global using ASC.MessagingSystem.Mapping;
global using ASC.MessagingSystem.Models;
global using AutoMapper;
global using Microsoft.AspNetCore.Http;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.EntityFrameworkCore.Migrations;
global using Microsoft.EntityFrameworkCore.Metadata;
global using Microsoft.EntityFrameworkCore.Infrastructure;
global using Microsoft.EntityFrameworkCore.Metadata;
global using Microsoft.EntityFrameworkCore.Migrations;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Options;
global using Microsoft.Extensions.Primitives;
global using AutoMapper;
global using Newtonsoft.Json;
global using UAParser;

View File

@ -6,6 +6,7 @@
<Product>ASC.Notify.Textile</Product>
<Copyright>(c) Ascensio System SIA. All rights reserved</Copyright>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>

View File

@ -1,7 +1,4 @@
global using System;
global using System.IO;
global using System.Linq;
global using System.Reflection;
global using System.Reflection;
global using System.Text;
global using System.Text.RegularExpressions;
global using System.Web;

View File

@ -12,6 +12,7 @@
<Copyright>(c) Ascensio System SIA. All rights reserved</Copyright>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>

View File

@ -1,5 +1,5 @@
namespace Textile
{
namespace Textile;
public class BlockModifier
{
protected BlockModifier()
@ -16,4 +16,3 @@ namespace Textile
return line;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile
{
namespace Textile;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class BlockModifierAttribute : Attribute
{
@ -7,4 +7,3 @@ namespace Textile
{
}
}
}

View File

@ -10,8 +10,8 @@
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public static class BlockAttributesParser
{
public static StyleReader Styler { get; set; }
@ -148,4 +148,3 @@ namespace Textile.Blocks
return style;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class BoldPhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"\*\*", "b");
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class CapitalsBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -14,4 +14,3 @@ namespace Textile.Blocks
return @"<span class=""caps"">" + m.Groups["caps"].Value + @"</span>";
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class CitePhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"\?\?", "cite");
}
}
}

View File

@ -10,8 +10,8 @@
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class CodeBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -53,4 +53,3 @@ namespace Textile.Blocks
return res;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class DeletedPhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"\-", "del");
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class EmphasisPhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"_", "em");
}
}
}

View File

@ -10,8 +10,8 @@
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class FootNoteReferenceBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -19,4 +19,3 @@ namespace Textile.Blocks
return Regex.Replace(line, @"\b\[([0-9]+)\](\W)", "<sup><a href=\"#fn$1\">$1</a></sup>$2");
}
}
}

View File

@ -10,8 +10,8 @@
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class GlyphBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -85,4 +85,3 @@ namespace Textile.Blocks
return sb.ToString();
}
}
}

View File

@ -11,11 +11,11 @@
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class HyperLinkBlockModifier : BlockModifier
{
private readonly string m_rel = string.Empty;
private readonly string _rel = string.Empty;
public override string ModifyLine(string line)
{
@ -44,8 +44,8 @@ namespace Textile.Blocks
var linkText = m.Groups["text"].Value.Trim(' ');
var str = m.Groups["pre"].Value + "<a ";
if (!string.IsNullOrEmpty(m_rel))
str += "ref=\"" + m_rel + "\" ";
if (!string.IsNullOrEmpty(_rel))
str += "ref=\"" + _rel + "\" ";
str += "href=\"" +
m.Groups["url"].Value + m.Groups["slash"].Value + "\"" +
atts +
@ -53,4 +53,3 @@ namespace Textile.Blocks
return str;
}
}
}

View File

@ -10,8 +10,8 @@
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class ImageBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -66,4 +66,3 @@ namespace Textile.Blocks
return res;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class InsertedPhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"\+", "ins");
}
}
}

View File

@ -1,5 +1,5 @@
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class ItalicPhraseBlockModifier : PhraseBlockModifier
{
public override string ModifyLine(string line)
@ -7,4 +7,3 @@ namespace Textile.Blocks
return PhraseModifierFormat(line, @"__", "i");
}
}
}

View File

@ -11,8 +11,8 @@
#endregion
namespace Textile.Blocks
{
namespace Textile.Blocks;
public class NoTextileBlockModifier : BlockModifier
{
public override string ModifyLine(string line)
@ -29,4 +29,3 @@ namespace Textile.Blocks
return line;
}
}
}

Some files were not shown because too many files have changed in this diff Show More