public override bool Equals(object obj) { RefData other = obj as RefData; if (other == null) { return(false); } return(object.ReferenceEquals(this.Data, other.Data)); }
/// <summary> /// </summary> /// <param name="data"></param> /// <param name="dataContract"></param> /// <param name="alreadyRefdValues"></param> /// <param name="nonRefdValues"></param> private static void FindAndAddRefd(object data, DataContract dataContract, ref Dictionary <DataContract, List <RefData> > alreadyRefdValues , ref Dictionary <DataContract, List <RefData> > nonRefdValues) { RefData refData = new RefData(data); FindRefUpdateRef(refData, dataContract, ref alreadyRefdValues, ref nonRefdValues); if (s_refStack.Contains(refData)) { return; } else { s_refStack.Push(refData); } FindRefHandleMembers(data, dataContract, ref alreadyRefdValues, ref nonRefdValues); s_refStack.Pop(); }
private static void FindRefUpdateRef(RefData refData, DataContract dataContract, ref Dictionary <DataContract, List <RefData> > alreadyRefdValues, ref Dictionary <DataContract, List <RefData> > nonRefdValues) { if (dataContract.IsReference) { if (alreadyRefdValues.ContainsKey(dataContract)) { if (!alreadyRefdValues[dataContract].Contains(refData)) { alreadyRefdValues[dataContract].Add(refData); } else { alreadyRefdValues[dataContract][alreadyRefdValues[dataContract].IndexOf(refData)].RefCount++; } } else { List <RefData> list = new List <RefData>(); list.Add(refData); alreadyRefdValues.Add(dataContract, list); } } else if (!(dataContract is PrimitiveDataContract)) { if (nonRefdValues.ContainsKey(dataContract)) { if (!nonRefdValues[dataContract].Contains(refData)) { nonRefdValues[dataContract].Add(refData); } else { nonRefdValues[dataContract][nonRefdValues[dataContract].IndexOf(refData)].RefCount++; } } else { List <RefData> list = new List <RefData>(); list.Add(refData); nonRefdValues.Add(dataContract, list); } } }