internal override CodeExpression BuildStringPropertyExpression(PropertyEntry pse) { if ((pse.PropertyInfo != null) && (Attribute.GetCustomAttribute(pse.PropertyInfo, typeof(UrlPropertyAttribute)) is UrlPropertyAttribute)) { if (pse is SimplePropertyEntry) { SimplePropertyEntry entry = (SimplePropertyEntry)pse; string virtualPath = (string)entry.Value; if (UrlPath.IsRelativeUrl(virtualPath) && !UrlPath.IsAppRelativePath(virtualPath)) { entry.Value = UrlPath.MakeVirtualPathAppRelative(UrlPath.Combine(this._themeParser.VirtualDirPath.VirtualPathString, virtualPath)); } } else { ComplexPropertyEntry entry2 = (ComplexPropertyEntry)pse; StringPropertyBuilder builder = (StringPropertyBuilder)entry2.Builder; string str2 = (string)builder.BuildObject(); if (UrlPath.IsRelativeUrl(str2) && !UrlPath.IsAppRelativePath(str2)) { entry2.Builder = new StringPropertyBuilder(UrlPath.MakeVirtualPathAppRelative(UrlPath.Combine(this._themeParser.VirtualDirPath.VirtualPathString, str2))); } } } return(base.BuildStringPropertyExpression(pse)); }
public void StringPropertyBuilder_should_set_string_properties() { var obj = new Class1(); var propInfo = typeof(Class1).GetProperty("stringProperty1"); var lookup = Mock.Of <IPropertyInfoMetadataLookup>( f => f.GetMetadata(propInfo) == new Parameter { required = true }); var builder = new StringPropertyBuilder(lookup); Assert.IsTrue(builder.BuildProperty(obj, propInfo)); Assert.IsFalse(string.IsNullOrEmpty(obj.stringProperty1)); Assert.AreEqual(6, obj.stringProperty1.Length); }
internal override CodeExpression BuildStringPropertyExpression(PropertyEntry pse) { // Make the UrlProperty based on virtualDirPath for control themes. if (pse.PropertyInfo != null) { UrlPropertyAttribute urlAttrib = Attribute.GetCustomAttribute(pse.PropertyInfo, typeof(UrlPropertyAttribute)) as UrlPropertyAttribute; if (urlAttrib != null) { if (pse is SimplePropertyEntry) { SimplePropertyEntry spse = (SimplePropertyEntry)pse; string strValue = (string)spse.Value; if (UrlPath.IsRelativeUrl(strValue) && !UrlPath.IsAppRelativePath(strValue)) { spse.Value = UrlPath.MakeVirtualPathAppRelative(UrlPath.Combine(_themeParser.VirtualDirPath.VirtualPathString, strValue)); } } else { Debug.Assert(pse is ComplexPropertyEntry); ComplexPropertyEntry cpe = (ComplexPropertyEntry)pse; StringPropertyBuilder builder = (StringPropertyBuilder)cpe.Builder; string strValue = (string)builder.BuildObject(); if (UrlPath.IsRelativeUrl(strValue) && !UrlPath.IsAppRelativePath(strValue)) { cpe.Builder = new StringPropertyBuilder(UrlPath.MakeVirtualPathAppRelative(UrlPath.Combine(_themeParser.VirtualDirPath.VirtualPathString, strValue))); } } } } return(base.BuildStringPropertyExpression(pse)); }