public override bool Equals(ref TItem[] a, ref TItem[] b) { if (ReferenceEquals(a, b)) { return(true); } else if (AnyNull(a, b)) { return(false); } else if (a.Length != b.Length) { return(false); } else { for (int i = 0; i < a.Length; i++) { if (!m_itemSerializer.Equals(ref a[i], ref b[i])) { return(false); } } return(true); } }
public override bool Equals(ref List <TItem> a, ref List <TItem> b) { if (ReferenceEquals(a, b)) { return(true); } else if (AnyNull(a, b)) { return(false); } else if (a.Count != b.Count) { return(false); } else { TItem aa, bb; for (int i = 0; i < a.Count; i++) { aa = a[i]; bb = b[i]; if (!m_itemSerializer.Equals(ref aa, ref bb)) { return(false); } } return(true); } }
public override bool Equals(ref Dictionary <TKey, TValue> a, ref Dictionary <TKey, TValue> b) { if (ReferenceEquals(a, b)) { return(true); } else if (AnyNull(a, b)) { return(false); } else if (a.Count != b.Count) { return(false); } else { TValue valA; TValue valB; foreach (var pair in a) { // TODO: b dictionary key comparer is used, not sure if it's correct (but it's fast) valA = pair.Value; if (!b.TryGetValue(pair.Key, out valB) || !m_valueSerializer.Equals(ref valA, ref valB)) { return(false); } } return(true); } }
public override bool Equals(ref TOwner a, ref TOwner b) { TMember valA, valB; m_getter(ref a, out valA); m_getter(ref b, out valB); return(m_serializer.Equals(ref valA, ref valB)); }
public override bool Equals(ref TOwner a, ref TOwner b) { #if !XB1 // XB1_SYNC_SERIALIZER_NOEMIT TMember valA, valB; m_getter(ref a, out valA); m_getter(ref b, out valB); return(m_serializer.Equals(ref valA, ref valB)); #else // XB1 if (a is IMySetGetMemberDataHelper) { TMember valA, valB; valA = (TMember)((IMySetGetMemberDataHelper)a).GetMemberData(m_memberInfo); valB = (TMember)((IMySetGetMemberDataHelper)b).GetMemberData(m_memberInfo); return(m_serializer.Equals(ref valA, ref valB)); } else { System.Diagnostics.Debug.Assert(false, "TODO for XB1."); return(false); } #endif // XB1 }
public override bool Equals(ref T?a, ref T?b) { if (a.HasValue != b.HasValue) // One is null and the other is not, return false { return(false); } else if (!a.HasValue) // Here both have value or both are null, if null, return true { return(true); } else { T aa = a.Value; T bb = b.Value; return(m_serializer.Equals(ref aa, ref bb)); } }
static bool WriteNullable <T>(BitStream stream, ref T value, bool isNullable, MySerializer <T> serializer) { if (isNullable) { T def = default(T); bool hasValue = !serializer.Equals(ref value, ref def); stream.WriteBool(hasValue); return(hasValue); } else { if (!typeof(T).IsValueType && value == null) { throw new MySerializeException(MySerializeErrorEnum.NullNotAllowed); } return(true); } }