public Task <Errorable <TreeID> > ResolvePartialID(TreeID.Partial id)
 {
     FileInfo[] fis = system.getPathsByPartialID(id);
     if (fis.Length == 1)
     {
         return(Task.FromResult(TreeID.TryParse(id.ToString().Substring(0, 2) + fis[0].Name)));
     }
     if (fis.Length == 0)
     {
         return(Task.FromResult((Errorable <TreeID>) new TreeIDPartialNoResolutionError(id)));
     }
     return(Task.FromResult((Errorable <TreeID>) new TreeIDPartialAmbiguousResolutionError(id, fis.SelectAsArray(f => TreeID.TryParse(id.ToString().Substring(0, 2) + f.Name).Value))));
 }
        public async Task <Errorable <TreeID> > ResolvePartialID(TreeID.Partial id)
        {
            var resolvedIDs = await db.ExecuteListQueryAsync(new ResolvePartialTreeID(id));

            if (resolvedIDs.Length == 1)
            {
                return(resolvedIDs[0]);
            }
            if (resolvedIDs.Length == 0)
            {
                return(new TreeIDPartialNoResolutionError(id));
            }
            return(new TreeIDPartialAmbiguousResolutionError(id, resolvedIDs));
        }
Ejemplo n.º 3
0
        internal FileInfo[] getPathsByPartialID(TreeID.Partial partial)
        {
            DirectoryInfo objDir = getObjectsDirectory();
            string        idStr  = partial.ToString();

            string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2));
            var    di   = new DirectoryInfo(path);

            if (!di.Exists)
            {
                return(new FileInfo[0]);
            }

            return(di.GetFiles(idStr.Substring(2) + "*"));
        }
Ejemplo n.º 4
0
 public TreeIDPartialAmbiguousResolutionError(TreeID.Partial id, params TreeID[] ids) : base("Partial TreeID {0} resolves to multiple TreeID", id, ids)
 {
 }
Ejemplo n.º 5
0
 public TreeIDPartialNoResolutionError(TreeID.Partial id) : base("Partial TreeID {0} does not resolve to a TreeID", id)
 {
 }
 public ResolvePartialTreeID(TreeID.Partial id)
 {
     this._id = id;
 }