Esempio n. 1
0
        /// <summary>
        /// Ensure the destination instance path is valid when nulls are encountered along the path.
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="property"></param>
        /// <param name="index"></param>
        bool EnsureDestinationInstance(ModelInstance instance, ModelReferenceProperty property, int index)
        {
            if (property.IsList)
            {
                ModelInstanceList list = instance.GetList(property);
                for (int i = list.Count; i <= index; i++)
                {
                    list.Add(property.PropertyType.Create());
                }
            }
            else
            {
                instance.SetReference(property, property.PropertyType.Create());
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Ensure the destination instance path is valid when nulls are encountered along the path.
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="property"></param>
        /// <param name="index"></param>
        bool EnsureDestinationInstance(ModelInstance instance, ModelReferenceProperty property, int index)
        {
            if (property.IsList)
            {
                ModelInstanceList list = instance.GetList(property);
                for (int i = list.Count; i <= index; i++)
                    list.Add(property.PropertyType.Create());
            }
            else
                instance.SetReference(property, property.PropertyType.Create());

            return true;
        }