///////////////////////////////////////////////////////////////// // AttribLib.h - demonstrates how to use {Developer] attribute // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2003 // ///////////////////////////////////////////////////////////////// // Build Process: // // Required Files: // AttribLib.h, AttribLib.cpp, Stdafx.h, Stdafx.h, // AssemblyInfo.cpp, AttribDef.dll // // To Build: // - AttribDef.dll needs to be in the AttribLib\debug folder // - build ///////////////////////////////////////////////////////////////// #pragma once using namespace System; using namespace System::Text; #using "../AttribDef/Debug/AttribDef.dll" using namespace AttribDef; namespace AttribLib { [DeveloperAttribute("Jim Fawcett")] public ref class Test { public: String^ say() { StringBuilder^ pTemp = gcnew StringBuilder("a test case for "); pTemp->Append(getDeveloper()); return pTemp->ToString(); } //----< extract developer name from metadata >------------------- String^ getDeveloper() { Type^ pType = GetType(); array^ pObjs = Attribute::GetCustomAttributes(pType); for(int i=0; iLength; ++i) { if(pObjs[i]->GetType()->Equals(DeveloperAttribute::typeid)) { String^ dev = static_cast(pObjs[i])->Developer; return dev; } } return "not found"; } }; }