Program.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Masuit.Tools.Models;
  2. using Masuit.Tools.Reflection;
  3. using Masuit.Tools.Security;
  4. using Microsoft.AspNetCore;
  5. using Microsoft.AspNetCore.Hosting;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. namespace NetCoreTest
  10. {
  11. public class Program
  12. {
  13. public static void Main(string[] args)
  14. {
  15. var myClass = new MyClass()
  16. {
  17. MyProperty1 = 1,
  18. Name = "1",
  19. Parent = new MyClass()
  20. {
  21. Name = "mc",
  22. Parent = new MyClass()
  23. {
  24. Name = "ccc"
  25. }
  26. }
  27. };
  28. var path = myClass.Path(c => c.Name);
  29. Console.WriteLine(path);
  30. myClass.SetProperty(nameof(MyClass.MyProperty1), 1);
  31. Console.ReadKey();
  32. var rsaKey = RsaCrypt.GenerateRsaKeys(RsaKeyType.PKCS8, 2048);
  33. Console.WriteLine(rsaKey.PrivateKey);
  34. Console.WriteLine(rsaKey.PublicKey);
  35. var enc = "123456".RSAEncrypt();
  36. Console.WriteLine(enc);
  37. Console.Beep();
  38. var dec = enc.RSADecrypt();
  39. Console.WriteLine(dec);
  40. Console.ReadKey();
  41. //CreateWebHostBuilder(args).Build().Run();
  42. }
  43. public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  44. WebHost.CreateDefaultBuilder(args)
  45. .UseStartup<Startup>();
  46. }
  47. public class MyClass : ITreeParent<MyClass>
  48. {
  49. [Description("test")]
  50. public string MyProperty { get; set; }
  51. public int? MyProperty1 { get; set; }
  52. /// <summary>
  53. /// 名字
  54. /// </summary>
  55. public string Name { get; set; }
  56. /// <summary>
  57. /// 父节点
  58. /// </summary>
  59. public virtual MyClass Parent { get; set; }
  60. /// <summary>
  61. /// 子级
  62. /// </summary>
  63. public ICollection<MyClass> Children { get; set; } = new List<MyClass>();
  64. }
  65. }