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


C# Cache.VerifyDigitalSignature方法代码示例

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


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

示例1: Communication

            public void Communication()
            {
                lock (_downloadNodeHash)
                {
                    _downloadNodeHash.Add(key.FileLocation.NodeID);
                }

                NodeListViewItem nlvi = null;
                string stringHash = "";
                int i = -1;

                IFileShareService proxy = null;
                try
                {
                    stringHash = BinaryEditor.BytesToHexString(item.Hash);
                    Cache cache;

                    lock (Settings.Default._cacheController.CacheList)
                    {
                        cache = Settings.Default._cacheController.CacheList.
                            FirstOrDefault(n => BinaryEditor.ArrayEquals(n.SignatureHash, item.SignatureHash));
                    }

                    lock (_downloadBlockDic)
                    {
                        if (!_downloadBlockDic.ContainsKey(stringHash))
                            _downloadBlockDic.Add(stringHash, new List<int>());
                    }

                    nlvi = new NodeListViewItem()
                    {
                        CommunicationType = "download",
                        Description = "キャッシュブロックを受信しています",
                        Node = key.FileLocation,
                    };
                    NodeShowAdd(this, nlvi);

                    using (ChannelFactory<IFileShareService> channel = new ChannelFactory<IFileShareService>("Tcp_Client", key.FileLocation.Endpoint))
                    {
                        proxy = channel.CreateChannel();

                        if (cache == null)
                        {
                            cache = new Cache();
                            cache.Key = Clone.DeepCopyClone<Key>(key);
                            cache.Key.FileLocation = new Node();
                            cache.Key.Review = null;

                            cache.Category = key.Cache_Category;
                            cache.CreationTime = key.Cache_CreationTime;
                            cache.Name = key.Cache_FileName;
                            cache.Sign = key.Cache_Sign;
                            cache.Size = key.Cache_Size;
                            cache.Signature = key.Cache_Signature;
                            cache.Signature_SHA1 = key.Cache_Signature_SHA1;
                            cache.PublicKey = key.PublicKey;
                            cache.CacheBlockHash = proxy.GetCacheBlockHashList(key.Cache_Hash);

                            if (!cache.VerifyDigitalSignature()) throw new ApplicationException("電子署名が不正です");

                            lock (Settings.Default._cacheController.CacheList)
                            {
                                Settings.Default._cacheController.CacheList.Add(cache);
                            }
                        }

                        for (; ; )
                        {
                            lock (_downloadBlockDic)
                            {
                                List<int> bmp = new List<int>();

                                for (int j = 0; j < item.CacheBlockLength; j++)
                                {
                                    if ((!Settings.Default._cacheController.ContainsKey(stringHash) ||
                                            Settings.Default._cacheController[stringHash][j] == null) && key.CacheBlockBitmap[j] == true &&
                                            !_downloadBlockDic[stringHash].Any(n => n == j))
                                    {
                                        bmp.Add(j);
                                    }
                                }

                                if (bmp.Count == 0) return;

                                i = bmp[new Random().Next(bmp.Count)];
                                _downloadBlockDic[stringHash].Add(i);
                            }

                            byte[] block = proxy.GetCacheBlock(item.Hash, i);
                            DebugWrite(this, "download成功:キャッシュブロックのダウンロードに成功しました");

                            if (block != null)
                                Settings.Default._cacheController[cache, i] = block;

                            lock (_downloadBlockDic)
                            {
                                _downloadBlockDic[stringHash].Remove(i);
                            }
                        }
                    }
//.........这里部分代码省略.........
开发者ID:asapo,项目名称:Profes,代码行数:101,代码来源:DownloadController.cs


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