当前位置: 首页>>代码示例>>C#>>正文


C# Guid.ToByteArray方法代码示例

本文整理汇总了C#中System.Guid.ToByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.ToByteArray方法的具体用法?C# Guid.ToByteArray怎么用?C# Guid.ToByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Guid的用法示例。


在下文中一共展示了Guid.ToByteArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Link

 public Link( uint folderID, Guid objectGUID, uint objectFolderTypeID, DateTime dateCreated )
 {
     FolderID           = folderID;
     ObjectGUID         = new UUID( objectGUID.ToByteArray() ).ToString();
     ObjectFolderTypeID = objectFolderTypeID;
     DateCreated        = dateCreated;
 }
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.MCM,代码行数:7,代码来源:Link.cs

示例2: DeleteMessageToSend

        public void DeleteMessageToSend(Guid transactionId)
        {
            Api.JetSetCurrentIndex(session, outgoing, "by_tx_id");

            Api.MakeKey(session, outgoing, transactionId.ToByteArray(), MakeKeyGrbit.NewKey);
            if (Api.TrySeek(session, outgoing, SeekGrbit.SeekEQ) == false)
                return;
            Api.MakeKey(session, outgoing, transactionId.ToByteArray(), MakeKeyGrbit.NewKey);
            try
            {
                Api.JetSetIndexRange(session, outgoing,
                                     SetIndexRangeGrbit.RangeInclusive | SetIndexRangeGrbit.RangeUpperLimit);
            }
            catch (EsentErrorException e)
            {
                if (e.Error!=JET_err.NoCurrentRecord)
                    throw;
                return;
            }
            do
            {
                logger.DebugFormat("Deleting output message {0}",
                    Api.RetrieveColumnAsInt32(session, outgoing, outgoingColumns["msg_id"]).Value);
                Api.JetDelete(session, outgoing);
            } while (Api.TryMoveNext(session, outgoing));
        }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:26,代码来源:GlobalActions.cs

示例3: GetSettings

        public LocalizationSettingsAggregateData GetSettings(Guid entityId, string language)
        {
            return ExecuteTransaction<LocalizationSettingsAggregateData>((connection, transaction) =>
            {
                var settingsAggregateData = connection.Query<LocalizationSettingsAggregateData>(
                    @"SELECT ID, ENTITY_ID, PARENT_ID, LANGUAGE, FORMATTING
                    FROM LOCALIZATION_SETTINGS
                    WHERE ENTITY_ID = :entity_id",
                    new { entity_id = entityId.ToByteArray() },
                    transaction).FirstOrDefault();

                settingsAggregateData.Localizations = connection.Query<LocalizationData>(
                    @"SELECT ID, LOCALIZATION_SETTINGS_ID, KEY, VALUE
                    FROM LOCALE_OVERRIDES
                    WHERE LOCALIZATION_SETTINGS_ID = :id",
                    new { id = settingsAggregateData.Id },
                    transaction).ToList();

                settingsAggregateData.Formattings = connection.Query<FormattingData>(
                    @"SELECT ID, LOCALIZATION_SETTINGS_ID, KEY, VALUE
                    FROM FORMATTING_OVERRIDES
                    WHERE LOCALIZATION_SETTINGS_ID = :id",
                    new { id = settingsAggregateData.Id },
                    transaction).ToList();

                return settingsAggregateData;
            });
        }
开发者ID:vitalishcharbin,项目名称:Orms.Example,代码行数:28,代码来源:LocalizationSettingsRepository.cs

示例4: ConvertGuidToGUID

        //
        // Converts Guid class to GUID structure that we can pass into native
        //
        internal static GUID ConvertGuidToGUID(Guid guid)
        {
            GUID newGuid = new GUID();

            if (guid != null){
                byte[] guidBytes = guid.ToByteArray();
                string guidString = guid.ToString();

                int startVal = 0;
                int endVal = guidString.IndexOf('-');
                newGuid.data1 = (uint)(Convert.ToUInt32(guidString.Substring(startVal, endVal - startVal), 16));
                startVal = endVal + 1;
                endVal = guidString.IndexOf('-', endVal + 1);
                newGuid.data2 = (ushort)(Convert.ToUInt16(guidString.Substring(startVal, endVal - startVal), 16));
                startVal = endVal + 1;
                endVal = guidString.IndexOf('-', endVal + 1);
                newGuid.data3 = (ushort)(Convert.ToUInt16(guidString.Substring(startVal, endVal - startVal), 16));
                newGuid.data4 = guidBytes[8];
                newGuid.data5 = guidBytes[9];
                newGuid.data6 = guidBytes[10];
                newGuid.data7 = guidBytes[11];
                newGuid.data8 = guidBytes[12];
                newGuid.data9 = guidBytes[13];
                newGuid.data10 = guidBytes[14];
                newGuid.data11 = guidBytes[15];
            }
            return newGuid;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:CollaborationHelperFunctions.cs

示例5: ToString

 public override string ToString(Guid g, bool upcase, bool newline)
 {
     if (IsLoopBack(g)) return "::1" + (newline?"\r\n":"");
     byte[] bytes = g.ToByteArray();
     if (IsIPv4(g)) return string.Format("{0}.{1}.{2}.{3}", bytes[12], bytes[13], bytes[14], bytes[15]) + (newline?"\r\n":"");
     return (new System.Net.IPAddress(bytes)).ToString() + (newline?"\r\n":"");
 }
开发者ID:michaelmcdaniel,项目名称:GuidgenConsole,代码行数:7,代码来源:IPAddressGuidFormat.cs

示例6: InitCommandRequest

 public static byte[] InitCommandRequest(Guid guid, string name)
 {
     var data = new byte[16 + Encoding.Unicode.GetByteCount(name) + 1];
     Array.Copy(guid.ToByteArray(), data, 16);
     Assign (name, data, 16);
     return Encode(PACKET_TYPE_INIT_COMMAND_REQUEST, data);
 }
开发者ID:nobnak,项目名称:TestPTP,代码行数:7,代码来源:PTP.cs

示例7: setFieldsFromGuid

 private void setFieldsFromGuid(Guid guid, TeamPicture teamPicture)
 {
     teamPicture.Message = guid.ToString();
     teamPicture.Picture = guid.ToByteArray();
     teamPicture.PictureHeight = HEIGHT;
     teamPicture.PictureWidth = WIDTH;
 }
开发者ID:ArildF,项目名称:Smeedee,代码行数:7,代码来源:TeamPictureRepositorySpecs.cs

示例8: HashPassword

 public static string HashPassword(string password, Guid salt)
 {
     //this is a many iterations of hashing with sha256... try and steal our passwords now!
     int iterations = (int)password[0];
     SHA256 passwordHash = SHA256.Create();
     byte[] passwordBytes = new byte[(password.Length * sizeof(char))];
     System.Buffer.BlockCopy(password.ToCharArray(), 0, passwordBytes, 0, passwordBytes.Length);
     passwordBytes = passwordBytes.Concat(salt.ToByteArray()).ToArray();
     passwordHash.ComputeHash(passwordBytes);
     for (int i = 0; i < iterations; i++)
     {
         var computedBytes = passwordHash.Hash.Concat(salt.ToByteArray()).ToArray();
         passwordHash.ComputeHash(computedBytes);
     }
     return Convert.ToBase64String(passwordHash.Hash);
 }
开发者ID:ethantang95,项目名称:HackRPI,代码行数:16,代码来源:PasswordSHA1Hash.cs

示例9: ConsumeMessage

        public void ConsumeMessage(Guid msgId, Func<DateTime, string, bool> shouldConsumeMessage)
        {
            var key = new JObject { { "MsgId", msgId.ToByteArray() } };
            var readResult = messages.Read(key);
            if (readResult == null)
            {
                var pendingResult = pendingMessages.Read(key);
                if (pendingResult != null)
                {
                    pendingMessages.Remove(key);
                    var pendingQueue = pendingResult.Key.Value<string>("Queue");
                    var pendingExpiry = pendingResult.Key.Value<DateTime>("Expiry");
                    if (shouldConsumeMessage(pendingExpiry, pendingQueue) == false)
                    {
                        ((JObject)pendingResult.Key).Remove("Hide");
                        messages.UpdateKey(pendingResult.Key);
                    }
                    else
                    {
                        queuesStorageActions.DecrementMessageCount(pendingQueue);
                    }
                }
                return;
            }

            var queue = readResult.Key.Value<string>("Queue");
            var epxiry = readResult.Key.Value<DateTime>("Expiry");
            if (shouldConsumeMessage(epxiry, queue) == false)
                return;
            messages.Remove(key);
            queuesStorageActions.DecrementMessageCount(queue);
        }
开发者ID:nieve,项目名称:ravenmq,代码行数:32,代码来源:MessagesStorageActions.cs

示例10: GetLiteral

 public override Linq.Translation.SqlGen.SqlStatement GetLiteral(Guid literal)
 {
     var bytes = literal.ToByteArray();
       var hex = HexUtil.ByteArrayToHex(bytes);
       var result = "X'" + hex + "'";
       return result;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:7,代码来源:SQLiteLinqSqlProvider.cs

示例11: AddMarkerReq

        public void AddMarkerReq(Card card, Guid id, string name, ushort count, ushort origCount, bool isScriptChange)
        {
            //Log.Info("[ProtOut] AddMarkerReq");

            if(Program.Client == null)return;
            MemoryStream stream = new MemoryStream(512);
            stream.Seek(4, SeekOrigin.Begin);
            BinaryWriter writer = new BinaryWriter(stream);

              if (Program.Client.Muted != 0)
              writer.Write(Program.Client.Muted);
              else
              writer.Write(0);
            writer.Write((byte)59);
            writer.Write(card.Id);
            writer.Write(id.ToByteArray());
            writer.Write(name);
            writer.Write(count);
            writer.Write(origCount);
            writer.Write(isScriptChange);

            writer.Flush(); writer.Seek(0, SeekOrigin.Begin);
            writer.Write((int)stream.Length);
            writer.Close();
            Send(stream.ToArray());
        }
开发者ID:rerbes,项目名称:OCTGN,代码行数:26,代码来源:BinaryStubs.cs

示例12: GenerateGuidFromName

        // Generate a Version 5 (SHA1 Name Based) Guid from a name.
        public static Guid GenerateGuidFromName(string name)
        {
            // Any fixed GUID will do for a namespace.
            Guid namespaceId = new Guid("28F1468D-672B-489A-8E0C-7C5B3030630C");

            using (SHA1 hasher = SHA1.Create())
            {
                var nameBytes = System.Text.Encoding.UTF8.GetBytes(name ?? string.Empty);
                var namespaceBytes = namespaceId.ToByteArray();

                SwapGuidByteOrder(namespaceBytes);

                var streamToHash = new byte[namespaceBytes.Length + nameBytes.Length];

                Array.Copy(namespaceBytes, streamToHash, namespaceBytes.Length);
                Array.Copy(nameBytes, 0, streamToHash, namespaceBytes.Length, nameBytes.Length);

                var hashResult = hasher.ComputeHash(streamToHash);

                var res = new byte[16];

                Array.Copy(hashResult, res, res.Length);

                unchecked { res[6] = (byte)(0x50 | (res[6] & 0x0F)); }
                unchecked { res[8] = (byte)(0x40 | (res[8] & 0x3F)); }

                SwapGuidByteOrder(res);

                return new Guid(res);
            }
        }
开发者ID:krytarowski,项目名称:cli,代码行数:32,代码来源:Utils.cs

示例13: GetPath

 private string GetPath(Guid identity)
 {
     var bytes = identity.ToByteArray();
     var a = bytes[3].ToHex();
     var b = bytes[2].ToHex();
     return Path.Combine(RootPath, a, b);
 }
开发者ID:nbevans,项目名称:EventStreams,代码行数:7,代码来源:RepositoryHierarchy.cs

示例14: CreateFrom

        private static Guid CreateFrom(Guid namespaceId, int version, byte[] nameBytes)
        {
            if (version != 3 && version != 5)
                throw new ArgumentOutOfRangeException("version", "version must be either 3 or 5.");

            if (nameBytes == null)
                throw new ArgumentNullException("nameBytes");

            // convert the namespace UUID to network order (step 3)
            var namespaceBytes = namespaceId.ToByteArray();
            SwapByteOrder(namespaceBytes);

            // comput the hash of the name space ID concatenated with the name (step 4)
            byte[] hash;
            using (var algorithm = version == 3 ? (HashAlgorithm) MD5.Create() : SHA1.Create())
            {
                algorithm.TransformBlock(namespaceBytes, 0, namespaceBytes.Length, null, 0);
                algorithm.TransformFinalBlock(nameBytes, 0, nameBytes.Length);
                hash = algorithm.Hash;
            }

            // most bytes from the hash are copied straight to the bytes of the new GUID (steps 5-7, 9, 11-12)
            var newGuid = new byte[16];
            Array.Copy(hash, 0, newGuid, 0, 16);

            // set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the appropriate 4-bit version number from Section 4.1.3 (step 8)
            newGuid[6] = (byte) ((newGuid[6] & 0x0F) | (version << 4));

            // set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively (step 10)
            newGuid[8] = (byte) ((newGuid[8] & 0x3F) | 0x80);

            // convert the resulting UUID to local byte order (step 13)
            SwapByteOrder(newGuid);
            return new Guid(newGuid);
        }
开发者ID:jbrahy,项目名称:derp.inventory,代码行数:35,代码来源:DeterministicGuid.cs

示例15: BytesToGuid

 public void BytesToGuid()
 {
     var guid = new Guid("21EC2020-3AEA-1069-A2DD-08002B30309D");
     var bytes = guid.ToByteArray();
     dynamic result = new { Bar = bytes }.ToExpando(new { Bar = typeof(Guid) });
     Assert.AreEqual(guid, result.Bar);
 }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.Model,代码行数:7,代码来源:AnonTypeSourceAndTypeHintTest.cs


注:本文中的System.Guid.ToByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。