예제 #1
0
        public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
        {
            IPropertyId           sitePropertyKey;
            DocumentPrimitiveNode documentNode = viewNode.DocumentNode as DocumentPrimitiveNode;

            if (documentNode != null)
            {
                DocumentNodeStringValue value = documentNode.Value as DocumentNodeStringValue;
                if (value != null)
                {
                    if (viewNode.Parent == null || !viewNode.IsProperty)
                    {
                        sitePropertyKey = null;
                    }
                    else
                    {
                        sitePropertyKey = viewNode.SitePropertyKey;
                    }
                    IPropertyId propertyProperty = sitePropertyKey;
                    if (viewNode.Parent != null)
                    {
                        IPropertyValueTypeMetadata metadata = viewNode.Parent.DocumentNode.Type.Metadata as IPropertyValueTypeMetadata;
                        IPropertyValueTypeMetadata propertyValueTypeMetadatum = metadata;
                        if (metadata != null)
                        {
                            propertyProperty = propertyValueTypeMetadatum.PropertyProperty;
                        }
                    }
                    if (this.ShouldUseDesignTimeUri(propertyProperty))
                    {
                        Uri uri  = new Uri(value.Value, UriKind.RelativeOrAbsolute);
                        Uri uri1 = viewNode.DocumentNode.Context.MakeDesignTimeUri(uri);
                        if (!context.IsSerializationScope)
                        {
                            viewNode.Instance = uri1;
                        }
                        else
                        {
                            viewNode.Instance = DocumentNodeUtilities.NewUriDocumentNode(context.DocumentContext, uri1);
                        }
                        viewNode.InstanceState = InstanceState.Valid;
                    }
                }
            }
            return(base.Instantiate(context, viewNode));
        }