/***************************************************************************** * DependencyObject.h * * * * System::Windows::DependencyObject definition file * * Copyright (c) XFX Team. All rights reserved * *****************************************************************************/ #ifndef _SYSTEM_WINDOWS_DEPENDENCYOBJECT_ #define _SYSTEM_WINDOWS_DEPENDENCYOBJECT_ #include using namespace System::Collections::Generic; namespace System { namespace Windows { /** * Represents an object that participates in the dependency property system. */ class DependencyObject { private: Dictionary dependencyProperties; protected: DependencyObject(); public: template void ClearValue(DependencyProperty p) { Derived_from(); if (dependencyProperties.ContainsKey(p.Name) { // Because wrapper classes and other types may be passed in-place, // we explicitly destroy them as to prevent memory leaks. dependencyProperties[p]->~Object(); // with the Object destroyed, we can now safely remove the entry. dependencyProperties.Remove(p); } } template T GetValue(DependencyProperty p) const { Derived_from(); return dependencyProperties[p.Name]; } template void SetValue(DependencyProperty p, T value) { Derived_from(); if (!dependencyProperties.ContainsKey(p.Name)) dependencyProperties.Add(p.Name, value); else dependencyProperties[p] = value; } }; } } #endif //_SYSTEM_WINDOWS_DEPENDENCYOBJECT_