#pragma once
#include \ using namespace System; namespace NAoWrapper { }
public ref class RefAoWrapper { };
// TODO: Add your methods for this class here. AoHelper *ao; int line_test(); RefAoWrapper(); ~RefAoWrapper(); private: public:
修改NAoWrapper.cpp
// This is the main DLL file.
#include \ #include \
using namespace System::Diagnostics;
namespace NAoWrapper {
int RefAoWrapper ::line_test() {
Stopwatch^ watch=gcnew Stopwatch(); watch->Start();
RefAoWrapper::~RefAoWrapper() { }
delete ao;
RefAoWrapper::RefAoWrapper() { }
ao=new AoHelper();
}
}
ao->line_test(); watch->Stop();
Console::WriteLine(watch->ElapsedMilliseconds); return 0;
5 添加新项目,命名为CSharpAoHeleper,C#直接调用ArcObjects
添加ESRI.ArcGIS.相关引用
将Class1.cs重命名为CSharpAoHeleper,代码如下
using System;
using System.Collections.Generic; using System.Linq; using System.Text;
using ESRI.ArcGIS.Geometry; using System.Diagnostics;
namespace CSharpAoHeleper {
public class CSharpAoHeleper {
public int line_test() {
IPoint ipPt1 = new PointClass(); IPoint ipPt2 = new PointClass(); ipPt1.PutCoords(1, 2); ipPt2.PutCoords(2, 3);
ILine ipLine = new LineClass();
Stopwatch watch = new Stopwatch(); watch.Start();
for (long i = 0; i <= 10000000; i++) {
ipLine.PutCoords(ipPt1, ipPt2); //Console::WriteLine(i); }
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);
return 0; } } }
编译,完成C#直接操作AO封装库
6 添加新项目,命名为Test
右键项目属性,修改输出路径(Output path):即AoWrapperDemo\\Debug目录
添加ESRI.AcrGIS.相关引用 添加项目引用
修改Program.cs
using System; using ESRI.ArcGIS;
using ESRI.ArcGIS.esriSystem;
namespace Test {
static class Program {
///
/// The main entry point for the application. /// [STAThread]
static void Main() {
if (!RuntimeManager.Bind(ProductCode.Engine))
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新高中教育C++CLI调用ArcObjects (3)全文阅读和word下载服务。
相关推荐: