/// <inheritdoc/>
 public override void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     if (CurrentPath.Match(MemberPath))
         VisitAssetMember(item, itemDescriptor);
     else
         base.VisitArrayItem(array, descriptor, index, item, itemDescriptor);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Pushes an array access on the path.
 /// </summary>
 /// <param name="descriptor">The descriptor of the array.</param>
 /// <param name="index">The index in the array.</param>
 /// <exception cref="System.ArgumentNullException">descriptor</exception>
 public void Push(ArrayDescriptor descriptor, int index)
 {
     if (descriptor == null)
     {
         throw new ArgumentNullException("descriptor");
     }
     AddItem(new ArrayPathItem(index));
 }
Ejemplo n.º 3
0
 public ArrayPathItem(ArrayDescriptor descriptor, int index)
 {
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     Index      = index;
     Descriptor = descriptor;
 }
Ejemplo n.º 4
0
 public virtual void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     for (int i = 0; i < array.Length; i++)
     {
         var value = array.GetValue(i);
         CurrentPath.Push(descriptor, i);
         VisitArrayItem(array, descriptor, i, value, value == null ? null : TypeDescriptorFactory.Find(value.GetType()));
         CurrentPath.Pop();
     }
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public virtual void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     for (var i = 0; i < array.Length; i++)
     {
         var value = array.GetValue(i);
         CurrentPath.Push(descriptor, i);
         VisitArrayItem(array, descriptor, i, value, TypeDescriptorFactory.Find(value?.GetType() ?? descriptor.ElementType));
         CurrentPath.Pop();
     }
 }
 public override void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     CollectionItemIdentifiers itemIds;
     if (inNonIdentifiableType == 0 && !CollectionItemIdHelper.TryGetCollectionItemIds(array, out itemIds))
     {
         itemIds = CollectionItemIdHelper.GetCollectionItemIds(array);
         for (var i = 0; i < array.Length; ++i)
         {
             itemIds.Add(i, ItemId.New());
         }
     }
     base.VisitArray(array, descriptor);
 }
        /// <summary>
        /// Creates a type descriptor for the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>An instance of type descriptor.</returns>
        protected virtual ITypeDescriptor Create(Type type)
        {
            ITypeDescriptor descriptor;

            // The order of the descriptors here is important

            if (PrimitiveDescriptor.IsPrimitive(type))
            {
                descriptor = new PrimitiveDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (DictionaryDescriptor.IsDictionary(type)) // resolve dictionary before collections, as they are also collections
            {
                // IDictionary
                descriptor = new DictionaryDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (CollectionDescriptor.IsCollection(type))
            {
                // ICollection
                descriptor = new CollectionDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (type.IsArray)
            {
                // array[]
                descriptor = new ArrayDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (NullableDescriptor.IsNullable(type))
            {
                descriptor = new NullableDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else
            {
                // standard object (class or value type)
                descriptor = new ObjectDescriptor(this, type, emitDefaultValues, namingConvention);
            }

            return(descriptor);
        }
Ejemplo n.º 8
0
 public virtual void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     Visit(item, itemDescriptor);
 }
Ejemplo n.º 9
0
        public override void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
        {
            var node = stackItems.Peek();
            var newNode = new DataVisitArrayItem(index, item, itemDescriptor);
            AddItem(node, newNode);

            stackItems.Push(newNode);
            base.VisitArrayItem(array, descriptor, index, item, itemDescriptor);
            stackItems.Pop();
        }
Ejemplo n.º 10
0
 public override void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     base.VisitArrayItem(array, descriptor, index, item, itemDescriptor);
     var assetReference = item as AssetReference;
     var assetBase = item as AssetBase;
     var attachedReference = item != null ? AttachedReferenceManager.GetAttachedReference(item) : null;
     if (assetReference != null)
     {
         AddLink(item,
             (guid, location) =>
             {
                 var newValue = AssetReference.New(descriptor.ElementType, guid.HasValue ? guid.Value : assetReference.Id, location);
                 array.SetValue(newValue, index);
                 return newValue;
             });
     }
     else if (assetBase != null)
     {
         AddLink(item,
             (guid, location) =>
             {
                 var newValue = new AssetBase(location, assetBase.Asset);
                 array.SetValue(newValue, index);
                 return newValue;
             });
     }
     else if (attachedReference != null)
     {
         AddLink(attachedReference,
             (guid, location) =>
             {
                 object newValue = guid.HasValue && guid.Value != Guid.Empty ? AttachedReferenceManager.CreateSerializableVersion(descriptor.ElementType, guid.Value, location) : null;
                 array.SetValue(newValue, index);
                 return newValue;
             });
     }
     else if (item is UFile)
     {
         AddLink(item,
             (guid, location) =>
             {
                 var newValue = new UFile(location);
                 array.SetValue(newValue, index);
                 return newValue;
             });
     }
     else if (item is UDirectory)
     {
         AddLink(item,
             (guid, location) =>
             {
                 var newValue = new UFile(location);
                 array.SetValue(newValue, index);
                 return newValue;
             });
     }
 }
Ejemplo n.º 11
0
 public virtual void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     Visit(item, itemDescriptor);
 }
Ejemplo n.º 12
0
 public virtual void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     for (var i = 0; i < array.Length; i++)
     {
         var value = array.GetValue(i);
         CurrentPath.Push(descriptor, i);
         VisitArrayItem(array, descriptor, i, value, TypeDescriptorFactory.Find(value?.GetType() ?? descriptor.ElementType));
         CurrentPath.Pop();
     }
 }
Ejemplo n.º 13
0
 public virtual void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     for (int i = 0; i < array.Length; i++)
     {
         var value = array.GetValue(i);
         CurrentPath.Push(descriptor, i);
         VisitArrayItem(array, descriptor, i, value, value == null ? null : TypeDescriptorFactory.Find(value.GetType()));
         CurrentPath.Pop();
     }
 }
 public override void VisitArray(Array array, ArrayDescriptor descriptor)
 {
     Fixup(array);
     base.VisitArray(array, descriptor);
 }
        public override void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
        {
            if (ProcessObject(item, descriptor.ElementType)) return;

            base.VisitArrayItem(array, descriptor, index, item, itemDescriptor);
        }
        /// <summary>
        /// Creates a type descriptor for the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>An instance of type descriptor.</returns>
        protected virtual ITypeDescriptor Create(Type type)
        {
            ITypeDescriptor descriptor;
            // The order of the descriptors here is important

            if (PrimitiveDescriptor.IsPrimitive(type))
            {
                descriptor = new PrimitiveDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (DictionaryDescriptor.IsDictionary(type)) // resolve dictionary before collections, as they are also collections
            {
                // IDictionary
                descriptor = new DictionaryDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (CollectionDescriptor.IsCollection(type))
            {
                // ICollection
                descriptor = new CollectionDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (type.IsArray)
            {
                // array[]
                descriptor = new ArrayDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else if (NullableDescriptor.IsNullable(type))
            {
                descriptor = new NullableDescriptor(this, type, emitDefaultValues, namingConvention);
            }
            else
            {
                // standard object (class or value type)
                descriptor = new ObjectDescriptor(this, type, emitDefaultValues, namingConvention);
            }

            return descriptor;
        }