source: trunk/CrypPlugins/PeerToPeerJobs/JobPart.cs @ 1448

Last change on this file since 1448 was 1448, checked in by Sven Rech, 12 years ago

replaced all BigInteger stuff with the new BigInteger class from .net 4.0

But there are still problems with some plugins (Keysearcher, BigInteger Operations...)

File size: 2.2 KB
Line 
1/* Copyright 2010 Team CrypTool (Christian Arnold), Uni Duisburg-Essen
2
3   Licensed under the Apache License, Version 2.0 (the "License");
4   you may not use this file except in compliance with the License.
5   You may obtain a copy of the License at
6
7       http://www.apache.org/licenses/LICENSE-2.0
8
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14*/
15
16using System;
17using System.Collections.Generic;
18using System.Linq;
19using System.Text;
20using Cryptool.PluginBase.Miscellaneous;
21using System.Numerics;
22
23namespace Cryptool.Plugins.PeerToPeer.Jobs
24{
25    public abstract class JobPart<JobType> : IJobPart
26    {
27        public JobPart(BigInteger jobId)
28        {
29            this.JobId = jobId;
30        }
31
32        public abstract byte[] Serialize();
33
34        public override bool Equals(object obj)
35        {
36            if (obj == null)
37                return false;
38
39            if (ReferenceEquals(this, obj))
40                return true;
41
42            if (this.GetType() != obj.GetType())
43                return false;
44
45            return this == (JobPart<JobType>)obj;
46        }
47
48        public static bool operator ==(JobPart<JobType> left, JobPart<JobType> right)
49        {
50            if ((object)left == (object)right)
51                return true;
52
53            if ((object)left == null || (object)right == null)
54                return false;
55
56            if (left.JobId == right.JobId)
57                return true;
58
59            return false;
60        }
61
62        public static bool operator !=(JobPart<JobType> left, JobPart<JobType> right)
63        {
64            return !(left == right);
65        }
66
67        public override int GetHashCode()
68        {
69            return this.JobId.GetHashCode();
70        }
71
72        #region IJobPart Members
73
74        private BigInteger jobId;
75        public BigInteger JobId
76        {
77            get { return this.jobId; }
78            set { this.jobId = value; }
79        }
80
81        #endregion
82    }
83}
Note: See TracBrowser for help on using the repository browser.