Create Method (IItemFactory)
Defines the factory create method all factories must implement.
Add a folder connection item to the current project
//Adding a folder connection
string folderPath = "@C:\\myDataFolder";
var folder = await QueuedTask.Run(() =>
{
//Create the folder connection project item
var item = ItemFactory.Instance.Create(folderPath) as IProjectItem;
//If it is successfully added to the project, return it otherwise null
return Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null;
});
//Adding a Geodatabase:
string gdbPath = "@C:\\myDataFolder\\myData.gdb";
var newlyAddedGDB = await QueuedTask.Run(() =>
{
//Create the File GDB project item
var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem;
//If it is successfully added to the project, return it otherwise null
return Project.Current.AddItem(item) ? item as GDBProjectItem : null;
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.