Esempio n. 1
0
        /// <summary>
        /// Gets the serializable value of a <see cref="ModelProperty"/>.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        internal static object GetPropertyValue(ModelProperty property, IModelPropertySource source)
        {
            ModelReferenceProperty reference = property as ModelReferenceProperty;

            if (reference != null)
            {
                // Serialize lists
                if (reference.IsList)
                {
                    return(source.GetList(reference).Select(item => GetReference(reference, item)));
                }

                // Serialize references
                else
                {
                    return(GetReference(reference, source.GetReference(reference)));
                }
            }

            // Serialize values
            else
            {
                return(source.GetValue((ModelValueProperty)property));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the serializable value of a <see cref="ModelProperty"/>.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        internal static object GetPropertyValue(ModelProperty property, IModelPropertySource source)
        {
            ModelReferenceProperty reference = property as ModelReferenceProperty;
            if (reference != null)
            {
                // Serialize lists
                if (reference.IsList)
                    return source.GetList(reference).Select(item => GetReference(reference, item));

                // Serialize references
                else
                    return GetReference(reference, source.GetReference(reference));
            }

            // Serialize values
            else
                return source.GetValue((ModelValueProperty)property);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the <see cref="ModelInstance"/> defined by specified source path.
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public ModelInstance GetReference(ModelInstance root)
        {
            IModelPropertySource source = GetSource(root);

            return(source == null ? null : source.GetReference(SourceProperty));
        }