in vsintegration/src/FSharp.ProjectSystem.Base/Project/HierarchyNode.cs [626:816]
public virtual object GetProperty(int propId)
{
object result = null;
switch ((__VSHPROPID)propId)
{
case __VSHPROPID.VSHPROPID_Expandable:
result = (this.firstChild != null);
break;
case __VSHPROPID.VSHPROPID_Caption:
result = this.Caption;
break;
case __VSHPROPID.VSHPROPID_Name:
result = this.Caption;
break;
case __VSHPROPID.VSHPROPID_ExpandByDefault:
result = false;
break;
case __VSHPROPID.VSHPROPID_IconImgList:
result = this.ProjectMgr.ImageHandler.ImageList.Handle;
break;
case __VSHPROPID.VSHPROPID_OpenFolderIconIndex:
case __VSHPROPID.VSHPROPID_IconIndex:
int index = this.ImageIndex;
if (index != NoImage)
{
result = index;
}
break;
case __VSHPROPID.VSHPROPID_StateIconIndex:
result = (int)this.StateIconIndex;
break;
case __VSHPROPID.VSHPROPID_IconHandle:
result = GetIconHandle(false);
break;
case __VSHPROPID.VSHPROPID_OpenFolderIconHandle:
result = GetIconHandle(true);
break;
case __VSHPROPID.VSHPROPID_NextVisibleSibling:
goto case __VSHPROPID.VSHPROPID_NextSibling;
case __VSHPROPID.VSHPROPID_NextSibling:
result = (int)((this.nextSibling != null) ? this.nextSibling.hierarchyId : VSConstants.VSITEMID_NIL);
break;
case __VSHPROPID.VSHPROPID_IsNonMemberItem:
result = IsNonMemberItem;
break;
case __VSHPROPID.VSHPROPID_FirstChild:
goto case __VSHPROPID.VSHPROPID_FirstVisibleChild;
case __VSHPROPID.VSHPROPID_FirstVisibleChild:
result = (int)((this.firstChild != null) ? this.firstChild.hierarchyId : VSConstants.VSITEMID_NIL);
break;
case __VSHPROPID.VSHPROPID_Parent:
if (this.parentNode != null)
result = new IntPtr(unchecked((int)this.parentNode.hierarchyId));
else
result = new IntPtr(unchecked((int)VSConstants.VSITEMID_NIL)); // VS wants VT_INT_PTR or VT_INT
break;
case __VSHPROPID.VSHPROPID_ParentHierarchyItemid:
if (parentHierarchy != null)
{
result = (IntPtr)parentHierarchyItemId; // VS requires VT_I4 | VT_INT_PTR
}
break;
case __VSHPROPID.VSHPROPID_ParentHierarchy:
result = parentHierarchy;
break;
case __VSHPROPID.VSHPROPID_Root:
// Why return IntPtr? Return this.projectMgr and let COM do all the marshalling?
// (as in the above case of parentHierarchy)
// Here is why: Because the project can be aggregated by a flavor, we need to make sure
// we get the outer most implementation of that interface (hence: project --> IUnknown)
result = Marshal.GetIUnknownForObject(this.projectMgr);
break;
case __VSHPROPID.VSHPROPID_Expanded:
result = this.isExpanded;
break;
case __VSHPROPID.VSHPROPID_BrowseObject:
result = this.NodeProperties;
if (result != null) result = new DispatchWrapper(result);
break;
case __VSHPROPID.VSHPROPID_EditLabel:
if (this.ProjectMgr != null && !this.ProjectMgr.IsClosed && !this.ProjectMgr.IsCurrentStateASuppressCommandsMode())
{
result = GetEditLabel();
}
break;
case __VSHPROPID.VSHPROPID_SaveName:
//SaveName is the name shown in the Save and the Save Changes dialog boxes.
result = this.Caption;
break;
case __VSHPROPID.VSHPROPID_ItemDocCookie:
if (this.docCookie != 0) return (IntPtr)this.docCookie; //cast to IntPtr as some callers expect VT_INT
break;
case __VSHPROPID.VSHPROPID_ExtObject:
result = GetAutomationObject();
break;
}
__VSHPROPID2 id2 = (__VSHPROPID2)propId;
switch (id2)
{
case __VSHPROPID2.VSHPROPID_NoDefaultNestedHierSorting:
return true; // We are doing the sorting ourselves through VSHPROPID_FirstChild and VSHPROPID_NextSibling
case __VSHPROPID2.VSHPROPID_BrowseObjectCATID:
{
// If there is a browse object and it is a NodeProperties, then get it's CATID
object browseObject = this.GetProperty((int)__VSHPROPID.VSHPROPID_BrowseObject);
if (browseObject != null)
{
if (browseObject is DispatchWrapper)
browseObject = ((DispatchWrapper)browseObject).WrappedObject;
result = this.ProjectMgr.GetCATIDForType(browseObject.GetType()).ToString("B");
if (String.CompareOrdinal(result as string, Guid.Empty.ToString("B")) == 0)
result = null;
}
break;
}
case __VSHPROPID2.VSHPROPID_ExtObjectCATID:
{
// If there is a extensibility object and it is a NodeProperties, then get it's CATID
object extObject = this.GetProperty((int)__VSHPROPID.VSHPROPID_ExtObject);
if (extObject != null)
{
if (extObject is DispatchWrapper)
extObject = ((DispatchWrapper)extObject).WrappedObject;
result = this.ProjectMgr.GetCATIDForType(extObject.GetType()).ToString("B");
if (String.CompareOrdinal(result as string, Guid.Empty.ToString("B")) == 0)
result = null;
}
break;
}
}
if ((__VSHPROPID4)propId == __VSHPROPID4.VSHPROPID_TargetFrameworkMoniker)
{
result = GetTargetFrameworkMoniker();
}
else if ((__VSHPROPID3)propId == __VSHPROPID3.VSHPROPID_TargetFrameworkVersion)
{
result = GetTargetFrameworkVersion();
}
if (propId == (int)__VSHPROPID5.VSHPROPID_TargetRuntime)
{
// Indicates what runtime the project targets
result = (UInt32)__VSPROJTARGETRUNTIME.VSPROJ_TARGETRUNTIME_MANAGED;
}
if (propId == (int)__VSHPROPID5.VSHPROPID_TargetPlatformIdentifier)
{
// Indicates the target platform (e.g., Windows, Portable, or WindowsPhone)
result = this.ProjectMgr.GetProjectProperty("TargetPlatformIdentifier");
}
if (propId == (int)__VSHPROPID5.VSHPROPID_ProvisionalViewingStatus)
{
// Indicates that the node support previewing
result = ProvisionalViewingStatus;
}
#if DEBUG
if (propId != LastTracedProperty)
{
string trailer = (result == null) ? "null" : result.ToString();
CCITracing.TraceCall(this.hierarchyId + "," + propId.ToString() + " = " + trailer);
LastTracedProperty = propId; // some basic filtering here...
}
#endif
return result;
}