Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7ef25cd

Browse files
committed
Remove SS.Text restrictions
1 parent 0b203ed commit 7ef25cd

File tree

7 files changed

+18
-43
lines changed

7 files changed

+18
-43
lines changed

src/ServiceStack.Text/Json/JsonReader.Generic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static ParseStringDelegate GetParseFn()
6565

6666
public static object Parse(string value)
6767
{
68-
TypeConfig<T>.AssertValidUsage();
68+
TypeConfig<T>.Init();
6969

7070
if (ReadFn == null)
7171
{

src/ServiceStack.Text/Json/JsonWriter.Generic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public static void WriteObject(TextWriter writer, object value)
194194
#if __IOS__
195195
if (writer == null) return;
196196
#endif
197-
TypeConfig<T>.AssertValidUsage();
197+
TypeConfig<T>.Init();
198198

199199
try
200200
{
@@ -218,7 +218,7 @@ public static void WriteRootObject(TextWriter writer, object value)
218218
#if __IOS__
219219
if (writer == null) return;
220220
#endif
221-
TypeConfig<T>.AssertValidUsage();
221+
TypeConfig<T>.Init();
222222

223223
JsState.Depth = 0;
224224
CacheFn(writer, value);

src/ServiceStack.Text/Jsv/JsvReader.Generic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static ParseStringDelegate GetParseFn()
6565

6666
public static object Parse(string value)
6767
{
68-
TypeConfig<T>.AssertValidUsage();
68+
TypeConfig<T>.Init();
6969

7070
if (ReadFn == null)
7171
{

src/ServiceStack.Text/Jsv/JsvWriter.Generic.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void WriteObject(TextWriter writer, object value)
137137
#if __IOS__
138138
if (writer == null) return;
139139
#endif
140-
TypeConfig<T>.AssertValidUsage();
140+
TypeConfig<T>.Init();
141141

142142
try
143143
{
@@ -161,15 +161,7 @@ public static void WriteRootObject(TextWriter writer, object value)
161161
#if __IOS__
162162
if (writer == null) return;
163163
#endif
164-
try
165-
{
166-
TypeConfig<T>.AssertValidUsage();
167-
}
168-
catch (Exception ex)
169-
{
170-
var inner = ex.GetInnerMostException();
171-
throw inner;
172-
}
164+
TypeConfig<T>.Init();
173165

174166
JsState.Depth = 0;
175167
CacheFn(writer, value);

src/ServiceStack.Text/LicenseUtils.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public static void Init()
131131
public static class ErrorMessages
132132
{
133133
private const string UpgradeInstructions = " Please see https://servicestack.net to upgrade to a commercial license or visit https://github.com/ServiceStackV3/ServiceStackV3 to revert back to the free ServiceStack v3.";
134-
internal const string ExceededTextTypes = "The free-quota limit on '{0} ServiceStack.Text Types' has been reached." + UpgradeInstructions;
135134
internal const string ExceededRedisTypes = "The free-quota limit on '{0} Redis Types' has been reached." + UpgradeInstructions;
136135
internal const string ExceededRedisRequests = "The free-quota limit on '{0} Redis requests per hour' has been reached." + UpgradeInstructions;
137136
internal const string ExceededOrmLiteTables = "The free-quota limit on '{0} OrmLite Tables' has been reached." + UpgradeInstructions;
@@ -146,7 +145,6 @@ public static class FreeQuotas
146145
{
147146
public const int ServiceStackOperations = 10;
148147
public const int TypeFields = 20;
149-
public const int TextTypes = 80;
150148
public const int RedisTypes = 20;
151149
public const int RedisRequestPerHour = 6000;
152150
public const int OrmLiteTables = 10;
@@ -254,15 +252,6 @@ public static void AssertValidUsage(LicenseFeature feature, QuotaType quotaType,
254252
//Free Quotas
255253
switch (feature)
256254
{
257-
case LicenseFeature.Text:
258-
switch (quotaType)
259-
{
260-
case QuotaType.Types:
261-
ApprovedUsage(licensedFeatures, feature, FreeQuotas.TextTypes, count, ErrorMessages.ExceededTextTypes);
262-
return;
263-
}
264-
break;
265-
266255
case LicenseFeature.Redis:
267256
switch (quotaType)
268257
{
@@ -446,6 +435,7 @@ static class _approved
446435
};
447436
}
448437

438+
[Obsolete("Should no longer be needed")]
449439
public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
450440
{
451441
var accessType = accessToken.GetType();

src/ServiceStack.Text/TypeConfig.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ internal class TypeConfig
1313
internal Func<object, string, object, object> OnDeserializing;
1414
internal bool IsUserType { get; set; }
1515

16-
internal void AssertValidUsage()
17-
{
18-
if (!IsUserType) return;
19-
20-
LicenseUtils.AssertValidUsage(LicenseFeature.Text, QuotaType.Types, JsConfig.__uniqueTypesCount);
21-
}
22-
2316
internal TypeConfig(Type type)
2417
{
2518
Type = type;
@@ -37,7 +30,7 @@ public static class TypeConfig<T>
3730

3831
static TypeConfig Config
3932
{
40-
get { return config ?? (config = Init()); }
33+
get { return config ?? (config = Create()); }
4134
}
4235

4336
public static PropertyInfo[] Properties
@@ -66,7 +59,15 @@ public static bool IsUserType
6659

6760
static TypeConfig()
6861
{
69-
config = Init();
62+
Init();
63+
}
64+
65+
internal static void Init()
66+
{
67+
if (config == null)
68+
{
69+
Create();
70+
}
7071
}
7172

7273
public static Func<object, string, object, object> OnDeserializing
@@ -75,7 +76,7 @@ public static Func<object, string, object, object> OnDeserializing
7576
set { config.OnDeserializing = value; }
7677
}
7778

78-
static TypeConfig Init()
79+
static TypeConfig Create()
7980
{
8081
config = new TypeConfig(typeof(T));
8182

@@ -107,10 +108,5 @@ internal static TypeConfig GetState()
107108
{
108109
return Config;
109110
}
110-
111-
internal static void AssertValidUsage()
112-
{
113-
Config.AssertValidUsage();
114-
}
115111
}
116112
}

tests/ServiceStack.Text.Tests/LicensingTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class LicensingTests
3535
const string TestIndie2013Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBJbmRpZSxUeXBlOkluZGllLEhhc2g6UGJyTWlRL205YkpCN3NoUGFBelZKVkppZERHRjQwK2JiVWpvOWtrLzgrTUF3UmZZOE0rUkNHMTRYZ055S2ZFT29aNDY4c0FXS2dLRGlVZzEvVmViNjN5M2FpNTh5T2JTZ3RIL2tEdzhDL1VFOEZrazRhMEMrdEtNVU4xQlFxVHBEU21HQUZESUxuOHQ1M2lFWE9tK014MWZCNFEvbitFQUJTMVhvbjBlUE1zPSxFeHBpcnk6MjAxNC0wMS0wMX0=";
3636
readonly LicenseKey TestIndie2013 = new LicenseKey { Ref = "1001", Name = "Test Indie", Type = LicenseType.Indie, Expiry = new DateTime(2014, 01, 01) };
3737
const string TestText2013Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBUZXh0LFR5cGU6VGV4dEluZGllLEhhc2g6V3liaFpUejZiMWgxTGhCcmRRSzlNc09FVUsya3Z6Z2E5VDBaRCtEWnlBd0JxM1dabVFVanNaelgwTWR5OXJMSTlmbzJ0dVVOMk9iZ2srcmswdVZGeit6Q1dreTk3SFE5OHhkOGtDRkx0LzQxR2RiU054SnFIVUlmR1hMdS9CQTVOR0lKanN3SjhXTjdyY0R0VmYyTllKK2dEaFd1RzZ4cnB1ZXhYa01WSXFrPSxFeHBpcnk6MjAxMy0wMS0wMX0=";
38-
readonly LicenseKey TestText2013 = new LicenseKey { Ref = "1001", Name = "Test Text", Type = LicenseType.TextIndie, Expiry = new DateTime(2013, 01, 01) };
3938

4039
const string TestTrial2001Text = "TRIAL302001-e1JlZjpUUklBTDMwMjAwMSxOYW1lOlRyaWFsIFRlc3QsVHlwZTpUcmlhbCxIYXNoOlRGRlNVQTRHYWtiY2tmYlpsOHpsbXhVZUpLZ0pORkxaQ1pJckxwSEJpdTVtSXAzWEx4NGFmd0ZGa2duYzNkZTlUUjczR3hKdVdjMkVnQXF0dzdERVNxVWQwOTBFQ09UOXZ3eGNsMjR4V3BXSkwvM1A5TW1RN283bGp1ckJzV2wvL3AzVFpXajlmeTIzcVA0T3B5YmEzTzhLcmhoTXNnZ3k3c0dGL0JOVmdjbz0sRXhwaXJ5OjIwMDEtMDEtMDF9";
4140
readonly LicenseKey TestTrial2001 = new LicenseKey { Ref = "TRIAL302001", Name = "Trial Test", Type = LicenseType.Trial, Expiry = new DateTime(2001, 01, 01) };
@@ -48,7 +47,6 @@ public IEnumerable AllLicenseUseCases
4847
{
4948
return new[]
5049
{
51-
new LicenseUseCase(LicenseFeature.Text, QuotaType.Types, LicenseUtils.FreeQuotas.TextTypes),
5250
new LicenseUseCase(LicenseFeature.Redis, QuotaType.Types, LicenseUtils.FreeQuotas.RedisTypes),
5351
new LicenseUseCase(LicenseFeature.OrmLite, QuotaType.Tables, LicenseUtils.FreeQuotas.OrmLiteTables),
5452
new LicenseUseCase(LicenseFeature.Aws, QuotaType.Tables, LicenseUtils.FreeQuotas.AwsTables),
@@ -186,7 +184,6 @@ public void Can_deserialize_all_license_key()
186184
AssertKey(TestIndie2000Text, TestIndie2000);
187185
AssertKey(TestBusiness2013Text, TestBusiness2013);
188186
AssertKey(TestIndie2013Text, TestIndie2013);
189-
AssertKey(TestText2013Text, TestText2013);
190187
AssertKey(TestTrial2001Text, TestTrial2001);
191188
AssertKey(TestTrial2016Text, TestTrial2016);
192189
}

0 commit comments

Comments
 (0)