Fork me on GitHub
2sxc 9.33 for DNN 7 to 9
Website Builder, Content Manager, App-System: open-source and amazing
You are here: Home  >  Blog

Working with the breaking change ADAM objects 2sxc 9.20

2sxc 9.20 had to change ADAM a bit, to decouple it from DNN - and getting ready for .net core. Here's what you need to know. 

Why the Breaking Change

The previous version of ADAM used objects like File, which were based on the DNN FileInfo and FolderInfo objects. As we're getting ready for DNN.core and running 2sxc in headless environments (without a big DNN in the background), we had to be sure that 2sxc worked without the old WebForms dotnetnuke.dll. 

Compatibility Help

To ensure that most old code will still work, we added some compatibility layer. So AsAdam(...).Files returns objects which can be cast to the old ToSic.SexyContent.Adam.AdamFile, and does provide the old properties, especially

  • FileId with small "d" (the DNN API is very inconsistent about this)
    In the future, cast to ToSic.Sxc.Adam.File and use Id
  • FileName
    In the future, cast to ToSic.Sxc.Adam.File and use FullName
  • CreatedOnDate
    In the future, cast to ToSic.Sxc.Adam.File and use Created

Your Code Will Probably not Break

...because we changed how we implemented things, but in most cases you'll have for-each loops showing files, which don't care about the actual types. There are rare cases where you will run into problems, like the following:

  1. ...or the [your-object].FolderID (note the inconsistent, large D) - we didn't want to continue supporting this inconsistent API, and believe you won't be affected
  2. If you actively cast an object to a DNN FileInfo object
  3. If you specifically mentioned the type ToSic.SexyContent.AdamFolder in your code

What Changed

The internal types of ADAM files and folders were changed to a new interface. This means that namespaces and object-names changed. So if you're affected, check out the code and you should be able to quickly fix things. Here are the most important objects you'll care about:

  • File (ToSic.Sxc.Adam.File, inherits ToSic.Eav.Apps.Assets.File)
    • Id - int - replaces FileId
    • FolderId - int - replaces FolderID (had a large D)
    • Folder - string
    • FullName - string - replaces FileName
    • Name - string
    • Extension - string
    • Path - string
    • Created - datetime
    • Modified - datetime
    • HasMetadata - bool
    • Metadata - DynamicEntity
    • Url - string
    • Type - string
  • Folder (ToSic.Sxc.Adam.Folder, inherits ToSic.Eav.Apps.Assets.Folder)
    • Id - int - replaces FolderID
    • Name - string
    • Path - string
    • Url - string
    • Type - string
    • HasChildren - bool
    • Created - datetime
    • Modified - datetime
    • HasMetadata - bool
    • Metadata - DynamicEntity

The following properties existed in the FileInfo and FolderInfo, and don't exist any more. If you need them, use the DNN API to get the FileInfo / FolderInfo object for the specific ID, and you'll get them:

  • File
    • UniqueId
    • VersionGuid 
    • PortalId 
    • Width 
    • Height 
    • ContentType 
    • StorageLocation 
    • IsCached 
    • SHA1Hash
  • Folder
    • DisplayName 
    • DisplayPath
    • PortalID
    • MappedPath
    • StorageLocation
    • IsProtected
    • IsCached
    • FolderMappingID 
    • IsVersioned 
    • KeyID 
    • ParentID 
    • UniqueId
    • VersionGuid 
    • WorkflowID

Sorry about this

We hope almost nobody is affected, but it was really important to do this, to get ready for cross-platform and headless implementations. We hope you'll be able to get things working asap. 

Love from Switzerland, 
Daniel


Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler