本文整理汇总了C#中IMedia.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# IMedia.Parent方法的具体用法?C# IMedia.Parent怎么用?C# IMedia.Parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMedia
的用法示例。
在下文中一共展示了IMedia.Parent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMediaItemPath
private string GetMediaItemPath(IMedia item)
{
string path = "" ;
path = FileHelper.CleanFileName(item.Name) ;
if (item.ParentId != -1)
{
path = String.Format("{0}\\{1}", GetMediaItemPath(item.Parent()), path);
}
return path;
}
示例2: ExportMedia
public XElement ExportMedia(IMedia item)
{
LogHelper.Debug<MediaExporter>("Exporting Media {0}", () => item.Name);
var nodeName = FileHelper.CleanFileName(item.ContentType.Alias);
XElement xml = uSyncXmlHelper.ExportContentBase(nodeName, item, false);
xml.Add(new XAttribute("parentGUID", item.Level > 1 ? item.Parent().Key : new Guid("00000000-0000-0000-0000-000000000000")));
xml.Add(new XAttribute("mediaTypeAlias", item.ContentType.Alias));
xml.Add(new XAttribute("path", item.Path));
// helpers.FileHelper.ExportMediaFile(item.Path, ImportPairs.GetSourceGuid(item.Key));
// any files here ??? this only works for umbracoFile values
//
// ideally it should look for upload types, (based on alias) and then get any of them
//
// lets not make media any more complicated than it already is.
//
foreach (var file in item.Properties.Where(p => p.Alias == "umbracoFile"))
{
if (file == null || file.Value == null)
{
LogHelper.Debug<MediaExporter>("Media {0} doesn't have an associated file", () => item.Name);
}
else
{
LogHelper.Info<MediaExporter>("umbraco file {0}", () => file.Value.ToString());
FileHelper.ExportMediaFile(file.Value.ToString(), ImportPairs.GetSourceGuid(item.Key));
}
}
return xml;
}
示例3: SerialiseMedia
/// <summary>
/// Serialize IMedia to XElement and adds dependent nodes
/// </summary>
/// <param name="media">Umbraco IMedia object</param>
/// <param name="dependantNodes">this function will add dependent nodes to this collection</param>
/// <returns>returns serialized version of IMedia as XElement</returns>
public XElement SerialiseMedia(IMedia media, Dictionary<int, ObjectTypes> dependantNodes = null)
{
var nodeName = media.ContentType.Alias.ToSafeAliasWithForcingCheck();
var node = new XElement(nodeName,
new XAttribute("name", media.Name),
new XAttribute("nodeTypeAlias", media.ContentType.Alias),
new XAttribute("guid", media.Key),
new XAttribute("sortOrder", media.SortOrder),
new XAttribute("parentGuid", media.Parent() == null ? "-1" : media.Parent().Key.ToString()),
new XAttribute("level", media.Level),
new XAttribute("objectType", ObjectTypes.Media));
var propertyTypes = media.PropertyTypes.Where(x => !Constants.MediaDefaultProperties.Contains(x.Alias)).ToArray();
var count = 0;
foreach (var property in media.Properties.Where(x => !Constants.MediaDefaultProperties.Contains(x.Alias)))
{
var tag = property.ToXml();
var propertyType = propertyTypes.ElementAt(count);
tag.Add(new XAttribute("dataTypeGuid", propertyType.DataTypeId));
tag.Add(new XAttribute("dataTypeName", Services.DataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId).Name));
var guid = propertyTypes.ElementAt(count).DataTypeId;
if (guid == new Guid(Constants.UploadDataTypeGuid))
{
var umbracoFile = property.Value.ToString();
tag.Add(
new XAttribute("umbracoFile", umbracoFile),
new XAttribute("fileName", umbracoFile.Split('/').Last()),
new XAttribute("objectType", ObjectTypes.File));
}
else if (SpecialDataTypes.ContainsKey(guid))
{
DataTypeConverterExport(property, tag, dependantNodes, SpecialDataTypes[guid]);
}
node.Add(tag);
count++;
}
return node;
}