コード例 #1
0
 public Task <Errorable <CommitID> > ResolvePartialID(CommitID.Partial id)
 {
     FileInfo[] fis = system.getPathsByPartialID(id);
     if (fis.Length == 1)
     {
         return(Task.FromResult(CommitID.TryParse(id.ToString().Substring(0, 2) + fis[0].Name)));
     }
     if (fis.Length == 0)
     {
         return(Task.FromResult((Errorable <CommitID>) new CommitIDPartialNoResolutionError(id)));
     }
     return(Task.FromResult((Errorable <CommitID>) new CommitIDPartialAmbiguousResolutionError(id, fis.SelectAsArray(f => CommitID.TryParse(id.ToString().Substring(0, 2) + f.Name).Value))));
 }
コード例 #2
0
        public SqlCommand ConstructCommand(SqlConnection cn)
        {
            string cmdText = String.Format(
                @"SELECT [{0}] FROM {1}{2}{3} WHERE LEFT(LEFT(RIGHT(master.dbo.fn_varbintohexstr([{0}]), 42), 40), LEN(@partialid)) = @partialid",
                Tables.TablePKs_Commit.Single(),
                Tables.TableName_Commit,
                "", // no alias
                Tables.TableFromHint_Commit
                );

            SqlCommand cmd = new SqlCommand(cmdText, cn);

            cmd.AddInParameter("@partialid", new SqlString(_id.ToString()));
            return(cmd);
        }
コード例 #3
0
        internal FileInfo[] getPathsByPartialID(CommitID.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) + "*"));
        }