//e.g., nameOfFeatureClass = "States"
//on ArcSDE use ISqlSyntax::QualifyTableName for fully qualified table names.
public void IWorkspaceEdit_Example(IWorkspace workspace, string nameOfFeatureClass)
{
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(nameOfFeatureClass);
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
//start editing with undo redo functionality
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
IFeature feature = featureClass.GetFeature(1);
feature.Delete();
workspaceEdit.StopEditOperation();
Console.WriteLine("Would you like to undo your operation? Y or N");
string response = Console.ReadLine();
if(response.ToUpper() == "Y")
{
workspaceEdit.UndoEditOperation();
}
bool hasEdits = false;
workspaceEdit.HasEdits(ref hasEdits);
if (hasEdits)
{
Console.WriteLine("Would you like to save your edits? Y or N");
response = Console.ReadLine();
if (response.ToUpper() == "Y")
{
workspaceEdit.StopEditing(true);
}
else
{
workspaceEdit.StopEditing(false);
}
}
}
IWorkspaceEdit Example
最新推荐文章于 2021-09-02 10:33:09 发布
//IWorkspaceEdit Example