diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs
index d96d6665ba..a635e2c492 100644
--- a/src/Umbraco.Core/Services/PackagingService.cs
+++ b/src/Umbraco.Core/Services/PackagingService.cs
@@ -71,15 +71,15 @@ namespace Umbraco.Core.Services
/// containing the xml representation of the Content object
public XElement Export(IContent content, bool deep = false, bool raiseEvents = true)
{
- if (raiseEvents)
- {
- if (ExportingContent.IsRaisedEventCancelled(new SaveEventArgs(content), this))
- return default(XElement);
- }
-
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
+ if (raiseEvents)
+ {
+ if (ExportingContent.IsRaisedEventCancelled(new ExportEventArgs(content, nodeName), this))
+ return new XElement(nodeName);
+ }
+
var xml = Export(content, nodeName);
xml.Add(new XAttribute("nodeType", content.ContentType.Id));
xml.Add(new XAttribute("creatorName", content.GetCreatorProfile().Name));
@@ -96,7 +96,7 @@ namespace Umbraco.Core.Services
}
if(raiseEvents)
- ExportedContent.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedContent.RaiseEvent(new ExportEventArgs(content, xml, false), this);
return xml;
}
@@ -167,7 +167,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingContent.IsRaisedEventCancelled(new SaveEventArgs(element), this))
+ if (ImportingContent.IsRaisedEventCancelled(new ImportEventArgs(element), this))
return Enumerable.Empty();
}
@@ -184,7 +184,7 @@ namespace Umbraco.Core.Services
_contentService.Save(contents, userId);
if(raiseEvents)
- ImportedContent.RaiseEvent(new SaveEventArgs(contents, false), this);
+ ImportedContent.RaiseEvent(new ImportEventArgs(contents, element, false), this);
return contents;
}
@@ -198,7 +198,7 @@ namespace Umbraco.Core.Services
_contentService.Save(contents, userId);
if(raiseEvents)
- ImportedContent.RaiseEvent(new SaveEventArgs(contents, false), this);
+ ImportedContent.RaiseEvent(new ImportEventArgs(contents, element, false), this);
return contents;
}
@@ -335,8 +335,8 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingContentType.IsRaisedEventCancelled(new SaveEventArgs(contentType), this))
- return default(XElement);
+ if (ExportingContentType.IsRaisedEventCancelled(new ExportEventArgs(contentType, "DocumentType"), this))
+ return new XElement("DocumentType");
}
var info = new XElement("Info",
@@ -401,7 +401,7 @@ namespace Umbraco.Core.Services
tabs);
if (raiseEvents)
- ExportedContentType.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedContentType.RaiseEvent(new ExportEventArgs(contentType, xml, false), this);
return xml;
}
@@ -430,7 +430,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingContentType.IsRaisedEventCancelled(new SaveEventArgs(element), this))
+ if (ImportingContentType.IsRaisedEventCancelled(new ImportEventArgs(element), this))
return Enumerable.Empty();
}
@@ -481,7 +481,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ImportedContentType.RaiseEvent(new SaveEventArgs(list, false), this);
+ ImportedContentType.RaiseEvent(new ImportEventArgs(list, element, false), this);
return list;
}
@@ -778,12 +778,11 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingDataType.IsRaisedEventCancelled(new SaveEventArgs(dataTypeDefinition), this))
- return default(XElement);
+ if (ExportingDataType.IsRaisedEventCancelled(new ExportEventArgs(dataTypeDefinition, "DataType"), this))
+ return new XElement("DataType");
}
var prevalues = new XElement("PreValues");
-
var prevalueList = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)
.FormatAsDictionary();
@@ -807,7 +806,7 @@ namespace Umbraco.Core.Services
xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));
if (raiseEvents)
- ExportedDataType.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedDataType.RaiseEvent(new ExportEventArgs(dataTypeDefinition, xml, false), this);
return xml;
}
@@ -823,7 +822,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingDataType.IsRaisedEventCancelled(new SaveEventArgs(element), this))
+ if (ImportingDataType.IsRaisedEventCancelled(new ImportEventArgs(element), this))
return Enumerable.Empty();
}
@@ -891,7 +890,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ImportedDataType.RaiseEvent(new SaveEventArgs(list, false), this);
+ ImportedDataType.RaiseEvent(new ImportEventArgs(list, element, false), this);
return list;
}
@@ -954,8 +953,8 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingDictionaryItem.IsRaisedEventCancelled(new SaveEventArgs(dictionaryItem), this))
- return default(XElement);
+ if (ExportingDictionaryItem.IsRaisedEventCancelled(new ExportEventArgs(dictionaryItem, "DictionaryItem"), this))
+ return new XElement("DictionaryItem");
}
var xml = new XElement("DictionaryItem", new XAttribute("Key", dictionaryItem.ItemKey));
@@ -977,7 +976,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ExportedDictionaryItem.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedDictionaryItem.RaiseEvent(new ExportEventArgs(dictionaryItem, xml, false), this);
return xml;
}
@@ -992,7 +991,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingDictionaryItem.IsRaisedEventCancelled(new SaveEventArgs(dictionaryItemElementList), this))
+ if (ImportingDictionaryItem.IsRaisedEventCancelled(new ImportEventArgs(dictionaryItemElementList), this))
return Enumerable.Empty();
}
@@ -1007,7 +1006,7 @@ namespace Umbraco.Core.Services
items.AddRange(ImportDictionaryItem(dictionaryItemElement, languages, raiseEvents));
if (raiseEvents)
- ImportedDictionaryItem.RaiseEvent(new SaveEventArgs(items, false), this);
+ ImportedDictionaryItem.RaiseEvent(new ImportEventArgs(items, dictionaryItemElementList, false), this);
return items;
}
@@ -1100,8 +1099,8 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingLanguage.IsRaisedEventCancelled(new SaveEventArgs(language), this))
- return default(XElement);
+ if (ExportingLanguage.IsRaisedEventCancelled(new ExportEventArgs(language, "Language"), this))
+ return new XElement("Language");
}
var xml = new XElement("Language",
@@ -1110,7 +1109,7 @@ namespace Umbraco.Core.Services
new XAttribute("FriendlyName", language.CultureName));
if (raiseEvents)
- ExportedLanguage.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedLanguage.RaiseEvent(new ExportEventArgs(language, xml, false), this);
return xml;
}
@@ -1126,7 +1125,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingLanguage.IsRaisedEventCancelled(new SaveEventArgs(languageElementList), this))
+ if (ImportingLanguage.IsRaisedEventCancelled(new ImportEventArgs(languageElementList), this))
return Enumerable.Empty();
}
@@ -1147,7 +1146,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ImportedLanguage.RaiseEvent(new SaveEventArgs(list, false), this);
+ ImportedLanguage.RaiseEvent(new ImportEventArgs(list, languageElementList, false), this);
return list;
}
@@ -1167,7 +1166,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingMacro.IsRaisedEventCancelled(new SaveEventArgs(element), this))
+ if (ImportingMacro.IsRaisedEventCancelled(new ImportEventArgs(element), this))
return Enumerable.Empty();
}
@@ -1223,7 +1222,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ImportedMacro.RaiseEvent(new SaveEventArgs(macros, false), this);
+ ImportedMacro.RaiseEvent(new ImportEventArgs(macros, element, false), this);
return macros;
}
@@ -1254,8 +1253,8 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingMacro.IsRaisedEventCancelled(new SaveEventArgs(macro), this))
- return default(XElement);
+ if (ExportingMacro.IsRaisedEventCancelled(new ExportEventArgs(macro, "macro"), this))
+ return new XElement("macro");
}
var xml = new XElement("macro");
@@ -1280,7 +1279,7 @@ namespace Umbraco.Core.Services
xml.Add(properties);
if (raiseEvents)
- ExportedMacro.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedMacro.RaiseEvent(new ExportEventArgs(macro, xml, false), this);
return xml;
}
@@ -1323,15 +1322,15 @@ namespace Umbraco.Core.Services
/// containing the xml representation of the Media object
public XElement Export(IMedia media, bool deep = false, bool raiseEvents = true)
{
- if (raiseEvents)
- {
- if (ExportingMedia.IsRaisedEventCancelled(new SaveEventArgs(media), this))
- return default(XElement);
- }
-
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
+ if (raiseEvents)
+ {
+ if (ExportingMedia.IsRaisedEventCancelled(new ExportEventArgs(media, nodeName), this))
+ return new XElement(nodeName);
+ }
+
var xml = Export(media, nodeName);
xml.Add(new XAttribute("nodeType", media.ContentType.Id));
xml.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
@@ -1348,7 +1347,7 @@ namespace Umbraco.Core.Services
}
if(raiseEvents)
- ExportedMedia.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedMedia.RaiseEvent(new ExportEventArgs(media, xml, false), this);
return xml;
}
@@ -1456,7 +1455,7 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ImportingTemplate.IsRaisedEventCancelled(new SaveEventArgs(element), this))
+ if (ImportingTemplate.IsRaisedEventCancelled(new ImportEventArgs(element), this))
return Enumerable.Empty();
}
@@ -1529,7 +1528,7 @@ namespace Umbraco.Core.Services
_fileService.SaveTemplate(templates, userId);
if(raiseEvents)
- ImportedTemplate.RaiseEvent(new SaveEventArgs(templates, false), this);
+ ImportedTemplate.RaiseEvent(new ImportEventArgs(templates, element, false), this);
return templates;
}
@@ -1576,8 +1575,8 @@ namespace Umbraco.Core.Services
{
if (raiseEvents)
{
- if (ExportingTemplate.IsRaisedEventCancelled(new SaveEventArgs(template), this))
- return default(XElement);
+ if (ExportingTemplate.IsRaisedEventCancelled(new ExportEventArgs(template, "Template"), this))
+ return new XElement("Template");
}
var xml = new XElement("Template");
@@ -1597,7 +1596,7 @@ namespace Umbraco.Core.Services
}
if (raiseEvents)
- ExportedTemplate.RaiseEvent(new SaveEventArgs(xml, false), this);
+ ExportedTemplate.RaiseEvent(new ExportEventArgs(template, xml, false), this);
return xml;
}
@@ -1611,152 +1610,152 @@ namespace Umbraco.Core.Services
///
/// Occurs before Importing Content
///
- public static event TypedEventHandler> ImportingContent;
+ public static event TypedEventHandler> ImportingContent;
///
/// Occurs after Content is Imported and Saved
///
- public static event TypedEventHandler> ImportedContent;
+ public static event TypedEventHandler> ImportedContent;
///
/// Occurs before Exporting Content
///
- public static event TypedEventHandler> ExportingContent;
+ public static event TypedEventHandler> ExportingContent;
///
/// Occurs after Content is Exported to Xml
///
- public static event TypedEventHandler> ExportedContent;
+ public static event TypedEventHandler> ExportedContent;
///
/// Occurs before Exporting Media
///
- public static event TypedEventHandler> ExportingMedia;
+ public static event TypedEventHandler> ExportingMedia;
///
/// Occurs after Media is Exported to Xml
///
- public static event TypedEventHandler> ExportedMedia;
+ public static event TypedEventHandler> ExportedMedia;
///
/// Occurs before Importing ContentType
///
- public static event TypedEventHandler> ImportingContentType;
+ public static event TypedEventHandler> ImportingContentType;
///
/// Occurs after ContentType is Imported and Saved
///
- public static event TypedEventHandler> ImportedContentType;
+ public static event TypedEventHandler> ImportedContentType;
///
/// Occurs before Exporting ContentType
///
- public static event TypedEventHandler> ExportingContentType;
+ public static event TypedEventHandler> ExportingContentType;
///
/// Occurs after ContentType is Exported to Xml
///
- public static event TypedEventHandler> ExportedContentType;
+ public static event TypedEventHandler> ExportedContentType;
///
/// Occurs before Importing DataType
///
- public static event TypedEventHandler> ImportingDataType;
+ public static event TypedEventHandler> ImportingDataType;
///
/// Occurs after DataType is Imported and Saved
///
- public static event TypedEventHandler> ImportedDataType;
+ public static event TypedEventHandler> ImportedDataType;
///
/// Occurs before Exporting DataType
///
- public static event TypedEventHandler> ExportingDataType;
+ public static event TypedEventHandler> ExportingDataType;
///
/// Occurs after DataType is Exported to Xml
///
- public static event TypedEventHandler> ExportedDataType;
+ public static event TypedEventHandler> ExportedDataType;
///
/// Occurs before Importing DictionaryItem
///
- public static event TypedEventHandler> ImportingDictionaryItem;
+ public static event TypedEventHandler> ImportingDictionaryItem;
///
/// Occurs after DictionaryItem is Imported and Saved
///
- public static event TypedEventHandler> ImportedDictionaryItem;
+ public static event TypedEventHandler> ImportedDictionaryItem;
///
/// Occurs before Exporting DictionaryItem
///
- public static event TypedEventHandler> ExportingDictionaryItem;
+ public static event TypedEventHandler> ExportingDictionaryItem;
///
/// Occurs after DictionaryItem is Exported to Xml
///
- public static event TypedEventHandler> ExportedDictionaryItem;
+ public static event TypedEventHandler> ExportedDictionaryItem;
///
/// Occurs before Importing Macro
///
- public static event TypedEventHandler> ImportingMacro;
+ public static event TypedEventHandler> ImportingMacro;
///
/// Occurs after Macro is Imported and Saved
///
- public static event TypedEventHandler> ImportedMacro;
+ public static event TypedEventHandler> ImportedMacro;
///
/// Occurs before Exporting Macro
///
- public static event TypedEventHandler> ExportingMacro;
+ public static event TypedEventHandler> ExportingMacro;
///
/// Occurs after Macro is Exported to Xml
///
- public static event TypedEventHandler> ExportedMacro;
+ public static event TypedEventHandler> ExportedMacro;
///
/// Occurs before Importing Language
///
- public static event TypedEventHandler> ImportingLanguage;
+ public static event TypedEventHandler> ImportingLanguage;
///
/// Occurs after Language is Imported and Saved
///
- public static event TypedEventHandler> ImportedLanguage;
+ public static event TypedEventHandler> ImportedLanguage;
///
/// Occurs before Exporting Language
///
- public static event TypedEventHandler> ExportingLanguage;
+ public static event TypedEventHandler> ExportingLanguage;
///
/// Occurs after Language is Exported to Xml
///
- public static event TypedEventHandler> ExportedLanguage;
+ public static event TypedEventHandler> ExportedLanguage;
///
/// Occurs before Importing Template
///
- public static event TypedEventHandler> ImportingTemplate;
+ public static event TypedEventHandler> ImportingTemplate;
///
/// Occurs after Template is Imported and Saved
///
- public static event TypedEventHandler> ImportedTemplate;
+ public static event TypedEventHandler> ImportedTemplate;
///
/// Occurs before Exporting Template
///
- public static event TypedEventHandler> ExportingTemplate;
+ public static event TypedEventHandler> ExportingTemplate;
///
/// Occurs after Template is Exported to Xml
///
- public static event TypedEventHandler> ExportedTemplate;
+ public static event TypedEventHandler> ExportedTemplate;
#endregion
}
}
\ No newline at end of file