K
KenWilson
I am trying to iterate through the properties of the ActiveProject. I'm
using PIA provided by Microsoft. I can get an Application instance and
retrieve the ActiveProject. I can even iterate through the PropertyInfo[]
for the property names but I cannot access the property values. When I try I
am told that my variable that holds the ProjectClass is not an object. What
I want to do is load a Dictionary object with the property names and values
as key/value pairs. Code snippets are here:
private ApplicationClass theApp;
private ProjectClass theProject;
....
public Dictionary<string, string> GetActiveProjectData()
{
if (theProject == null)
{
throw new Exception("No project has been loaded.\n"
+ "Please open a project.");
}
Type type = theProject.GetType();
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (PropertyInfo property in type.GetProperties())
{
dictionary.Add(property.Name,
property.GetValue(theProject, null).ToString());
}
public void OpenFile(....)
{
...
theProject = (ProjectClass) theApp.ActiveProject;
...
}
using PIA provided by Microsoft. I can get an Application instance and
retrieve the ActiveProject. I can even iterate through the PropertyInfo[]
for the property names but I cannot access the property values. When I try I
am told that my variable that holds the ProjectClass is not an object. What
I want to do is load a Dictionary object with the property names and values
as key/value pairs. Code snippets are here:
private ApplicationClass theApp;
private ProjectClass theProject;
....
public Dictionary<string, string> GetActiveProjectData()
{
if (theProject == null)
{
throw new Exception("No project has been loaded.\n"
+ "Please open a project.");
}
Type type = theProject.GetType();
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (PropertyInfo property in type.GetProperties())
{
dictionary.Add(property.Name,
property.GetValue(theProject, null).ToString());
}
public void OpenFile(....)
{
...
theProject = (ProjectClass) theApp.ActiveProject;
...
}