本文整理汇总了C#中GitSharp.Core.ObjectId类的典型用法代码示例。如果您正苦于以下问题:C# ObjectId类的具体用法?C# ObjectId怎么用?C# ObjectId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectId类属于GitSharp.Core命名空间,在下文中一共展示了ObjectId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlobBasedConfig
/// <summary> * The constructor from object identifier
/// </summary>
/// <param name="base">the base configuration file </param>
/// <param name="r">the repository</param>
/// <param name="objectid">the object identifier</param>
/// <exception cref="IOException">
/// the blob cannot be read from the repository. </exception>
/// <exception cref="ConfigInvalidException">
/// the blob is not a valid configuration format.
/// </exception>
public BlobBasedConfig(Config @base, Repository r, ObjectId objectid)
: base(@base)
{
ObjectLoader loader = r.OpenBlob(objectid);
if (loader == null)
{
throw new IOException("Blob not found: " + objectid);
}
fromText(RawParseUtils.decode(loader.Bytes));
}
示例2: DecodeTypeString
public static ObjectType DecodeTypeString(ObjectId id, byte[] typeString, byte endMark, ref int offset)
{
try
{
switch (typeString[offset])
{
case (byte)'b':
if (typeString[offset + 1] != (byte)'l' ||
typeString[offset + 2] != (byte)'o' ||
typeString[offset + 3] != (byte)'b' ||
typeString[offset + 4] != endMark) break;
offset += 5;
return ObjectType.Blob;
case (byte)'c':
if (typeString[offset + 1] != (byte)'o' || typeString[offset + 2] != (byte)'m' ||
typeString[offset + 3] != (byte)'m' || typeString[offset + 4] != (byte)'i' ||
typeString[offset + 5] != (byte)'t' || typeString[offset + 6] != endMark) break;
offset += 7;
return ObjectType.Commit;
case (byte)'t':
switch (typeString[offset + 1])
{
case (byte)'a':
if (typeString[offset + 2] != (byte)'g' || typeString[offset + 2] != endMark)
{
throw new CorruptObjectException(id, "invalid type");
}
offset += 4;
return ObjectType.Tag;
case (byte)'r':
if (typeString[offset + 2] != (byte)'e' || typeString[offset + 3] != (byte)'e' || typeString[offset + 4] != endMark)
{
throw new CorruptObjectException(id, "invalid type");
}
offset += 5;
return ObjectType.Tree;
}
break;
}
}
catch (IndexOutOfRangeException)
{
}
throw new CorruptObjectException(id, "invalid type");
}
示例3: Tag
/**
* Construct a Tag representing an existing with a known name referencing an known object.
* This could be either a simple or annotated tag.
*
* @param db {@link Repository}
* @param id target id.
* @param refName tag name or null
* @param raw data of an annotated tag.
*/
public Tag(Repository db, ObjectId id, string refName, byte[] raw)
{
Repository = db;
if (raw != null)
{
TagId = id;
Id = ObjectId.FromString(raw, 7);
}
else
Id = id;
if (refName != null && refName.StartsWith("refs/tags/"))
refName = refName.Substring(10);
TagName = refName;
this.raw = raw;
}
示例4: BlobBasedConfig
/// <summary> * The constructor from object identifier
/// </summary>
/// <param name="base">the base configuration file </param>
/// <param name="repo">the repository</param>
/// <param name="objectid">the object identifier</param>
/// <exception cref="IOException">
/// the blob cannot be read from the repository. </exception>
/// <exception cref="ConfigInvalidException">
/// the blob is not a valid configuration format.
/// </exception>
public BlobBasedConfig(Config @base, Repository repo, ObjectId objectid)
: base(@base)
{
if (repo == null)
{
throw new System.ArgumentNullException("repo");
}
ObjectLoader loader = repo.OpenBlob(objectid);
if (loader == null)
{
throw new IOException("Blob not found: " + objectid);
}
fromText(RawParseUtils.decode(loader.Bytes));
}
示例5: Entry
public Entry(byte[] raw, int pos)
{
oldId = ObjectId.FromString(raw, pos);
pos += Constants.OBJECT_ID_STRING_LENGTH;
if (raw[pos++] != ' ')
throw new ArgumentException("Raw log message does not parse as log entry");
newId = ObjectId.FromString(raw, pos);
pos += Constants.OBJECT_ID_STRING_LENGTH;
if (raw[pos++] != ' ')
throw new ArgumentException("Raw log message does not parse as log entry");
who = RawParseUtils.parsePersonIdentOnly(raw, pos);
int p0 = RawParseUtils.next(raw, pos, (byte)'\t');
if (p0 == -1)
throw new ArgumentException("Raw log message does not parse as log entry");
int p1 = RawParseUtils.nextLF(raw, p0);
if (p1 == -1)
throw new ArgumentException("Raw log message does not parse as log entry");
comment = RawParseUtils.decode(raw, p0, p1 - 1);
}
示例6: MakeTree
private Tree MakeTree(ObjectId id, byte[] raw)
{
return new Tree(this, id, raw);
}
示例7: MapCommit
/// <summary>
/// Access a Commit by SHA'1 id.
/// </summary>
/// <param name="id"></param>
/// <returns>Commit or null</returns>
public Commit MapCommit(ObjectId id)
{
ObjectLoader or = OpenObject(id);
if (or == null)
{
return null;
}
byte[] raw = or.Bytes;
if (Constants.OBJ_COMMIT == or.Type)
{
return new Commit(this, id, raw);
}
throw new IncorrectObjectTypeException(id, ObjectType.Commit);
}
示例8: MakeCommit
private object MakeCommit(ObjectId id, byte[] raw)
{
return new Commit(this, id, raw);
}
示例9: MakeTag
private Tag MakeTag(ObjectId id, string refName, byte[] raw)
{
return new Tag(this, id, refName, raw);
}
示例10: Write
public void Write(ObjectId id)
{
RequireLock();
try
{
var b = new BinaryWriter(_os);
id.CopyTo(b);
b.Write('\n');
b.Flush();
_fLck.Release();
b.Close();
_os = null;
}
catch (Exception)
{
Unlock();
throw;
}
}
示例11: Unpeeled
/// <summary>
/// Create a new ref pairing.
/// </summary>
/// <param name="st">method used to store this ref.</param>
/// <param name="name">name of this ref.</param>
/// <param name="id">
/// current value of the ref. May be null to indicate a ref that
/// does not exist yet.
/// </param>
public Unpeeled(Storage st, string name, ObjectId id)
: base(st, name, id)
{
}
示例12: OpenCommit
public Commit OpenCommit(ObjectId id)
{
return MapCommit(id);
}
示例13: Tree
/// <summary>
/// Construct a Tree object with known content and hash value
/// </summary>
/// <param name="repo"></param>
/// <param name="id"></param>
/// <param name="raw"></param>
/// <exception cref="IOException"></exception>
public Tree(Repository repo, ObjectId id, byte[] raw)
: base(null, id, null)
{
_db = repo;
ReadTree(raw);
}
示例14: MapObject
/// <summary>
/// Access any type of Git object by id and
/// </summary>
/// <param name="id">SHA-1 of object to read</param>
/// <param name="refName">optional, only relevant for simple tags</param>
/// <returns>The Git object if found or null</returns>
public object MapObject(ObjectId id, string refName)
{
ObjectLoader or = OpenObject(id);
if (or == null)
{
return null;
}
byte[] raw = or.Bytes;
switch ((ObjectType)(or.Type))
{
case ObjectType.Tree:
return MakeTree(id, raw);
case ObjectType.Commit:
return MakeCommit(id, raw);
case ObjectType.Tag:
return MakeTag(id, refName, raw);
case ObjectType.Blob:
return raw;
default:
throw new IncorrectObjectTypeException(id,
"COMMIT nor TREE nor BLOB nor TAG");
}
}
示例15: MapTree
/// <summary>
/// Access a Tree by SHA'1 id.
/// </summary>
/// <param name="id"></param>
/// <returns>Tree or null</returns>
public Tree MapTree(ObjectId id)
{
ObjectLoader or = OpenObject(id);
if (or == null)
{
return null;
}
byte[] raw = or.Bytes;
switch (((ObjectType)or.Type))
{
case ObjectType.Tree:
return new Tree(this, id, raw);
case ObjectType.Commit:
return MapTree(ObjectId.FromString(raw, 5));
}
throw new IncorrectObjectTypeException(id, ObjectType.Tree);
}