To start using the Agility CMS & .NET 5 Starter, sign up for a FREE account and create a new Instance using the Blog Template.
Introduction to .NET and Agility CMS
- Uses the latest version of .NET, with greatly improved performance across many components, Language improvements to C# and F#, and much more.
- Provides a facility to developers to sync their Pages, Items and Lists in their local file system.
- Provides methods to clear the sync if you want to delete the generated files.
- Supports generation of files in live and preview mode with the specified locale.
- Ability to generate the objects from the extracted files of Pages, Items and Lists based on their respective Id's.
🚨 Before you dive into the code, it's important that you have the latest version of the .NET SDK installed on your machine (>=v6.0), as the project will not run without this. Install the Nuget Packages Newtonsoft.Json (13.0.1) & RestSharp (106.11.7).
- Clone the solution AgilityCMS.Net.Sync.SDK.
- Add namespaces AgilityCMS.Net.Sync & AgilityCMS.Net.Sync.SDK to make use of the SyncOptions class.
- Create an object of SyncOptions class to provide values of -
- rootPath -> This will be the path where the output will be stored. This should be a physical path on your local file system.
- locale -> The locale under which your application is hosted. Example en-us.
- Create string variables of Guid (your Instance Guid) and APIKey (either defaultlive or defaultpreview value). These values can be found under Settings -> API Keys section of your organization.
- Create a boolean variable as IsPreview. A true value specifies that the application will run in preview mode else live mode. Make sure the API Key value should correspond the value of IsPreview variable.
- Create an object of SyncClient class and you may call following methods -
- SyncPages -> To sync pages.
- SyncContent -> To sync items and lists.
- ClearSync -> To delete the generated files from the application.
- GetPage -> Provide the pageId and the path where the page is generated to create an object of PageItems class. Use the store property of the object of SyncClient class to call the method.
- GetContentItem -> Provide the contentID and the path where an item is generated to create an object of ContentItems class. Use the store property of the object of SyncClient class to call the method.
- GetContentList -> Provide the referenceName and the path where a list is generated to create an object of List. Use the store property of the object of SyncClient class to call the method.
- Check out the Test project to see the functionality. Supply the values and run the tests. Refer the AgilityCMS.Net.Sync.Tests project.
- Make sure you have a
.runsettings
file with the proper configuration dotnet test -s .runsettings
- Make sure you have a
dotnet build
=> Builds your .NET project.dotnet run
=> Builds & runs your .NET project.dotnet clean
=> Cleans the build outputs of your .NET project.
If you have feedback or questions about this starter, please use the Github Issues on this repo, join our Community Slack Channel or create a post on the Agility Developer Community.