Exemplo n.º 1
0
Arquivo: POEntry.cs Projeto: GioviQ/po
        public POSingularEntry(POKey key)
        {
            if (!key.IsValid)
            {
                throw new ArgumentException(null, nameof(key));
            }

            Key = key;
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            var idKindToken = POKey.GetIdKindToken(IdKind) ?? "?";
            var value       = Value ?? string.Empty;

            var sb = new StringBuilder();

            sb.Append(idKindToken);
            sb.Append(' ');
            sb.Append('"');
            POString.Encode(sb, value, 0, value.Length);
            sb.Append('"');

            return(sb.ToString());
        }
Exemplo n.º 3
0
        public static bool TryParse(string value, out POPreviousValueComment result)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            string idKindToken = null;

            value = value.Trim();
            var index = value.FindIndex(char.IsWhiteSpace);

            if (index >= 0)
            {
                idKindToken = value.Remove(index);
                value       = value.Substring(index + 1).TrimStart();
            }

            int           length;
            POIdKind      idKind;
            StringBuilder sb;

            if (index < 0 ||
                (length = value.Length) < 2 || value[0] != '"' || value[length - 1] != '"' ||
                (idKind = POKey.GetIdKind(idKindToken)) == POIdKind.Unknown ||
                POString.Decode(sb = new StringBuilder(), value, 1, length - 2) >= 0)
            {
                result = null;
                return(false);
            }

            result = new POPreviousValueComment {
                IdKind = idKind, Value = sb.ToString()
            };
            return(true);
        }