Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetLicense()

override? License System.ComponentModel.LicFileLicenseProvider.GetLicense ( LicenseContext context,
Type type,
object? instance,
bool allowExceptions )
inline

Definition at line 39 of file LicFileLicenseProvider.cs.

40 {
41 LicFileLicense licFileLicense = null;
42 if (context != null)
43 {
44 if (context.UsageMode == LicenseUsageMode.Runtime)
45 {
46 string savedLicenseKey = context.GetSavedLicenseKey(type, null);
47 if (savedLicenseKey != null && IsKeyValid(savedLicenseKey, type))
48 {
49 licFileLicense = new LicFileLicense(this, savedLicenseKey);
50 }
51 }
52 if (licFileLicense == null)
53 {
54 string text = null;
55 if (context != null)
56 {
57 ITypeResolutionService typeResolutionService = (ITypeResolutionService)context.GetService(typeof(ITypeResolutionService));
58 if (typeResolutionService != null)
59 {
60 text = typeResolutionService.GetPathOfAssembly(type.Assembly.GetName());
61 }
62 }
63 if (type.Assembly.Location.Length != 0)
64 {
65 if (text == null)
66 {
67 text = type.Module.FullyQualifiedName;
68 }
69 string directoryName = Path.GetDirectoryName(text);
70 string path = directoryName + "\\" + type.FullName + ".lic";
71 if (File.Exists(path))
72 {
73 Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
74 StreamReader streamReader = new StreamReader(stream);
75 string key = streamReader.ReadLine();
76 streamReader.Close();
77 if (IsKeyValid(key, type))
78 {
79 licFileLicense = new LicFileLicense(this, GetKey(type));
80 }
81 }
82 if (licFileLicense != null)
83 {
84 context.SetSavedLicenseKey(type, licFileLicense.LicenseKey);
85 }
86 }
87 }
88 }
89 return licFileLicense;
90 }
virtual bool IsKeyValid(string? key, Type type)
static bool Exists([NotNullWhen(true)] string? path)
Definition File.cs:97
static ? string GetDirectoryName(string? path)
Definition Path.cs:121
override void Close()
override? string ReadLine()

References System.IO.StreamReader.Close(), System.IO.File.Exists(), System.IO.Path.GetDirectoryName(), System.ComponentModel.LicFileLicenseProvider.GetKey(), System.ComponentModel.Design.ITypeResolutionService.GetPathOfAssembly(), System.ComponentModel.LicenseContext.GetSavedLicenseKey(), System.ComponentModel.LicenseContext.GetService(), System.ComponentModel.LicFileLicenseProvider.IsKeyValid(), System.key, System.ComponentModel.LicFileLicenseProvider.LicFileLicense.LicenseKey, System.IO.StreamReader.ReadLine(), System.ComponentModel.LicenseContext.SetSavedLicenseKey(), System.stream, System.text, System.type, and System.ComponentModel.LicenseContext.UsageMode.