本文整理汇总了C#中AList.IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# AList.IsEmpty方法的具体用法?C# AList.IsEmpty怎么用?C# AList.IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AList
的用法示例。
在下文中一共展示了AList.IsEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
/// <summary>Construct the merge commit message.</summary>
/// <remarks>Construct the merge commit message.</remarks>
/// <param name="refsToMerge">the refs which will be merged</param>
/// <param name="target">the branch ref which will be merged into</param>
/// <returns>merge commit message</returns>
public virtual string Format(IList<Ref> refsToMerge, Ref target)
{
StringBuilder sb = new StringBuilder();
sb.Append("Merge ");
IList<string> branches = new AList<string>();
IList<string> remoteBranches = new AList<string>();
IList<string> tags = new AList<string>();
IList<string> commits = new AList<string>();
IList<string> others = new AList<string>();
foreach (Ref @ref in refsToMerge)
{
if (@ref.GetName().StartsWith(Constants.R_HEADS))
{
branches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_REMOTES))
{
remoteBranches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_TAGS))
{
tags.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().Equals(@ref.GetObjectId().GetName()))
{
commits.AddItem("'" + @ref.GetName() + "'");
}
else
{
others.AddItem(@ref.GetName());
}
}
}
}
}
IList<string> listings = new AList<string>();
if (!branches.IsEmpty())
{
listings.AddItem(JoinNames(branches, "branch", "branches"));
}
if (!remoteBranches.IsEmpty())
{
listings.AddItem(JoinNames(remoteBranches, "remote branch", "remote branches"));
}
if (!tags.IsEmpty())
{
listings.AddItem(JoinNames(tags, "tag", "tags"));
}
if (!commits.IsEmpty())
{
listings.AddItem(JoinNames(commits, "commit", "commits"));
}
if (!others.IsEmpty())
{
listings.AddItem(StringUtils.Join(others, ", ", " and "));
}
sb.Append(StringUtils.Join(listings, ", "));
string targetName = target.GetLeaf().GetName();
if (!targetName.Equals(Constants.R_HEADS + Constants.MASTER))
{
string targetShortName = Repository.ShortenRefName(target.GetName());
sb.Append(" into " + targetShortName);
}
return sb.ToString();
}
示例2: ScanPacksImpl
private ObjectDirectory.PackList ScanPacksImpl(ObjectDirectory.PackList old)
{
IDictionary<string, PackFile> forReuse = ReuseMap(old);
FileSnapshot snapshot = FileSnapshot.Save(packDirectory);
ICollection<string> names = ListPackDirectory();
IList<PackFile> list = new AList<PackFile>(names.Count >> 2);
bool foundNew = false;
foreach (string indexName in names)
{
// Must match "pack-[0-9a-f]{40}.idx" to be an index.
//
if (indexName.Length != 49 || !indexName.EndsWith(".idx"))
{
continue;
}
string @base = Sharpen.Runtime.Substring(indexName, 0, indexName.Length - 4);
string packName = @base + ".pack";
if (!names.Contains(packName))
{
// Sometimes C Git's HTTP fetch transport leaves a
// .idx file behind and does not download the .pack.
// We have to skip over such useless indexes.
//
continue;
}
PackFile oldPack = Sharpen.Collections.Remove(forReuse, packName);
if (oldPack != null)
{
list.AddItem(oldPack);
continue;
}
FilePath packFile = new FilePath(packDirectory, packName);
FilePath idxFile = new FilePath(packDirectory, indexName);
list.AddItem(new PackFile(idxFile, packFile));
foundNew = true;
}
// If we did not discover any new files, the modification time was not
// changed, and we did not remove any files, then the set of files is
// the same as the set we were given. Instead of building a new object
// return the same collection.
//
if (!foundNew && forReuse.IsEmpty() && snapshot.Equals(old.snapshot))
{
old.snapshot.SetClean(snapshot);
return old;
}
foreach (PackFile p in forReuse.Values)
{
p.Close();
}
if (list.IsEmpty())
{
return new ObjectDirectory.PackList(snapshot, NO_PACKS.packs);
}
PackFile[] r = Sharpen.Collections.ToArray(list, new PackFile[list.Count]);
Arrays.Sort(r, PackFile.SORT);
return new ObjectDirectory.PackList(snapshot, r);
}
示例3: GetAllDocs
//.........这里部分代码省略.........
args.AddItem(Sharpen.Extensions.ToString(options.GetLimit()));
args.AddItem(Sharpen.Extensions.ToString(options.GetSkip()));
Cursor cursor = null;
IDictionary<string, QueryRow> docs = new Dictionary<string, QueryRow>();
try
{
cursor = database.RawQuery(sql.ToString(), Sharpen.Collections.ToArray(args, new
string[args.Count]));
bool keepGoing = cursor.MoveToNext();
while (keepGoing)
{
long docNumericID = cursor.GetLong(0);
string docId = cursor.GetString(1);
string revId = cursor.GetString(2);
long sequenceNumber = cursor.GetLong(3);
bool deleted = includeDeletedDocs && cursor.GetInt(GetDeletedColumnIndex(options)
) > 0;
IDictionary<string, object> docContents = null;
if (options.IsIncludeDocs())
{
byte[] json = cursor.GetBlob(4);
docContents = DocumentPropertiesFromJSON(json, docId, revId, deleted, sequenceNumber
, options.GetContentOptions());
}
// Iterate over following rows with the same doc_id -- these are conflicts.
// Skip them, but collect their revIDs if the 'conflicts' option is set:
IList<string> conflicts = new AList<string>();
while (((keepGoing = cursor.MoveToNext()) == true) && cursor.GetLong(0) == docNumericID
)
{
if (options.GetAllDocsMode() == Query.AllDocsMode.ShowConflicts || options.GetAllDocsMode
() == Query.AllDocsMode.OnlyConflicts)
{
if (conflicts.IsEmpty())
{
conflicts.AddItem(revId);
}
conflicts.AddItem(cursor.GetString(2));
}
}
if (options.GetAllDocsMode() == Query.AllDocsMode.OnlyConflicts && conflicts.IsEmpty
())
{
continue;
}
IDictionary<string, object> value = new Dictionary<string, object>();
value.Put("rev", revId);
value.Put("_conflicts", conflicts);
if (includeDeletedDocs)
{
value.Put("deleted", (deleted ? true : null));
}
QueryRow change = new QueryRow(docId, sequenceNumber, docId, value, docContents);
change.SetDatabase(this);
if (options.GetKeys() != null)
{
docs.Put(docId, change);
}
else
{
rows.AddItem(change);
}
}
if (options.GetKeys() != null)
{
foreach (object docIdObject in options.GetKeys())
示例4: ScanCachedPacks
/// <exception cref="System.IO.IOException"></exception>
private ObjectDirectory.CachedPackList ScanCachedPacks(ObjectDirectory.CachedPackList
old)
{
FileSnapshot s = FileSnapshot.Save(cachedPacksFile);
byte[] buf;
try
{
buf = IOUtil.ReadFully(cachedPacksFile);
}
catch (FileNotFoundException)
{
buf = new byte[0];
}
if (old != null && old.snapshot.Equals(s) && Arrays.Equals(old.raw, buf))
{
old.snapshot.SetClean(s);
return old;
}
AList<LocalCachedPack> list = new AList<LocalCachedPack>(4);
ICollection<ObjectId> tips = new HashSet<ObjectId>();
int ptr = 0;
while (ptr < buf.Length)
{
if (buf[ptr] == '#' || buf[ptr] == '\n')
{
ptr = RawParseUtils.NextLF(buf, ptr);
continue;
}
if (buf[ptr] == '+')
{
tips.AddItem(ObjectId.FromString(buf, ptr + 2));
ptr = RawParseUtils.NextLF(buf, ptr + 2);
continue;
}
IList<string> names = new AList<string>(4);
while (ptr < buf.Length && buf[ptr] == 'P')
{
int end = RawParseUtils.NextLF(buf, ptr);
if (buf[end - 1] == '\n')
{
end--;
}
names.AddItem(RawParseUtils.Decode(buf, ptr + 2, end));
ptr = RawParseUtils.NextLF(buf, end);
}
if (!tips.IsEmpty() && !names.IsEmpty())
{
list.AddItem(new LocalCachedPack(this, tips, names));
tips = new HashSet<ObjectId>();
}
}
list.TrimToSize();
return new ObjectDirectory.CachedPackList(s, Sharpen.Collections.UnmodifiableList
(list), buf);
}
示例5: Push
/// <exception cref="NGit.Errors.TransportException"></exception>
public virtual void Push(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate
> refUpdates)
{
MarkStartedOperation();
packNames = null;
newRefs = new SortedDictionary<string, Ref>(GetRefsMap());
packedRefUpdates = new AList<RemoteRefUpdate>(refUpdates.Count);
// Filter the commands and issue all deletes first. This way we
// can correctly handle a directory being cleared out and a new
// ref using the directory name being created.
//
IList<RemoteRefUpdate> updates = new AList<RemoteRefUpdate>();
foreach (RemoteRefUpdate u in refUpdates.Values)
{
string n = u.GetRemoteName();
if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
{
u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
u.SetMessage(JGitText.Get().funnyRefname);
continue;
}
if (AnyObjectId.Equals(ObjectId.ZeroId, u.GetNewObjectId()))
{
DeleteCommand(u);
}
else
{
updates.AddItem(u);
}
}
// If we have any updates we need to upload the objects first, to
// prevent creating refs pointing at non-existent data. Then we
// can update the refs, and the info-refs file for dumb transports.
//
if (!updates.IsEmpty())
{
Sendpack(updates, monitor);
}
foreach (RemoteRefUpdate u_1 in updates)
{
UpdateCommand(u_1);
}
// Is this a new repository? If so we should create additional
// metadata files so it is properly initialized during the push.
//
if (!updates.IsEmpty() && IsNewRepository())
{
CreateNewRepository(updates);
}
RefWriter refWriter = new _RefWriter_177(this, newRefs.Values);
if (!packedRefUpdates.IsEmpty())
{
try
{
refWriter.WritePackedRefs();
foreach (RemoteRefUpdate u_2 in packedRefUpdates)
{
u_2.SetStatus(RemoteRefUpdate.Status.OK);
}
}
catch (IOException err)
{
foreach (RemoteRefUpdate u_2 in packedRefUpdates)
{
u_2.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
u_2.SetMessage(err.Message);
}
throw new TransportException(uri, JGitText.Get().failedUpdatingRefs, err);
}
}
try
{
refWriter.WriteInfoRefs();
}
catch (IOException err)
{
throw new TransportException(uri, JGitText.Get().failedUpdatingRefs, err);
}
}