Beispiel #1
0
        public IEnumerable <Site> GetSites(Protocol protocol)
        {
            var coll = Call("sites", MainSite.GetUrl());

            if (!coll.Any())
            {
                throw new Exception("No results returned from sites request.", null);
            }

            var sites = new List <Site>();
            var code  = GetCode(coll);

            if (code == ResponseCode.CODE_210)
            {
                foreach (var line in coll.Skip(1))
                {
                    var site = new Site(line);
                    if ((protocol & site.Protocol) != 0)
                    {
                        sites.Append(site);
                    }
                }
                return(sites);
            }
            throw new Exception($"Error Code: {code}");
        }
Beispiel #2
0
 private IList <string> Call(string command)
 {
     if (CurrentSite != null)
     {
         return(Call(command, CurrentSite.GetUrl()));
     }
     else
     {
         return(Call(command, MainSite.GetUrl()));
     }
 }
Beispiel #3
0
        public Result <IEnumerable <Site> > GetSites()
        {
            IList <string> lines = Call(Commands.CMD_SITES, MainSite.GetUrl());

            Result <IEnumerable <Site> > result = new Result <IEnumerable <Site> >(lines[0], new List <Site>());

            if (result.Code == ResponseCodes.CODE_210_OkOrMultipleExactMatches)
            {
                lines.RemoveAt(0);
                foreach (String line in lines)
                {
                    (result.Value as List <Site>).Add(new Site(line));
                }
            }

            return(result);
        }