文字列を数値に変換する際に、.Value を使用できないようです。
これを使用して、Umbraco を使用してレスポンシブ イメージを作成しています。
public static IHtmlString GetSrcSet(this IPublishedContent item, int width = 0, int height = 0, string widths = "300,600,768")
{
StringBuilder sb = new StringBuilder(string.Empty);
if (width == 0)
{
width = int.Parse(item.GetProperty("UmbracoWidth").ToString());
}
if (height == 0)
{
height = int.Parse(item.GetProperty("UmbracoHeight").ToString());
}
string[] splitWidths = widths.Split(',');
foreach (string newWidth in splitWidths)
{
. . .
}
return (new HtmlString(sb.ToString()));
}
これらの行で .Value を使用する必要があると確信しています
if (width == 0)
{
width = int.Parse(item.GetProperty("UmbracoWidth").Value.ToString());
}
if (height == 0)
{
height = int.Parse(item.GetProperty("UmbracoHeight").Value.ToString());
}
しかし、私は得る
エラー CS0119 'PublishedElementExtensions.Value(IPublishedElement, string, string, string, Fallback, object)' はメソッドであり、指定されたコンテキストでは無効です
省略.Value:
入力文字列は、正しい形式ではありませんでした。