internal static IReference CreateReference(object objectValue, Type objectType, object index) { if (objectValue != null && !objectType.IsInstanceOfType(objectValue)) { throw new ArgumentException(@"objectValue type does not match objectType", nameof(objectValue)); } if (!CreatingReference.IsValueCreated) { CreatingReference.Value = 0; } ++CreatingReference.Value; IReference reference; var isCollection = HasCollectionReference(objectValue?.GetType() ?? objectType); if (objectValue != null && isCollection && index == NotInCollection) { reference = new ReferenceEnumerable((IEnumerable)objectValue, objectType, index); } else { reference = new ObjectReference(objectValue, objectType, index); } --CreatingReference.Value; return(reference); }
internal static IReference CreateReference(object objectValue, Type objectType, object index) { if (objectValue != null && !objectType.IsInstanceOfType(objectValue)) { throw new ArgumentException(@"objectValue type does not match objectType", "objectValue"); } ++creatingReference; IReference reference; var enumerableValue = objectValue as IEnumerable; if (enumerableValue != null && index == NotInCollection) { reference = new ReferenceEnumerable(enumerableValue, objectType, index); } else { reference = new ObjectReference(objectValue, objectType, index); } --creatingReference; return(reference); }
public void Dispose() { obj = null; indexEnumerator.Dispose(); }
public ReferenceEnumerator(ReferenceEnumerable obj) { this.obj = obj; indexEnumerator = obj.Indices.GetEnumerator(); }