开发者

How can I use the Google page-speed SDK from C#

I would like to be able to use the Google page-speed SDK ( http://code.google.com/p/开发者_开发问答page-speed/ ) from within managed code ( C# ) I am a bit out of my depth, so if anyone can explain what I need to do that would be great.

I have come across http://www.swig.org which looks like it might be what I need, but there is so much documentation I am finding it difficult to see the wood through the trees!

Cheers,

Chris


I might have a nice alternative for you :-)

Google page speed has a nice api online. I've wrote a little class to request page speed data and presents it in a neat dataholder class.

Take a look at it here: http://schaffhauser.me/Development.aspx#GooglePageSpeed

I provided the full C# source code and an online demo of it. And its freeware :-)


The API appears to be C++ class oriented which is not easy to be used from .Net directly.

One approach is to use swig to create a compatible library that you consumed. I've not used swig so I can't really comment on how complicated it is.

I personally would start off simply and create an native DLL that exposes a simple interface that can be used from standard pinvokes.

I would use the example test shell runner as starting point, making this into a DLL with a standard C types, export the symbol via __declspec(dllexport) and use a matching DllImport on the C# side.

http://code.google.com/p/page-speed/source/browse/bin/trunk/src/pagespeed/test_shell_runner.cc

http://msdn.microsoft.com/en-us/library/a90k134d(v=VS.100).aspx

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜