internal static IReference CreateReference(object objectValue, Type objectType, NodeIndex index, bool isMember) { 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 (isMember) { reference = new ObjectReference(objectValue, objectType, index); } else { if (objectValue != null && isCollection && index.IsEmpty) { reference = new ReferenceEnumerable((IEnumerable)objectValue, objectType); } else { reference = null; } } --CreatingReference.Value; return(reference); }
public void Dispose() { obj = null; indexEnumerator.Dispose(); }
public ReferenceEnumerator([NotNull] ReferenceEnumerable obj) { this.obj = obj; indexEnumerator = obj.Indices.GetEnumerator(); }