use crate::{dbgeng::WinResult, dbgmodel::ModelObject, *};
use windows::Win32::System::Diagnostics::Debug::Extensions::IModelPropertyAccessor;
use windy::WStr;
impl_debug_interface!(
ModelPropertyAccessor,
ModelPropertyAccessorRef,
IModelPropertyAccessor
);
pub trait ModelPropertyAccessorHandler {
fn get_value(
&self,
key: String,
context_object: &ModelObject,
) -> WinResult<ModelObject>;
fn set_value(
&self,
key: String,
context_object: &ModelObject,
value: &ModelObject,
) -> WinResult<()>;
}
impl ModelPropertyAccessor {
pub fn get_value(
&self,
key: impl AsRef<WStr>,
context_object: &ModelObject,
) -> WinResult<ModelObject> {
unsafe {
Ok(self.0.GetValue(pcw!(key), context_object.as_raw())?.into())
}
}
pub fn set_value(
&self,
key: impl AsRef<WStr>,
context_object: &ModelObject,
value: &ModelObject,
) -> WinResult<()> {
unsafe {
self.0
.SetValue(pcw!(key), context_object.as_raw(), value.as_raw())
}
}
}