From e283a3e745bad05a55c572646d7b20fbaaeb522d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Aug 2019 17:38:56 +0800 Subject: Add script to convert encoding and eof. And of course run it. --- Timeline/Entities/Http/Common.cs | 74 ++++++++++++------------ Timeline/Entities/Http/Token.cs | 52 ++++++++--------- Timeline/Entities/Http/User.cs | 40 ++++++------- Timeline/Entities/PutResult.cs | 34 +++++------ Timeline/Entities/UserInfo.cs | 46 +++++++-------- Timeline/Entities/UserUtility.cs | 120 +++++++++++++++++++-------------------- 6 files changed, 183 insertions(+), 183 deletions(-) (limited to 'Timeline/Entities') diff --git a/Timeline/Entities/Http/Common.cs b/Timeline/Entities/Http/Common.cs index 3a45a0ae..4cdc85dd 100644 --- a/Timeline/Entities/Http/Common.cs +++ b/Timeline/Entities/Http/Common.cs @@ -1,37 +1,37 @@ -namespace Timeline.Entities.Http -{ - public class CommonResponse - { - public CommonResponse() - { - - } - - public CommonResponse(int code, string message) - { - Code = code; - Message = message; - } - - public int Code { get; set; } - public string Message { get; set; } - } - - public static class CommonPutResponse - { - public const int CreatedCode = 0; - public const int ModifiedCode = 1; - - public static CommonResponse Created { get; } = new CommonResponse(CreatedCode, "A new item is created."); - public static CommonResponse Modified { get; } = new CommonResponse(ModifiedCode, "An existent item is modified."); - } - - public static class CommonDeleteResponse - { - public const int DeletedCode = 0; - public const int NotExistsCode = 1; - - public static CommonResponse Deleted { get; } = new CommonResponse(DeletedCode, "An existent item is deleted."); - public static CommonResponse NotExists { get; } = new CommonResponse(NotExistsCode, "The item does not exist."); - } -} +namespace Timeline.Entities.Http +{ + public class CommonResponse + { + public CommonResponse() + { + + } + + public CommonResponse(int code, string message) + { + Code = code; + Message = message; + } + + public int Code { get; set; } + public string Message { get; set; } + } + + public static class CommonPutResponse + { + public const int CreatedCode = 0; + public const int ModifiedCode = 1; + + public static CommonResponse Created { get; } = new CommonResponse(CreatedCode, "A new item is created."); + public static CommonResponse Modified { get; } = new CommonResponse(ModifiedCode, "An existent item is modified."); + } + + public static class CommonDeleteResponse + { + public const int DeletedCode = 0; + public const int NotExistsCode = 1; + + public static CommonResponse Deleted { get; } = new CommonResponse(DeletedCode, "An existent item is deleted."); + public static CommonResponse NotExists { get; } = new CommonResponse(NotExistsCode, "The item does not exist."); + } +} diff --git a/Timeline/Entities/Http/Token.cs b/Timeline/Entities/Http/Token.cs index 8a02ed2e..5e261f30 100644 --- a/Timeline/Entities/Http/Token.cs +++ b/Timeline/Entities/Http/Token.cs @@ -1,26 +1,26 @@ -namespace Timeline.Entities.Http -{ - public class CreateTokenRequest - { - public string Username { get; set; } - public string Password { get; set; } - // in day - public double? ExpireOffset { get; set; } - } - - public class CreateTokenResponse - { - public string Token { get; set; } - public UserInfo User { get; set; } - } - - public class VerifyTokenRequest - { - public string Token { get; set; } - } - - public class VerifyTokenResponse - { - public UserInfo User { get; set; } - } -} +namespace Timeline.Entities.Http +{ + public class CreateTokenRequest + { + public string Username { get; set; } + public string Password { get; set; } + // in day + public double? ExpireOffset { get; set; } + } + + public class CreateTokenResponse + { + public string Token { get; set; } + public UserInfo User { get; set; } + } + + public class VerifyTokenRequest + { + public string Token { get; set; } + } + + public class VerifyTokenResponse + { + public UserInfo User { get; set; } + } +} diff --git a/Timeline/Entities/Http/User.cs b/Timeline/Entities/Http/User.cs index b5384778..e9aaf795 100644 --- a/Timeline/Entities/Http/User.cs +++ b/Timeline/Entities/Http/User.cs @@ -1,20 +1,20 @@ -namespace Timeline.Entities.Http -{ - public class UserPutRequest - { - public string Password { get; set; } - public bool Administrator { get; set; } - } - - public class UserPatchRequest - { - public string Password { get; set; } - public bool? Administrator { get; set; } - } - - public class ChangePasswordRequest - { - public string OldPassword { get; set; } - public string NewPassword { get; set; } - } -} +namespace Timeline.Entities.Http +{ + public class UserPutRequest + { + public string Password { get; set; } + public bool Administrator { get; set; } + } + + public class UserPatchRequest + { + public string Password { get; set; } + public bool? Administrator { get; set; } + } + + public class ChangePasswordRequest + { + public string OldPassword { get; set; } + public string NewPassword { get; set; } + } +} diff --git a/Timeline/Entities/PutResult.cs b/Timeline/Entities/PutResult.cs index 4ed48572..32b87e25 100644 --- a/Timeline/Entities/PutResult.cs +++ b/Timeline/Entities/PutResult.cs @@ -1,17 +1,17 @@ -namespace Timeline.Entities -{ - /// - /// Represents the result of a "put" operation. - /// - public enum PutResult - { - /// - /// Indicates the item did not exist and now is created. - /// - Created, - /// - /// Indicates the item exists already and is modified. - /// - Modified - } -} +namespace Timeline.Entities +{ + /// + /// Represents the result of a "put" operation. + /// + public enum PutResult + { + /// + /// Indicates the item did not exist and now is created. + /// + Created, + /// + /// Indicates the item exists already and is modified. + /// + Modified + } +} diff --git a/Timeline/Entities/UserInfo.cs b/Timeline/Entities/UserInfo.cs index 414a8dfe..c75168b8 100644 --- a/Timeline/Entities/UserInfo.cs +++ b/Timeline/Entities/UserInfo.cs @@ -1,23 +1,23 @@ -namespace Timeline.Entities -{ - public sealed class UserInfo - { - public UserInfo() - { - } - - public UserInfo(string username, bool administrator) - { - Username = username; - Administrator = administrator; - } - - public string Username { get; set; } - public bool Administrator { get; set; } - - public override string ToString() - { - return $"Username: {Username} ; Administrator: {Administrator}"; - } - } -} +namespace Timeline.Entities +{ + public sealed class UserInfo + { + public UserInfo() + { + } + + public UserInfo(string username, bool administrator) + { + Username = username; + Administrator = administrator; + } + + public string Username { get; set; } + public bool Administrator { get; set; } + + public override string ToString() + { + return $"Username: {Username} ; Administrator: {Administrator}"; + } + } +} diff --git a/Timeline/Entities/UserUtility.cs b/Timeline/Entities/UserUtility.cs index 14cdb2d6..351d0299 100644 --- a/Timeline/Entities/UserUtility.cs +++ b/Timeline/Entities/UserUtility.cs @@ -1,60 +1,60 @@ -using System; -using System.Linq; -using Timeline.Models; -using Timeline.Services; - -namespace Timeline.Entities -{ - public static class UserUtility - { - public const string UserRole = UserRoles.User; - public const string AdminRole = UserRoles.Admin; - - public static string[] UserRoleArray { get; } = new string[] { UserRole }; - public static string[] AdminRoleArray { get; } = new string[] { UserRole, AdminRole }; - - public static string[] IsAdminToRoleArray(bool isAdmin) - { - return isAdmin ? AdminRoleArray : UserRoleArray; - } - - public static bool RoleArrayToIsAdmin(string[] roles) - { - return roles.Contains(AdminRole); - } - - public static string[] RoleStringToRoleArray(string roleString) - { - return roleString.Split(',').ToArray(); - } - - public static string RoleArrayToRoleString(string[] roles) - { - return string.Join(',', roles); - } - - public static string IsAdminToRoleString(bool isAdmin) - { - return RoleArrayToRoleString(IsAdminToRoleArray(isAdmin)); - } - - public static bool RoleStringToIsAdmin(string roleString) - { - return RoleArrayToIsAdmin(RoleStringToRoleArray(roleString)); - } - - public static UserInfo CreateUserInfo(User user) - { - if (user == null) - throw new ArgumentNullException(nameof(user)); - return new UserInfo(user.Name, RoleStringToIsAdmin(user.RoleString)); - } - - internal static UserCache CreateUserCache(User user) - { - if (user == null) - throw new ArgumentNullException(nameof(user)); - return new UserCache { Username = user.Name, Administrator = RoleStringToIsAdmin(user.RoleString), Version = user.Version }; - } - } -} +using System; +using System.Linq; +using Timeline.Models; +using Timeline.Services; + +namespace Timeline.Entities +{ + public static class UserUtility + { + public const string UserRole = UserRoles.User; + public const string AdminRole = UserRoles.Admin; + + public static string[] UserRoleArray { get; } = new string[] { UserRole }; + public static string[] AdminRoleArray { get; } = new string[] { UserRole, AdminRole }; + + public static string[] IsAdminToRoleArray(bool isAdmin) + { + return isAdmin ? AdminRoleArray : UserRoleArray; + } + + public static bool RoleArrayToIsAdmin(string[] roles) + { + return roles.Contains(AdminRole); + } + + public static string[] RoleStringToRoleArray(string roleString) + { + return roleString.Split(',').ToArray(); + } + + public static string RoleArrayToRoleString(string[] roles) + { + return string.Join(',', roles); + } + + public static string IsAdminToRoleString(bool isAdmin) + { + return RoleArrayToRoleString(IsAdminToRoleArray(isAdmin)); + } + + public static bool RoleStringToIsAdmin(string roleString) + { + return RoleArrayToIsAdmin(RoleStringToRoleArray(roleString)); + } + + public static UserInfo CreateUserInfo(User user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + return new UserInfo(user.Name, RoleStringToIsAdmin(user.RoleString)); + } + + internal static UserCache CreateUserCache(User user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + return new UserCache { Username = user.Name, Administrator = RoleStringToIsAdmin(user.RoleString), Version = user.Version }; + } + } +} -- cgit v1.2.3