Skip to content

Commit c57fba8

Browse files
IdamkinImichaeldemey
authored andcommitted
Port itextpdf commit 2b00de5
Update Version class for LicenseKey DEVSIX-1464
1 parent ab68ff6 commit c57fba8

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

src/core/iTextSharp/text/Version.cs

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -97,40 +97,45 @@ public static Version GetInstance() {
9797
version = new Version();
9898
lock (version) {
9999
try {
100-
Type type = Type.GetType("iTextSharp.license.LicenseKey, itextsharp.LicenseKey");
101-
MethodInfo m = type.GetMethod("GetLicenseeInfo");
102-
String[] info = (String[]) m.Invoke(Activator.CreateInstance(type), null);
103-
if (info[3] != null && info[3].Trim().Length > 0) {
104-
version.key = info[3];
105-
} else {
106-
version.key = "Trial version ";
107-
if (info[5] == null) {
108-
version.key += "unauthorised";
109-
} else {
110-
version.key += info[5];
111-
}
112-
}
113-
if (info[4] != null && info[4].Trim().Length > 0) {
114-
version.iTextVersion = info[4];
115-
} else if (info[2] != null && info[2].Trim().Length > 0) {
116-
version.iTextVersion += " (" + info[2];
117-
if (!version.key.ToLower().StartsWith("trial")) {
118-
version.iTextVersion += "; licensed version)";
119-
} else {
120-
version.iTextVersion += "; " + version.key + ")";
121-
}
122-
} else if (info[0] != null && info[0].Trim().Length > 0) {
123-
// fall back to contact name, if company name is unavailable
124-
version.iTextVersion += " (" + info[0];
125-
if (!version.key.ToLower().StartsWith("trial")) {
126-
// we shouldn't have a licensed version without company name,
127-
// but let's account for it anyway
128-
version.iTextVersion += "; licensed version)";
129-
} else {
130-
version.iTextVersion += "; " + version.key + ")";
131-
}
132-
} else {
133-
throw new Exception();
100+
Type type = Type.GetType("iText.License.LicenseKey, itext.licensekey");
101+
if (type != null) {
102+
Type[] cArg = new Type[] {typeof(String)};
103+
MethodInfo m = type.GetMethod("GetLicenseeInfoForVersion", cArg);
104+
String coreVersion = release;
105+
Object[] args = new Object[] {coreVersion};
106+
String[] info = (String[]) m.Invoke(Activator.CreateInstance(type), args);
107+
if (info[3] != null && info[3].Trim().Length > 0) {
108+
version.key = info[3];
109+
} else {
110+
version.key = "Trial version ";
111+
if (info[5] == null) {
112+
version.key += "unauthorised";
113+
} else {
114+
version.key += info[5];
115+
}
116+
}
117+
if (info[4] != null && info[4].Trim().Length > 0) {
118+
version.iTextVersion = info[4];
119+
} else if (info[2] != null && info[2].Trim().Length > 0) {
120+
version.iTextVersion += " (" + info[2];
121+
if (!version.key.ToLower().StartsWith("trial")) {
122+
version.iTextVersion += "; licensed version)";
123+
} else {
124+
version.iTextVersion += "; " + version.key + ")";
125+
}
126+
} else if (info[0] != null && info[0].Trim().Length > 0) {
127+
// fall back to contact name, if company name is unavailable
128+
version.iTextVersion += " (" + info[0];
129+
if (!version.key.ToLower().StartsWith("trial")) {
130+
// we shouldn't have a licensed version without company name,
131+
// but let's account for it anyway
132+
version.iTextVersion += "; licensed version)";
133+
} else {
134+
version.iTextVersion += "; " + version.key + ")";
135+
}
136+
} else {
137+
throw new Exception();
138+
}
134139
}
135140
} catch (Exception) {
136141
version.iTextVersion += AGPL;

0 commit comments

Comments
 (0)