# GeneralReturnValues **Repository Path**: zhangyin-gitee/general-return-values ## Basic Information - **Project Name**: GeneralReturnValues - **Description**: 通用返回值,支持序列化与反序列化。 - **Primary Language**: Unknown - **License**: CC-BY-4.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2023-03-18 - **Last Updated**: 2024-07-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GeneralReturnValues ## Examples(实例) ``` using System.Text.Json; using TheSalLab.GeneralReturnValues; ServiceResult FunctionThatSuccess() { return ServiceResult.CreateSuccessResult(); } ServiceResult FunctionThatEncountersAnException() { var e = new Exception(); return ServiceResult.CreateExceptionResult(e, e.Message); } ServiceResult FunctionThatReturnsAnInt() { return ServiceResult.CreateSuccessResult(256); } ServiceResultViewModel FunctionThatReturnsAServiceResultViewModel() { return ServiceResult.CreateSuccessResult().ToServiceResultViewModel(); } void ServiceResultViewModelCanBeSerializedAndDeserialized() { var e = new Exception(); var serviceResult = ServiceResult.CreateExceptionResult(e, e.Message); var json = JsonSerializer.Serialize(serviceResult.ToServiceResultViewModel()); var serviceResultViewModel = JsonSerializer .Deserialize(json); serviceResult = serviceResultViewModel.ToServiceResult(); } Console.WriteLine("Hello World!"); ``` ## License GeneralReturnValues is licensed under [Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/). For attribution: Zhang, Yin. GeneralReturnValues. Northeastern University. Besides, please let me know if you plan to use GeneralReturnValues in your app by sending an email to zhangyin@mail.neu.edu.cn Thanks a lot! ## 许可证 GeneralReturnValues采用[署名4.0国际(CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/deed.zh)许可证。 署名请引用: 张引.GeneralReturnValues.东北大学. 除此之外,如果你计划使用GeneralReturnValues,请发送邮件到zhangyin@mail.neu.edu.cn告知我。 谢谢!