Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     obj = null;
     indexEnumerator.Dispose();
 }
Ejemplo n.º 4
0
 public ReferenceEnumerator(ReferenceEnumerable obj)
 {
     this.obj        = obj;
     indexEnumerator = obj.Indices.GetEnumerator();
 }