March 2007 - Posts
I use Clipboard.NET as a clipboard manager on Windows.
It stores the last few entries sent to the clipboard.
There's one problem: the default hotkey is Ctrl+Comma,
which also happens to be an important key for Outlook
(previous message).
I figured out a while ago how to change the hotkey,
but my report doesn't show up when you search for it.
Net: using a key name from the ConsoleKey table,
change the value of ShortcutKey in
%ProgramFiles%\Tom Medhurst\Clipboard.NET\clipmon32.exe.config:
<applicationSettings>
<clipmon32.Properties.Settings>
<setting name="ShortcutKey" serializeAs="String">
<value>OemComma</value>
The new hotkey will be Ctrl+keyname.
Over the last few days, I've been adapting an existing native C++ library
so that it can be called from managed code.
I had written a large number of unit tests with CppUnit
and I wanted to be able to call the tests from NUnit.
I suppose that I could have written a new CppUnit TestRunner so that I
could call it from NUnit.
Instead, I took the cheap-n-dirty route, playing with #define
and include paths.
It took less time to get working than it did to write this blog post.
Here's the original native CppUnit test code
#include <cppunit/extensions/HelperMacros.h>
class FooTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( FooTest );
CPPUNIT_TEST( testAlpha );
CPPUNIT_TEST_SUITE_END();
public:
void testAlpha();
};
#include "FooTest.h"
CPPUNIT_TEST_SUITE_REGISTRATION( FooTest );
void FooTest::testAlpha()
{
CPPUNIT_ASSERT( 4 == 2 + 2);
}
And here's my managed NUnit-based wrapper.
using namespace NUnit::Framework;
[TestFixture]
public ref class FooTest
{
public:
[Test] void testAlpha();
};
#define CPPUNIT_TEST_SUITE_REGISTRATION(x)
#define CPPUNIT_ASSERT(x) Assert::IsTrue(x)
I had to make one change to native\FooTest.cpp,
to #include <FooTest.h> (angle brackets).
This picks up the first FooTest.h in the include path,
so that the managed version of FooTest.cpp
now picks up managed\FooTest.h,
instead of the original.
In last week's tip on
using the NVelocity template formatting engine,
I described what to set to load a template from
an absolute path.
Here's the magic necessary to get NVelocity to load a template from an
embedded resource:
VelocityEngine engine = new VelocityEngine();
ExtendedProperties properties = new ExtendedProperties();
properties.AddProperty("resource.loader", "assembly");
properties.AddProperty("assembly.resource.loader.class",
"NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity");
properties.AddProperty("assembly.resource.loader.assembly", "StencilFormatter");
engine.Init(properties);
We've started using the NVelocity template formatting engine.
We were absolutely stymied for an hour, trying to figure
out how to get it working with an absolute path to the template file,
instead of the relative path shown in the documentation.
The trick is to set file.resource.loader.path.
Here's how to load C:\foo\bar\somefile.vm:
ExtendedProperties props = new ExtendedProperties();
props.AddProperty("file.resource.loader.path", new ArrayList(new string[]{".", "C:\\"}));
velocity.Init(props);
template = velocity.GetTemplate("foo\\bar\\somefile.vm");
More Posts