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)); }
public IProperty GetValueProperty() { if (this.Parent != null) { DocumentCompositeNode parent = this.Parent; IType type = parent.Type; IProperty sitePropertyKey = this.SitePropertyKey; if (sitePropertyKey != null) { IPropertyValueTypeMetadata valueTypeMetadata = type.Metadata as IPropertyValueTypeMetadata; if (valueTypeMetadata != null && sitePropertyKey.Equals((object)valueTypeMetadata.ValueProperty)) { return(DocumentPrimitiveNode.GetValueAsMember(parent.Properties[valueTypeMetadata.PropertyProperty]) as IProperty); } return(sitePropertyKey); } } return((IProperty)null); }