コード例 #1
0
        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);
        }
コード例 #2
0
 public void Dispose()
 {
     obj = null;
     indexEnumerator.Dispose();
 }
コード例 #3
0
 public ReferenceEnumerator([NotNull] ReferenceEnumerable obj)
 {
     this.obj        = obj;
     indexEnumerator = obj.Indices.GetEnumerator();
 }