コード例 #1
0
 public SimpleKernel(IProcessor processor, CalculationTask calculationTask, INetCreator netcreater, IResultWriter writer, int expirementCount = 100)
 {
     for (var i = 0; i < expirementCount; i++)
     {
         processor.InitProcess(calculationTask, netcreater);
         processor.Processing();
         processor.WriteResult(writer);
         Console.WriteLine("expirement {0} success", i);
     }
 }
コード例 #2
0
        /// <summary>
        /// GetCalculationTaskFrombytes Deserialize
        /// </summary>
        /// <param name="bytearray"></param>
        /// <returns></returns>
        public static CalculationTask GetCalculationTaskFrombytes(byte[] bytearray)
        {
            var calc         = new CalculationTask();
            var serializer   = new XmlSerializer(calc.GetType());
            var memorystream = new MemoryStream();

            memorystream.Write(bytearray, 0, bytearray.Length);
            memorystream.Position = 0;
            var calc2 = (CalculationTask)serializer.Deserialize(memorystream);

            return(calc2);
        }
コード例 #3
0
        /// <summary>
        /// GetbytesFromCalculationTask Serialize
        /// </summary>
        /// <param name="calc"></param>
        /// <returns></returns>
        public static byte[] GetbytesFromCalculationTask(CalculationTask calc)
        {
            var serializer   = new XmlSerializer(calc.GetType());
            var memorystream = new MemoryStream();

            serializer.Serialize(memorystream, calc);
            memorystream.Position = 0;
            var len = new byte[memorystream.Length];

            memorystream.Read(len, 0, (int)memorystream.Length);
            memorystream.Position = 0;
            return(len);
        }
コード例 #4
0
        /// <summary>
        /// Clone Current Task
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CalculationTask Clone(int id = 0)
        {
            var ret = new CalculationTask
            {
                AddToMaxLinkCount = AddToMaxLinkCount,
                NodeCount         = NodeCount,
                CountOfIteration  = CountOfIteration,
                MinLink           = MinLink,
                TaskId            = id,
                PofInfective      = PofInfective,
                IsAppend          = IsAppend,
                IsAdresDiff       = IsAdresDiff,
                AdressDiffType    = AdressDiffType,
                VirusStrategy     = VirusStrategy,
                NetType           = NetType,
                Path                 = Path,
                Granica              = Granica,
                SegmentCount         = SegmentCount,
                PercentBuckupChannel = PercentBuckupChannel
            };

            return(ret);
        }