-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cached query working for UserChartPart
- Loading branch information
1 parent
1cf9c7d
commit b77dcbf
Showing
39 changed files
with
1,011 additions
and
523 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 76 additions & 73 deletions
149
Signum.Engine/Json/JsonExtensions.cs → Signum.Engine/Json/EntityJsonContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,76 @@ | ||
using System.Collections.Immutable; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Signum.Engine.Json; | ||
|
||
public static class EntityJsonContext | ||
{ | ||
public static JsonSerializerOptions FullJsonSerializerOptions; | ||
static EntityJsonContext() | ||
{ | ||
var ejcf = new EntityJsonConverterFactory(); | ||
|
||
FullJsonSerializerOptions = new JsonSerializerOptions | ||
{ | ||
IncludeFields = true, | ||
Converters = | ||
{ | ||
ejcf, | ||
new MListJsonConverterFactory(ejcf.AssertCanWrite), | ||
new LiteJsonConverterFactory(), | ||
new JsonStringEnumConverter(), | ||
new TimeSpanConverter(), | ||
new DateOnlyConverter() | ||
} | ||
}; | ||
} | ||
|
||
static readonly ThreadVariable<ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)>?> currentPropertyRoute = Statics.ThreadVariable<ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey ? rowId) >?>("jsonPropertyRoute"); | ||
|
||
public static (PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)? CurrentPropertyRouteAndEntity | ||
{ | ||
get { return currentPropertyRoute.Value?.Peek(); } | ||
} | ||
|
||
public static IRootEntity? FindCurrentRootEntity() | ||
{ | ||
return currentPropertyRoute.Value?.FirstOrDefault(a => a.mod is IRootEntity).mod as IRootEntity; | ||
} | ||
|
||
public static PrimaryKey? FindCurrentRowId() | ||
{ | ||
return currentPropertyRoute.Value?.Where(a => a.rowId != null).FirstOrDefault().rowId; | ||
} | ||
|
||
public static IDisposable SetCurrentPropertyRouteAndEntity((PropertyRoute, ModifiableEntity?, PrimaryKey? rowId) pair) | ||
{ | ||
var old = currentPropertyRoute.Value; | ||
|
||
currentPropertyRoute.Value = (old ?? ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)>.Empty).Push(pair); | ||
|
||
return new Disposable(() => { currentPropertyRoute.Value = old; }); | ||
} | ||
|
||
static readonly ThreadVariable<bool> allowDirectMListChangesVariable = Statics.ThreadVariable<bool>("allowDirectMListChanges"); | ||
|
||
public static bool AllowDirectMListChanges | ||
{ | ||
get { return allowDirectMListChangesVariable.Value; } | ||
} | ||
|
||
public static IDisposable SetAllowDirectMListChanges(bool allowMListDirectChanges) | ||
{ | ||
var old = allowDirectMListChangesVariable.Value; | ||
|
||
allowDirectMListChangesVariable.Value = allowMListDirectChanges; | ||
|
||
return new Disposable(() => { allowDirectMListChangesVariable.Value = old; }); | ||
} | ||
|
||
|
||
|
||
} | ||
using System.Collections.Immutable; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Signum.Engine.Json; | ||
|
||
public static class EntityJsonContext | ||
{ | ||
public static JsonSerializerOptions FullJsonSerializerOptions; | ||
static EntityJsonContext() | ||
{ | ||
var ejcf = new EntityJsonConverterFactory(); | ||
|
||
FullJsonSerializerOptions = new JsonSerializerOptions | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
IncludeFields = true, | ||
Converters = | ||
{ | ||
ejcf, | ||
new LiteJsonConverterFactory(), | ||
new MListJsonConverterFactory(ejcf.AssertCanWrite), | ||
new JsonStringEnumConverter(), | ||
new ResultTableConverter(), | ||
new TimeSpanConverter(), | ||
new DateOnlyConverter(), | ||
new TimeOnlyConverter() | ||
} | ||
}; | ||
} | ||
|
||
static readonly ThreadVariable<ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)>?> currentPropertyRoute = Statics.ThreadVariable<ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey ? rowId) >?>("jsonPropertyRoute"); | ||
|
||
public static (PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)? CurrentPropertyRouteAndEntity | ||
{ | ||
get { return currentPropertyRoute.Value?.Peek(); } | ||
} | ||
|
||
public static IRootEntity? FindCurrentRootEntity() | ||
{ | ||
return currentPropertyRoute.Value?.FirstOrDefault(a => a.mod is IRootEntity).mod as IRootEntity; | ||
} | ||
|
||
public static PrimaryKey? FindCurrentRowId() | ||
{ | ||
return currentPropertyRoute.Value?.Where(a => a.rowId != null).FirstOrDefault().rowId; | ||
} | ||
|
||
public static IDisposable SetCurrentPropertyRouteAndEntity((PropertyRoute, ModifiableEntity?, PrimaryKey? rowId) pair) | ||
{ | ||
var old = currentPropertyRoute.Value; | ||
|
||
currentPropertyRoute.Value = (old ?? ImmutableStack<(PropertyRoute pr, ModifiableEntity? mod, PrimaryKey? rowId)>.Empty).Push(pair); | ||
|
||
return new Disposable(() => { currentPropertyRoute.Value = old; }); | ||
} | ||
|
||
static readonly ThreadVariable<bool> allowDirectMListChangesVariable = Statics.ThreadVariable<bool>("allowDirectMListChanges"); | ||
|
||
public static bool AllowDirectMListChanges | ||
{ | ||
get { return allowDirectMListChangesVariable.Value; } | ||
} | ||
|
||
public static IDisposable SetAllowDirectMListChanges(bool allowMListDirectChanges) | ||
{ | ||
var old = allowDirectMListChangesVariable.Value; | ||
|
||
allowDirectMListChangesVariable.Value = allowMListDirectChanges; | ||
|
||
return new Disposable(() => { allowDirectMListChangesVariable.Value = old; }); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.