Beispiel #1
0
        public int CompareTo(EntityAppearanceCollection other)
        {
            var h = new Helper.Comparator();

            h.Append(members.Values, other.members.Values);
            return(h.Finish());
        }
Beispiel #2
0
        public override int CompareTo(object obj)
        {
            var other = obj as CommonMessage;

            if (other == null)
            {
                return(1);
            }
            if (other == this)
            {
                return(0);
            }
            var c = new Helper.Comparator()
                    .Append(Origin, other.Origin)
                    .Append(SentOrderID, other.SentOrderID)
                    .Append(Channel, other.Channel)
                    .Append(Payload, other.Payload);

            return(c.Finish());
        }
Beispiel #3
0
        public override int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (obj == this)
            {
                return(0);
            }
            var other = obj as Message;

            if (other == null)                  //nothing i know
            {
                return(base.CompareTo(obj));
            }
            var c = new Helper.Comparator()
                    .AppendComparisonResult(base.CompareTo(other))
                    .Append(TargetEntityID, other.TargetEntityID);

            return(c.Finish());
        }
Beispiel #4
0
        public override int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (obj == this)
            {
                return(0);
            }
            var other = obj as Broadcast;

            if (other == null)              //nothing i know
            {
                return(base.CompareTo(obj));
            }
            var c = new Helper.Comparator()
                    .AppendComparisonResult(base.CompareTo(other))
                    .Append(MaxRange, other.MaxRange);

            return(c.Finish());
        }
Beispiel #5
0
        public static Tuple <SerialSDS, SerialCCS> Begin(Int3 myID, Action <SerialSDS> fetchSDS, Action <SerialCCS> fetchCCS)
        {
            sdsPoller = new DBType.ContinuousPoller <SerialSDS>(null, (collection) =>
            {
                SerialSDS latest = null;
                foreach (var candidate in collection)
                {
                    if (latest == null || latest.Generation < candidate.Generation)
                    {
                        latest = candidate;
                    }
                    else if (latest.Generation == candidate.Generation)
                    {
                        //weird, but let's check
                        if (!candidate.IC.IsEmpty)
                        {
                            throw new IntegrityViolation("SDS candidate at g=" + candidate.Generation + " is not consistent");
                        }
                        if (candidate.Generation != latest.Generation)
                        {
                            throw new IntegrityViolation("SDS candidate at g=" + candidate.Generation + " mismatch with favorite at g=" + latest.Generation);
                        }
                        var comp = new Helper.Comparator()
                                   .Append(candidate.SerialEntities, latest.SerialEntities)
                                   .Finish();
                        if (comp != 0)
                        {
                            Log.Error("Persistent SDS data mismatch at g=" + candidate.Generation);
                            if (comp < 0)
                            {
                                latest = candidate;
                            }
                        }
                    }
                }
                if (!latest.IC.IsEmpty)
                {
                    throw new IntegrityViolation("Chosen persistent SDS candidate at g=" + latest.Generation + " is not consistent");
                }
                return(latest);
            });
            sdsPoller.Start(SDSStore, myID.Encoded);
            sdsPoller.OnChange = serial => fetchSDS(serial);


            ccsPoller = new DBType.ContinuousPoller <SerialCCS>(null, (collection) =>
            {
                SerialCCS latest = null;
                foreach (var candidate in collection)
                {
                    if (latest == null || latest.Generation < candidate.Generation)
                    {
                        latest = candidate;
                    }
                    else if (latest.Generation == candidate.Generation)
                    {
                        //weird, but let's check
                        if (candidate.Generation != latest.Generation)
                        {
                            throw new IntegrityViolation("CCS candidate at g=" + candidate.Generation + " mismatch with favorite at g=" + latest.Generation);
                        }
                        var comp = new Helper.Comparator()
                                   .Append(candidate.Data, latest.Data)
                                   .Finish();
                        if (comp != 0)
                        {
                            Log.Error("Persistent CCS data mismatch at g=" + candidate.Generation);
                            if (comp < 0)
                            {
                                latest = candidate;
                            }
                        }
                    }
                }
                return(latest);
            });
            ccsPoller.Start(CCSStore, myID.Encoded);
            ccsPoller.OnChange = serial => fetchCCS(serial);

            return(new Tuple <SerialSDS, SerialCCS>(sdsPoller.Latest, ccsPoller.Latest));
        }