public static bool TryConstructFromData <TDstValue, TSrcValue>(ref TSrcValue srcValue, string typeIdentifierKey, VisitResult result, out TDstValue dstValue)
        {
            if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(TDstValue)))
            {
                dstValue = default;
                return(false);
            }

            // Try to construct based on the source type.
            if (TypeConstruction.TryConstruct(srcValue.GetType(), out dstValue))
            {
                return(true);
            }

            // Try to construct based on the destination type.
            if (TypeConstruction.TryConstruct(out dstValue))
            {
                return(true);
            }

            // If type identifier key option is not set, cannot construct this type.
            if (string.IsNullOrEmpty(typeIdentifierKey))
            {
                return(false);
            }

            // Try to get destination type name from type identifier meta data.
            if (!PropertyContainer.TryGetValue(ref srcValue, typeIdentifierKey, out string assemblyQualifiedTypeName))
            {
                result.AddLog($"PropertyContainer.Construct failed to construct DstType=[{typeof(TDstValue)}]. SrcValue Property=[{typeIdentifierKey}] was not found.");
                return(false);
            }

            // Verify destination type name is valid.
            if (string.IsNullOrEmpty(assemblyQualifiedTypeName))
            {
                result.AddException(new InvalidOperationException($"PropertyContainer.Construct failed to construct DstType=[{typeof(TDstValue)}]. SrcValue Property=[{typeIdentifierKey}] contained null or empty type information."));
                return(false);
            }

            // Try to get destination type.
            var dstType = Type.GetType(assemblyQualifiedTypeName);

            if (null == dstType)
            {
                result.AddException(new InvalidOperationException($"PropertyContainer.Construct failed to construct DstType=[{typeof(TDstValue)}]. Could not resolve type from TypeName=[{assemblyQualifiedTypeName}]."));
                return(false);
            }

            return(TypeConstruction.TryConstruct(dstType, out dstValue));
        }
 public void VisitCollectionProperty <TDstElementProperty, TDstElementValue>(
     TDstElementProperty dstElementProperty,
     ref TDstContainer dstContainer,
     ref ChangeTracker changeTracker)
     where TDstElementProperty : ICollectionProperty <TDstContainer, TDstElementValue>, ICollectionElementProperty <TDstContainer, TDstElementValue>
 {
     Result.AddException(new InvalidOperationException($"PropertyContainer.Construct ContainerType=[{typeof(TDstContainer)}] PropertyName=[{dstElementProperty.GetName()}] expected collection type but was container type."));
 }
 public void VisitCollectionProperty <TSrcElementProperty, TSrcElementValue>(
     TSrcElementProperty srcElementProperty,
     ref TSrcContainer srcContainer,
     ref ChangeTracker changeTracker)
     where TSrcElementProperty : ICollectionProperty <TSrcContainer, TSrcElementValue>, ICollectionElementProperty <TSrcContainer, TSrcElementValue>
 {
     Result.AddException(new InvalidOperationException("PropertyContainer.Construct does not support arrays of arrays."));
 }