Beispiel #1
0
        public byte[] ProcessData(byte[] data)
        {
            var stringData = stringEncoder.EncodeToString(data);
            var sb         = new StringBuilder();

            var matches    = varRegex.Matches(stringData);
            var startIndex = 0;

            for (var i = 0; i < matches.Count; ++i)
            {
                var match    = matches[i];
                var varKey   = match.Groups[1].Value;
                var varValue = GetVarValue(varKey);
                sb.Append(stringData.Substring(startIndex, match.Index - startIndex));
                sb.Append($"<span class=\"{options.VarValueSpanClass}\">{varValue}</span>");
                startIndex = match.Index + match.Value.Length;
            }
            sb.Append(stringData.Substring(startIndex));
            var replacedString = sb.ToString();

            return(stringEncoder.EncodeFromString(replacedString));
        }
        private async Task LoadAssetData(
            Asset asset,
            CancellationToken cancellationToken = default)
        {
            var dataEncoding = GetAssetDataEncoding(asset);
            var assetBytes   = await dataService.ReadAssetBytesAsync(
                options.AssetsDir,
                asset,
                cancellationToken);

            if (asset.Descriptor.AssetType == AssetType.Text)
            {
                assetBytes = textAssetDataProcessor.ProcessData(assetBytes);
            }

            string data = dataEncoding switch
            {
                AssetDataEncoding.String => stringEncoder.EncodeToString(assetBytes),
                AssetDataEncoding.Base64 => base64Encoder.Encode(assetBytes),
                _ => throw new NotSupportedException($"Data encoding {dataEncoding} is not supported")
            };

            asset.SetData(dataEncoding, data);
        }
Beispiel #3
0
 public string DecodeAsString(string data)
 {
     return(stringEncoder.EncodeToString(Decode(data)));
 }