Ejemplo n.º 1
0
        public static bool IsValidLink(IProtoService protoService, string url)
        {
            if (protoService == null)
            {
                return(Uri.IsWellFormedUriString(url, UriKind.Absolute));
            }

            var response = protoService.Execute(new GetTextEntities(url));

            if (response is TextEntities entities)
            {
                return(entities.Entities.Count == 1 && entities.Entities[0].Offset == 0 && entities.Entities[0].Length == url.Length && entities.Entities[0].Type is TextEntityTypeUrl);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public string GetString(string key)
        {
            var values = GetLanguagePack(key);

            if (values.TryGetValue(key, out string value))
            {
                return(value);
            }

            var path   = Path.Combine(ApplicationData.Current.LocalFolder.Path, $"{_protoService.SessionId}");
            var result = _protoService.Execute(new GetLanguagePackString(path, "android", _languageCode, key));

            if (result is LanguagePackStringValueOrdinary ordinary)
            {
                values[key] = ordinary.Value;
                return(ordinary.Value);
            }

            return(null);
        }