Backgournd모델에
나는 현재 모델의 목록에 값을 추가하려고하지만 내가 자바 스크립트에서 그것을 얼마나 다른 것 같다을 기반으로하는 목록에 값을 추가 .
모델
public class ContentBase
{
public string Name { get; set; }
public string Description { get; set; }
public string LastModifiedTime { get; set; }
public string KeyWords { get; set; }
public string Content { get; set; }
public string UniqueId { get; set; }
public string library { get; set; }
public string ContentSummary { get; set; }
public string[] images { get; set; }
}
기능 값을 추가하려면
List<ContentBase> returnList = new List<ContentBase>();
foreach (HtmlNode img in htmlDocument.DocumentNode.SelectNodes("//img"))
{
HtmlAttribute att = img.Attributes["src"];
returnList.Add(images = att.Value); << this is wrong, just trying to give an idea of my intentions
}
질문 내 리터의 string[] images
에 HtmlAttribute att = img.Attributes["src"];
에서 결과를 추가하려고
ist. 그런 식으로 한 번 나는
업데이트
이 위의 기능이이를 채 웁니다 내가 내 목록의 string[] images
부분에 각 루프 내에서 얻을 수있는 모든 값을 가질 수있을 것입니다이 반복을 완료 내 목록
string content = "";
if (includeContent == true)
{
content = rslt[ContentBase.fastContent] != null ? rslt[ContentBase.fastContent].ToString() : "";
}
returnList.Add(new ContentBase()
{
UniqueId = rslt[ContentBase.fasstUniqueId] != null ? rslt[ContentBase.fasstUniqueId].ToString() : "",
LastModifiedTime = rslt[ContentBase.fasstLastModifiedTime] != null ? rslt[ContentBase.fasstLastModifiedTime].ToString().Substring(0, 8) : "",
Name = rslt[ContentBase.fastName] != null ? rslt[ContentBase.fastName].ToString() : "",
Description = rslt[ContentBase.fastDescription] != null ? rslt[ContentBase.fastDescription].ToString() : "",
KeyWords = rslt[ContentBase.fastKeyWords] != null ? rslt[ContentBase.fastKeyWords].ToString() : "",
ContentSummary = rslt[ContentBase.fasstContentSummary] != null ? rslt[ContentBase.fasstContentSummary].ToString() : "",
Content = content,
});
는 –
목록 당신은 그것의'images' 속성을 설정하는 단 하나의'ContentBase' 요소가 포함됩니다 반환 목록의 내부 이미지 속성에 att.Value를 추가하려고? –
자리 비움, 예, 각 루프에 대해 my에서 수신 한 요소가 포함됩니다. 요소 수는 정적이 아닌 동적 일 것입니다. –