Beispiel #1
0
        public static IType GetDataType(DocumentNode dataNode)
        {
            if (dataNode == null)
            {
                return((IType)null);
            }
            IType type1 = dataNode.Type;
            IType type2;

            if (dataNode is DocumentPrimitiveNode)
            {
                type2 = DocumentPrimitiveNode.GetValueAsType(dataNode) ?? dataNode.Type;
            }
            else
            {
                DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)dataNode;
                if (PlatformTypes.ObjectDataProvider.IsAssignableFrom((ITypeId)dataNode.Type))
                {
                    type2 = DataContextHelper.GetObjectDataProviderType(documentCompositeNode);
                }
                else if (PlatformTypes.CollectionViewSource.IsAssignableFrom((ITypeId)dataNode.Type))
                {
                    type2 = DataContextHelper.GetCollectionViewSourceType(documentCompositeNode);
                }
                else if (dataNode.Type.IsBinding)
                {
                    type2 = DataContextHelper.GetBindingType(documentCompositeNode);
                }
                else if (dataNode.Type.RuntimeType == typeof(DesignInstanceExtension))
                {
                    type2 = DataContextHelper.GetDesignInstanceType(documentCompositeNode);
                }
                else if (dataNode.Type.RuntimeType == typeof(DesignDataExtension))
                {
                    type2 = DataContextHelper.GetDesignDataType(documentCompositeNode);
                }
                else
                {
                    if (!PlatformTypes.DataTemplate.IsAssignableFrom((ITypeId)dataNode.Type))
                    {
                        return(dataNode.Type);
                    }
                    type2 = DataContextHelper.GetDataTemplateType(documentCompositeNode);
                }
                if (type2 == null || type2.RuntimeType == (Type)null)
                {
                    type2 = dataNode.TypeResolver.ResolveType(PlatformTypes.Object);
                }
            }
            return(type2);
        }