本文整理汇总了C#中Asset.GetContent方法的典型用法代码示例。如果您正苦于以下问题:C# Asset.GetContent方法的具体用法?C# Asset.GetContent怎么用?C# Asset.GetContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset.GetContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoLinkLocales
public static void AutoLinkLocales(Asset aContentSource, Asset aContentDest, string szSitePath)
{
if (!Asset.Load(szSitePath + "/Relationships Config/" + aContentSource.Id.ToString() + "-" + aContentDest.Id.ToString()).IsLoaded)
{
Asset aRelationship = Asset.CreateNewAsset(aContentSource.Id.ToString() + "-" + aContentDest.Id.ToString(), Asset.Load(szSitePath + "/Relationships Config/"), Asset.Load("/System/Translation Model Framework/_Models/Relationship/Relationship"), new Dictionary<string, string>());
Dictionary<string, string> dtTmpContent = new Dictionary<string, string>();
dtTmpContent.Add("source_id", aContentSource.Id.ToString());
dtTmpContent.Add("destination_id", aContentDest.Id.ToString());
dtTmpContent.Add("source_last_modified_date", aContentSource.ModifiedDate.ToString());
dtTmpContent.Add("filter_string", "|" + aContentSource.Id.ToString() + "|" + aContentDest.Id.ToString() + "|");
foreach (KeyValuePair<string, string> kvpData in aContentSource.GetContent())
{
if (!string.Equals(kvpData.Key.Substring(0, 1), "_", StringComparison.OrdinalIgnoreCase))
dtTmpContent.Add("sourceOld_" + kvpData.Key, kvpData.Value);
}
aRelationship.SaveContent(dtTmpContent);
}
}
示例2: FixRelativeLinks
public static void FixRelativeLinks(Asset aContentDest, Asset aSourceLanguageContent, Asset aDestLanguageContent, string szSitePath)
{
//Out.DebugWriteLine("FixRelativeLinks starts");
string szCurrId = aContentDest.Id.ToString();
foreach (KeyValuePair<string, string> kvpData in aContentDest.GetContent())
{
if (kvpData.Key.StartsWith("upload#"))
{
Asset aLinkedItem = Asset.Load(kvpData.Value);
string szSourcePath = aLinkedItem.AssetPath.ToString();
string szDestinationPath = szSourcePath.Replace(aSourceLanguageContent["folder_root"], aDestLanguageContent["folder_root"]);
int nFixLinkFlag = 0;
if (Asset.Load(szDestinationPath).IsLoaded && !string.Equals(szSourcePath, szDestinationPath))
{
nFixLinkFlag = 1;
}
else
{
string szDestinationId = "";
foreach (Asset aConfig in GetRelList(aLinkedItem.Id, "source", szSitePath))
{
if (Asset.Load(aConfig["destination_id"]).AssetPath.ToString().ToLower().Contains(aDestLanguageContent["folder_root"].ToLower()))
{
szDestinationId = aConfig["destination_id"];
break;
}
}
if (!string.IsNullOrWhiteSpace(szDestinationId))
{
szDestinationPath = szDestinationId;
nFixLinkFlag = 1;
}
else
nFixLinkFlag = 0;
}
if (int.Equals(nFixLinkFlag, 1))
{
Asset aCurrId = Asset.Load(szCurrId);
aCurrId.DeleteContentField(kvpData.Key);
Asset aItemDest = Asset.Load(szDestinationPath);
//TODO: FixRelativeLinks (_cmsIdPath)
aCurrId.SaveContentField(kvpData.Key, "/cpt_internal/" + aItemDest.Id.ToString());
}
}
}
}
示例3: GetAssetContent
private string GetAssetContent(Asset asset)
{
StringBuilder sbOutput = new StringBuilder();
foreach (KeyValuePair<string, string> kvpField in asset.GetContent())
{
string szKey = ReplaceTextValues(kvpField.Key);
string szValue = ReplaceTextValues(ReplaceCptInternalPath(kvpField.Value));
sbOutput.AppendLine(string.Format("<content_field key=\"{0}\"><![CDATA[{1}]]></content_field>", szKey, szValue));
}
return sbOutput.ToString();
}