本文整理汇总了C#中Guid.ToByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.ToByteArray方法的具体用法?C# Guid.ToByteArray怎么用?C# Guid.ToByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guid
的用法示例。
在下文中一共展示了Guid.ToByteArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlGuid
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public SqlGuid(Guid g)
{
_value = g.ToByteArray();
}
示例2: SetGuid
// valid for UniqueIdentifier
internal void SetGuid(Guid value)
{
Debug.Assert(
SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetGuid));
byte[] bytes = value.ToByteArray();
Debug.Assert(SmiMetaData.DefaultUniqueIdentifier.MaxLength == bytes.Length, "Invalid length for guid bytes: " + bytes.Length);
if (SqlDbType.Variant == _metaData.SqlDbType)
{
_stateObj.Parser.WriteSqlVariantHeader(18, TdsEnums.SQLUNIQUEID, 0, _stateObj);
}
else
{
Debug.Assert(_metaData.MaxLength == bytes.Length, "Unexpected uniqueid metadata length: " + _metaData.MaxLength);
_stateObj.WriteByte((byte)_metaData.MaxLength);
}
_stateObj.WriteByteArray(bytes, bytes.Length, 0);
}
示例3: UniqueId
public UniqueId(Guid guid) : this(guid.ToByteArray())
{
}
示例4: ObjectAce_CreateTestData
private static object[] ObjectAce_CreateTestData(int intFlags, int intQualifier, int accessMask, string stringsid, int intObjectAceFlags, string stringType, string stringInheritedType, bool isCallback, int opaqueLength, int offset)
{
AceFlags aceFlags = (AceFlags)intFlags;
AceQualifier qualifier = (AceQualifier)intQualifier;
SecurityIdentifier sid = new SecurityIdentifier(stringsid);
ObjectAceFlags flags = (ObjectAceFlags)intObjectAceFlags;
Guid type = new Guid(stringType);
Guid inheritedType = new Guid(stringInheritedType);
byte[] opaque = new byte[opaqueLength];
ObjectAce ace = new ObjectAce(aceFlags, qualifier, accessMask, sid, flags, type, inheritedType, isCallback, opaque);
VerifyObjectAce(ace, aceFlags, qualifier, accessMask, sid, flags, type, inheritedType, isCallback, opaque);
byte[] binaryForm = new byte[ace.BinaryLength + offset];
switch (qualifier)
{
case AceQualifier.AccessAllowed:
binaryForm[offset + 0] = isCallback ? (byte)AceType.AccessAllowedCallbackObject : (byte)AceType.AccessAllowedObject;
break;
case AceQualifier.AccessDenied:
binaryForm[offset + 0] = isCallback ? (byte)AceType.AccessDeniedCallbackObject : (byte)AceType.AccessDeniedObject;
break;
case AceQualifier.SystemAudit:
binaryForm[offset + 0] = isCallback ? (byte)AceType.SystemAuditCallbackObject : (byte)AceType.SystemAuditObject;
break;
case AceQualifier.SystemAlarm:
binaryForm[offset + 0] = isCallback ? (byte)AceType.SystemAlarmCallbackObject : (byte)AceType.SystemAlarmObject;
break;
default:
return null;
}
binaryForm[offset + 1] = (byte)aceFlags;
binaryForm[offset + 2] = (byte)(ace.BinaryLength >> 0);
binaryForm[offset + 3] = (byte)(ace.BinaryLength >> 8);
int baseOffset = offset + 4;
int offsetLocal = 0;
binaryForm[baseOffset + 0] = (byte)(accessMask >> 0);
binaryForm[baseOffset + 1] = (byte)(accessMask >> 8);
binaryForm[baseOffset + 2] = (byte)(accessMask >> 16);
binaryForm[baseOffset + 3] = (byte)(accessMask >> 24);
offsetLocal += 4;
binaryForm[baseOffset + offsetLocal + 0] = (byte)(((uint)flags) >> 0);
binaryForm[baseOffset + offsetLocal + 1] = (byte)(((uint)flags) >> 8);
binaryForm[baseOffset + offsetLocal + 2] = (byte)(((uint)flags) >> 16);
binaryForm[baseOffset + offsetLocal + 3] = (byte)(((uint)flags) >> 24);
offsetLocal += 4;
if ((flags & ObjectAceFlags.ObjectAceTypePresent) != 0)
{
type.ToByteArray().CopyTo(binaryForm, baseOffset + offsetLocal);
offsetLocal += 16;
}
if ((flags & ObjectAceFlags.InheritedObjectAceTypePresent) != 0)
{
inheritedType.ToByteArray().CopyTo(binaryForm, baseOffset + offsetLocal);
offsetLocal += 16;
}
sid.GetBinaryForm(binaryForm, baseOffset + offsetLocal);
offsetLocal += sid.BinaryLength;
opaque.CopyTo(binaryForm, baseOffset + offsetLocal);
return new object[] { ace, binaryForm, offset };
}
示例5: WriteGuid
private void WriteGuid (Guid val, byte[] buffer,
int offset)
{
byte[] guidData = val.ToByteArray();
Array.Copy(guidData, 0, buffer, offset, 16);
}
示例6: WritePrimitive
public void WritePrimitive()
{
var writer = new BlobBuilder(17);
writer.WriteUInt32(0x11223344);
writer.WriteUInt16(0x5566);
writer.WriteByte(0x77);
writer.WriteUInt64(0x8899aabbccddeeff);
writer.WriteInt32(-1);
writer.WriteInt16(-2);
writer.WriteSByte(-3);
writer.WriteBoolean(true);
writer.WriteBoolean(false);
writer.WriteInt64(unchecked((long)0xfedcba0987654321));
writer.WriteDateTime(new DateTime(0x1112223334445556));
writer.WriteDecimal(102030405060.70m);
writer.WriteDouble(double.NaN);
writer.WriteSingle(float.NegativeInfinity);
var guid = new Guid("01020304-0506-0708-090A-0B0C0D0E0F10");
writer.WriteBytes(guid.ToByteArray());
writer.WriteGuid(guid);
AssertEx.Equal(new byte[]
{
0x44, 0x33, 0x22, 0x11,
0x66, 0x55,
0x77,
0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88,
0xff, 0xff, 0xff, 0xff,
0xfe, 0xff,
0xfd,
0x01,
0x00,
0x21, 0x43, 0x65, 0x87, 0x09, 0xBA, 0xDC, 0xFE,
0x56, 0x55, 0x44, 0x34, 0x33, 0x22, 0x12, 0x11,
0x02, 0xD6, 0xE0, 0x9A, 0x94, 0x47, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
0x00, 0x00, 0x80, 0xFF,
0x04, 0x03, 0x02, 0x01, 0x06, 0x05, 0x08, 0x07, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
0x04, 0x03, 0x02, 0x01, 0x06, 0x05, 0x08, 0x07, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10
}, writer.ToArray());
}
示例7: WriteGuidText
public override void WriteGuidText(Guid guid)
{
int offset;
byte[] buffer = GetTextNodeBuffer(17, out offset);
buffer[offset] = (byte)XmlBinaryNodeType.GuidText;
Buffer.BlockCopy(guid.ToByteArray(), 0, buffer, offset + 1, 16);
Advance(17);
}