Esempio n. 1
0
        internal static unsafe ChaosScheduleJob FromNative(NativeTypes.FABRIC_CHAOS_SCHEDULE_JOB *pointer)
        {
            var nativeJob       = *pointer;
            var chaosParameters = NativeTypes.FromNativeString(nativeJob.ChaosParameters);
            var days            = ChaosScheduleJobActiveDays.FromNative(nativeJob.Days);
            var times           = new List <ChaosScheduleTimeRangeUtc>();

            var nativeTimesList = *(NativeTypes.FABRIC_CHAOS_SCHEDULE_TIME_RANGE_UTC_LIST *)nativeJob.Times;

            for (int i = 0; i < nativeTimesList.Count; ++i)
            {
                var time = ChaosScheduleTimeRangeUtc.FromNative(nativeTimesList.Items + i * sizeof(NativeTypes.FABRIC_CHAOS_SCHEDULE_TIME_RANGE_UTC));
                times.Add(time);
            }

            return(new ChaosScheduleJob(chaosParameters, days, times));
        }
Esempio n. 2
0
        private static IntPtr ToNativeJobsList(PinCollection pinCollection, List <ChaosScheduleJob> jobs)
        {
            var jobsArray = new NativeTypes.FABRIC_CHAOS_SCHEDULE_JOB[jobs.Count];

            for (int i = 0; i < jobs.Count; ++i)
            {
                jobsArray[i].ChaosParameters = pinCollection.AddObject(jobs[i].ChaosParameters);
                jobsArray[i].Days            = jobs[i].Days.ToNative(pinCollection);
                jobsArray[i].Times           = ChaosScheduleTimeRangeUtc.ToNativeList(pinCollection, jobs[i].Times);
            }

            var nativeChaosScheduleJobs = new NativeTypes.FABRIC_CHAOS_SCHEDULE_JOB_LIST
            {
                Count = (uint)jobsArray.Length,
                Items = pinCollection.AddBlittable(jobsArray)
            };

            return(pinCollection.AddBlittable(nativeChaosScheduleJobs));
        }
Esempio n. 3
0
        /// <summary>
        /// Reads the state of this object from byte array.
        /// </summary>
        /// <param name="br">A BinaryReader object</param>
        /// <exception cref="EndOfStreamException">The end of the stream is reached. </exception>
        public override void Read(BinaryReader br)
        {
            decimal objectVersion = br.ReadDecimal();

            if (objectVersion >= ChaosConstants.ApiVersion62)
            {
                this.ChaosParameters = br.ReadString();

                this.Days.Read(br);

                int timesCount = br.ReadInt32();
                for (int i = 0; i < timesCount; i++)
                {
                    ChaosScheduleTimeRangeUtc time = new ChaosScheduleTimeRangeUtc();
                    time.Read(br);
                    this.Times.Add(time);
                }
            }
            else
            {
                TestabilityTrace.TraceSource.WriteError(TraceComponent, "Attempting to read a version of object below lowest version. Saw {0}. Expected >=6.2", objectVersion);
                ReleaseAssert.Fail("Failed to read byte serialization of ChaosScheduleJob");
            }
        }
Esempio n. 4
0
 /// <summary>
 /// <para>Initializes a new instance of the <see cref="System.Fabric.Chaos.DataStructures.ChaosScheduleTimeRangeUtc" /> class by copying another time range.</para>
 /// </summary>
 /// <param name="other">Another time range to copy.</param>
 internal ChaosScheduleTimeRangeUtc(ChaosScheduleTimeRangeUtc other)
 {
     this.StartTime = new ChaosScheduleTimeUtc(other.StartTime);
     this.EndTime   = new ChaosScheduleTimeUtc(other.EndTime);
 }