static IRemoteValueFormat ParseFormat(string formatSpecifier, uint?evaluatedSize = null)
        {
            // Empty specifier is not accepted.
            if (string.IsNullOrEmpty(formatSpecifier))
            {
                return(null);
            }

            // Split the expression into a size specifier, a raw formatter specifier and a value
            // format.
            if (!FormatSpecifierUtil.TrySplitSpecifier(formatSpecifier, out string size,
                                                       out string raw, out string baseSpecifier) ||
                !_formatLookup.ContainsKey(baseSpecifier))
            {
                return(null);
            }
            ISingleValueFormat valueFormat = _formatLookup[baseSpecifier];

            if (string.IsNullOrEmpty(size))
            {
                return(new RemoteValueFormat(valueFormat));
            }
            uint?parsedSize = TryParseSizeFormat(size, evaluatedSize);

            if (parsedSize != null)
            {
                return(new RemoteValueFormat(valueFormat, parsedSize));
            }
            return(null);
        }
示例#2
0
        public void TestGetStandaloneRawFormatSpecifiers(
            [Values(FormatSpecifierUtil.RawFormatSpecifier,
                    FormatSpecifierUtil.InheritableRawFormatSpecifier)] string specifier)
        {
            bool validFormat          = RemoteValueFormatProvider.IsValidFormat(specifier);
            ISingleValueFormat format = RemoteValueFormatProvider.Get(specifier);

            Assert.That(validFormat, Is.True);
            Assert.That(format is RemoteValueFormat);
        }
 public RemoteValueFormat(ISingleValueFormat valueFormat, uint?sizeSpecifier = null)
 {
     _format        = valueFormat;
     _sizeSpecifier = sizeSpecifier;
 }