src/OrchardCore/OrchardCore.ContentManagement/FileContentDefinitionStore.cs
/// <summary>
/// Gets a single document (or create a new one) for caching and that should not be updated.
/// </summary>
Gets a single document (or create a new one) for caching and that should not be updated.
Gets a single document ( or create a new one ) for caching and that should not be updated .
public Task<(bool, ContentDefinitionRecord)> GetContentDefinitionAsync()
        {
            var scopedCache = ShellScope.Services.GetRequiredService<FileContentDefinitionScopedCache>();
            if (scopedCache.ContentDefinitionRecord != null)
            {
                return Task.FromResult((false, scopedCache.ContentDefinitionRecord));
            }
            ContentDefinitionRecord result;
            if (!File.Exists(Filename))
            {
                result = new ContentDefinitionRecord();
            }
            else
            {
                lock (this)
                {
                    using (var file = File.OpenText(Filename))
                    {
                        var serializer = new JsonSerializer();
                        result = (ContentDefinitionRecord)serializer.Deserialize(file, typeof(ContentDefinitionRecord));
                    }
                }
            }
            return Task.FromResult((true, result));
        }
public Task < ( bool , ContentDefinitionRecord ) > GetContentDefinitionAsync ( ) { var scopedCache = ShellScope . Services . GetRequiredService < FileContentDefinitionScopedCache > ( ) ; if ( scopedCache . ContentDefinitionRecord != null ) { return Task . FromResult ( ( false , scopedCache . ContentDefinitionRecord ) ) ; } ContentDefinitionRecord result ; if ( ! File . Exists ( Filename ) ) { result = new ContentDefinitionRecord ( ) ; } else { lock ( this ) { using ( var file = File . OpenText ( Filename ) ) { var serializer = new JsonSerializer ( ) ; result = ( ContentDefinitionRecord ) serializer . Deserialize ( file , typeof ( ContentDefinitionRecord ) ) ; } } } return Task . FromResult ( ( true , result ) ) ; }
Gets a single document (or create a new one) for caching and that should not be updated.
Gets a single document ( or create a new one ) for caching and that should not be updated .
// Return the already loaded document but indicating that it should not be cached.