Пример #1
0
        private async Task <ImmutableDictionary <string, object> > SerializeAssetOrArchiveAsync(string ctx, AssetOrArchive assetOrArchive, bool keepResources)
        {
            if (_excessiveDebugOutput)
            {
                Log.Debug($"Serialize property[{ctx}]: asset/archive={assetOrArchive.GetType().Name}");
            }

            if (assetOrArchive is InvalidAsset)
            {
                throw new InvalidOperationException("Cannot serialize invalid asset");
            }
            if (assetOrArchive is InvalidArchive)
            {
                throw new InvalidOperationException("Cannot serialize invalid archive");
            }

            var propName = assetOrArchive.PropName;
            var value    = await SerializeAsync(ctx + "." + propName, assetOrArchive.Value, keepResources).ConfigureAwait(false);

            var builder = ImmutableDictionary.CreateBuilder <string, object>();

            builder.Add(Constants.SpecialSigKey, assetOrArchive.SigKey);
            builder.Add(assetOrArchive.PropName, value !);
            return(builder.ToImmutable());
        }
Пример #2
0
        private async Task <ImmutableDictionary <string, object> > SerializeAssetOrArchiveAsync(string ctx, AssetOrArchive assetOrArchive)
        {
            if (_excessiveDebugOutput)
            {
                Log.Debug($"Serialize property[{ctx}]: asset/archive={assetOrArchive.GetType().Name}");
            }

            var propName = assetOrArchive.PropName;
            var value    = await SerializeAsync(ctx + "." + propName, assetOrArchive.Value).ConfigureAwait(false);

            var builder = ImmutableDictionary.CreateBuilder <string, object>();

            builder.Add(Constants.SpecialSigKey, assetOrArchive.SigKey);
            builder.Add(assetOrArchive.PropName, value !);
            return(builder.ToImmutable());
        }