/// <summary> /// キャッシュ評価を追加します /// </summary> /// <param name="hash">キャッシュの電子署名のハッシュ</param> /// <param name="review"></param> public void AddReview(byte[] signatureHash, CacheReview review) { string stringSignatureHash = BinaryEditor.BytesToHexString(signatureHash); lock (_myReviewDic) { _myReviewDic[stringSignatureHash] = review; } lock (_reviewDic) { if (_reviewDic.ContainsKey(stringSignatureHash)) _reviewDic[stringSignatureHash].RemoveAll(n => n.PublicKey == review.PublicKey); } }
public new void GetObjectData(SerializationInfo info, StreamingContext context) { lock (_myReviewDic) { var _myReviewDic_KeyList = new string[_myReviewDic.Count]; var _myReviewDic_ValueList = new CacheReview[_myReviewDic.Count]; int i = 0; foreach (string key in _myReviewDic.Keys) { _myReviewDic_KeyList[i] = key; _myReviewDic_ValueList[i] = _myReviewDic[key]; i++; } info.AddValue("_myReviewDic_Keys", _myReviewDic_KeyList.ToArray(), typeof(string[])); info.AddValue("_myReviewDic_Values", _myReviewDic_ValueList.ToArray(), typeof(CacheReview[])); } lock (_reviewDic) { var _reviewDic_KeyList = new string[_reviewDic.Count]; var _reviewDic_ValueList = new CacheReview[_reviewDic.Count][]; int i = 0; foreach (string key in _reviewDic.Keys) { _reviewDic_KeyList[i] = key; _reviewDic_ValueList[i] = _reviewDic[key].ToArray(); i++; } info.AddValue("_reviewDic_Keys", _reviewDic_KeyList.ToArray(), typeof(string[])); info.AddValue("_reviewDic_Values", _reviewDic_ValueList.ToArray(), typeof(CacheReview[])); } }
/// <summary> /// 悪い /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, RoutedEventArgs e) { if (commentsTextBox.Text.Trim().Length == 0) { _closeFlag = false; MessageBox.Show("コメントが入力されていません"); _closeFlag = true; return; } else if (commentsTextBox.Text.Split('\n').Length > 10) { _closeFlag = false; MessageBox.Show("10行以内にコメントを収めてください"); _closeFlag = true; return; } CacheReview cr = new CacheReview(); cr.Review = Review.悪い; cr.ReviewComments = commentsTextBox.Text.Trim(); cr.Sign = Settings.Default.Sign; cr.PublicKey = Settings.Default.PublicKey; cr.CreateDigitalSignature(Settings.Default.PrivateKey); Settings.Default._keyController.AddReview(this.SignatureHash, cr); _closeFlag = false; this.Close(); }