/// <summary> /// Sets the value of the specified property on this node. /// </summary> /// <param name="propertyId">The Id of the property to set.</param> /// <param name="value">The value to set.</param> /// <returns> /// An HRESULT that is the result of the operation. Usually S_OK indicates that the property was set. /// If the property is not supported, returns DISP_E_MEMBERNOTFOUND. /// </returns> public virtual int SetProperty(__VSHPROPID propertyId, object value) { int hr = NativeMethods.S_OK; // Get the property from the node. switch (propertyId) { case __VSHPROPID.VSHPROPID_Caption: case __VSHPROPID.VSHPROPID_EditLabel: if (this.CaptionEditable) { hr = this.SetCaption((string)value); } break; case __VSHPROPID.VSHPROPID_Expanded: this.Expanded = (bool)value; break; case __VSHPROPID.VSHPROPID_ItemDocCookie: this.SetDocumentCookie((uint)value); break; default: hr = NativeMethods.DISP_E_MEMBERNOTFOUND; break; } return(hr); }
// ========================================================================================= // Methods // ========================================================================================= /// <summary> /// Sets the node property. /// </summary> /// <param name="propid">Property id.</param> /// <param name="value">Property value.</param> /// <returns>Returns success or failure code.</returns> public override int SetProperty(int propid, object value) { int result; __VSHPROPID id = (__VSHPROPID)propid; switch (id) { case __VSHPROPID.VSHPROPID_IsNonMemberItem: if (value == null) { throw new ArgumentNullException("value"); } bool boolValue = false; CCITracing.TraceCall(this.ID + "," + id.ToString()); if (bool.TryParse(value.ToString(), out boolValue)) { this.isNonMemberItem = boolValue; } else { WixHelperMethods.TraceFail("Could not parse the IsNonMemberItem property value."); } result = VSConstants.S_OK; break; default: result = base.SetProperty(propid, value); break; } return(result); }
public static object GetProp(this IVsHierarchy hierarchy, uint currentItem, __VSHPROPID prop) { object obj; hierarchy.GetProperty(currentItem, (int)prop, out obj); return(obj); }
// ------------------------------------------------------ /// <summary> /// Gets the value of a property of this hierarchy item. /// </summary> /// <param name="prop"> /// The property to obtain. /// </param> /// <returns> /// The value of the property. /// </returns> private object GetProperty(__VSHPROPID prop) { object result; hierarchy.GetProperty(itemID, (int)prop, out result); return(result); }
/// <summary> /// Sets the value of the specified property on this node. /// </summary> /// <param name="hierarchyId">The unique identifier of the node.</param> /// <param name="propertyId">The Id of the property to set.</param> /// <param name="value">The value to set.</param> /// <returns> /// An HRESULT that is the result of the operation. Usually S_OK indicates that the property was set. /// If the property is not supported, returns DISP_E_MEMBERNOTFOUND. /// </returns> public override int SetProperty(uint hierarchyId, __VSHPROPID propertyId, object value) { int hr = NativeMethods.S_OK; switch (propertyId) { case __VSHPROPID.VSHPROPID_ProjectIDGuid: this.ProjectGuid = (Guid)value; break; default: hr = NativeMethods.DISP_E_MEMBERNOTFOUND; break; } if (NativeMethods.Succeeded(hr)) { this.IncrementSupportedSetProperty(propertyId); } else { // Let the base class do its stuff. hr = base.SetProperty(hierarchyId, propertyId, value); } return(hr); }
// ------------------------------------------------------ /// <summary> /// Gets the value of a GUID property of this hierarchy item. /// </summary> /// <param name="prop"> /// The property to obtain. /// </param> /// <returns> /// The value of the property. /// </returns> private Guid GetGuidProperty(__VSHPROPID prop) { Guid result; hierarchy.GetGuidProperty(itemID, (int)prop, out result); return(result); }
/// <summary> /// Notifies all of our event listeners that an item in the hierarchy has changed. /// </summary> /// <param name="node">The <see cref="Node"/> that has changed.</param> /// <param name="propertyId">The property that has changed.</param> public void OnPropertyChanged(Node node, __VSHPROPID propertyId) { Tracer.VerifyNonNullArgument(node, "node"); object newValue; node.GetProperty(propertyId, out newValue); // There are some cases where the collection is changed while we're iterating it. // To be safe, we'll create a copy of the collection and iterate over that. // We just want a shallow copy, though, and not a deep (Clone) copy. ArrayList clone = new ArrayList(this.Values); for (int i = 0; i < clone.Count; i++) { IVsHierarchyEvents eventItem = (IVsHierarchyEvents)clone[i]; Tracer.WriteLineVerbose(classType, "OnPropertyChanged", "Notifying event listener {0} that '{1}' has changed its {2} property to '{3}'.", this.CookieOf(i), node.Caption, propertyId, newValue); try { eventItem.OnPropertyChanged(node.HierarchyId, (int)propertyId, 0); } catch (Exception e) { Tracer.WriteLineWarning(classType, "OnPropertyChanged", "There was an exception in the event listener {0} event handling code: {1}", this.CookieOf(i), e.ToString()); } } }
public static bool TryGetGuidProperty( this IVsHierarchy hierarchy, __VSHPROPID propertyId, out Guid guid ) => ErrorHandler.Succeeded( hierarchy.GetGuidProperty(VSConstants.VSITEMID_ROOT, (int)propertyId, out guid) );
private static T GetProperty<T>(IVsHierarchy hier, __VSHPROPID propertyId) { object propertyValue; hier.GetProperty( (uint)VSConstants.VSITEMID.Root, (int)propertyId, out propertyValue); return (T)propertyValue; }
private static object GetProperty(IVsHierarchy vsHierarchy, __VSHPROPID key, uint vsItemId) { ThreadHelper.ThrowIfNotOnUIThread(); object value = null; bool success = PackageHelper.Success(vsHierarchy.GetProperty(vsItemId, Convert.ToInt32(key), out value)); return(success ? value : null); }
private bool HasProperty(__VSHPROPID propId) { int hr = _hierarchy.GetProperty(_itemId, (int)propId, out object value); if (hr != VSConstants.S_OK || value == null) { return(false); } return(true); }
private object GetProperty(__VSHPROPID propid) { ThreadHelper.ThrowIfNotOnUIThread(); if (TryGetProperty((int)propid, out var value)) { return(value); } return(null); }
/// <include file='doc\HierarchyItem.uex' path='docs/doc[@for="HierarchyItemNode.GetProperty"]/*' /> /// <summary> /// return our dispinterface for properties here... /// </summary> public override object GetProperty(int propId) { __VSHPROPID id = (__VSHPROPID)propId; /* switch (id) { case __VSHPROPID.VSHPROPID_SelContainer: return new SelectionContainer(this); } */ return base.GetProperty(propId); }
// ------------------------------------------------------------------- /// <summary> /// Gets a GUID value of a property of this hierarchy item. /// </summary> /// <remarks> /// See the description of the indexing operator to see how the names /// for the properties are derived. /// </remarks> /// <param name="property"> /// The name of the property to be accessed. /// </param> /// <returns> /// The value of the property, as a Guid. /// </returns> public Guid GetGuid(string property) { Guid result; __VSHPROPID propID = (__VSHPROPID)Enum.Parse(typeof(__VSHPROPID), "VSHPROPID_" + property, true); hierarchy.GetGuidProperty(itemID, (int)propID, out result); return(result); }
private static bool TryGetItemNextId(IVsHierarchy hierarchy, uint itemId, __VSHPROPID property, out uint nextId) { object value = null; var result = TryGetItemProperty(hierarchy, itemId, property, out value); nextId = result ? (uint)(int)value : VSConstants.VSITEMID_NIL; return(result); }
private T GetProperty <T>(__VSHPROPID propId, uint itemid) { int hr = _hierarchy.GetProperty(itemid, (int)propId, out object value); if (hr != VSConstants.S_OK || value == null) { return(default(T)); } return((T)value); }
private object GetProperty(__VSHPROPID propid) { object value = null; if (TryGetProperty((int)propid, out value)) { return(value); } return(null); }
public static T GetProp <T>(this IVsHierarchy hierarchy, uint itemid, __VSHPROPID propid) { object tmp; hierarchy.GetProperty(itemid, (int)propid, out tmp); if (tmp != null) { return((T)tmp); } return(default(T)); }
private static T GetProperty <T>(IVsHierarchy hierarchy, __VSHPROPID propId, uint itemid) { object value = null; int hr = hierarchy.GetProperty(itemid, (int)propId, out value); if (hr != VSConstants.S_OK || value == null) { return(default(T)); } return((T)value); }
/// <summary> /// Gets the node property. /// </summary> /// <param name="propId">Property id.</param> /// <returns>The property value.</returns> public override object GetProperty(int propId) { __VSHPROPID id = (__VSHPROPID)propId; switch (id) { case __VSHPROPID.VSHPROPID_IsNonMemberItem: return(this.IsNonMemberItem); } return(base.GetProperty(propId)); }
private Guid GetGuidProperty(__VSHPROPID propId, uint itemid = VSConstants.VSITEMID_ROOT) { int hr = _hierarchy.GetGuidProperty(itemid, (int)propId, out Guid guid); // in case of failure, we simply trace the error and return silently with an empty guid // so the caller can resolve what to do without blowing out execution with an exception if (hr != 0) { Trace.TraceError(Marshal.GetExceptionForHR(hr).ToString()); } return(guid); }
HierarchyItem RelativeItem(__VSHPROPID propid) { object val; _hierarchy.GetProperty(_itemId, (int)propid, out val); uint itemId = (uint)(int)val; if (itemId == uint.MaxValue) { return(null); } return(new HierarchyItem(_hierarchy, itemId)); }
// ------------------------------------------------------------------- /// <summary> /// Gets the value of a property of this hierarchy item. /// </summary> /// <remarks> /// The name of the property is derived from the values in the /// __VSHPROPID enumeration by removing the VSHPROPID_ prefix. For /// example, to get the value of the __VSHPROPID.VSHPROPID_Name /// property, you would pass "Name" as the property parameter to this /// accessor. /// /// If the value of the property to be accessed is a GUID, use the /// GetGuid method instead of this accessor. /// </remarks> /// <param name="property"> /// The name of the property to be accessed. /// </param> /// <returns> /// The value of the property. /// </returns> public object this[string property] { get { object result; __VSHPROPID propID = (__VSHPROPID)Enum.Parse(typeof(__VSHPROPID), "VSHPROPID_" + property, true); hierarchy.GetProperty(itemID, (int)propID, out result); return(result); } }
/// <summary> /// return our dispinterface for properties here... /// </summary> public override object GetProperty(int propId) { __VSHPROPID id = (__VSHPROPID)propId; switch (id) { case __VSHPROPID.VSHPROPID_SelContainer: return new SelectionContainer(this); /* case __VSHPROPID.VSHPROPID_BrowseObject: return new NodeProperties(this);//Marshal.GetIDispatchForObject(this); */ } return base.GetProperty(propId); }
public static void DisplayProps(this IVsHierarchy hierarchy, uint currentItem, __VSHPROPID prop) { Debug.WriteLine(">>>" + prop); object obj = GetProp(hierarchy, currentItem, prop); var extObjectProps = TypeDescriptor.GetProperties(obj); foreach (PropertyDescriptor x in extObjectProps) { var value = x.GetValue(obj); Debug.WriteLine(" Name='" + x.Name + "' Description='" + x.Description + "' DisplayName='" + x.DisplayName + "' Value='" + value + "'"); } Debug.WriteLine("<<<" + prop); }
public IEnumerable <HierarchyNode> GetChildren(bool visibleNodesOnly) { __VSHPROPID propertyId = visibleNodesOnly ? __VSHPROPID.VSHPROPID_FirstVisibleChild : __VSHPROPID.VSHPROPID_FirstChild; object propertyValue = this.GetProperty(propertyId); uint childId = GetItemId(propertyValue); while (childId != VSConstants.VSITEMID_NIL) { yield return(new HierarchyNode(this.Hierarchy, childId)); propertyId = visibleNodesOnly ? __VSHPROPID.VSHPROPID_NextVisibleSibling : __VSHPROPID.VSHPROPID_NextSibling; propertyValue = GetProperty <__VSHPROPID, object>(this.Hierarchy, childId, propertyId); childId = GetItemId(propertyValue); } }
/// <summary> /// Gets the node property. /// </summary> /// <param name="propId">Property id.</param> /// <returns>The property value.</returns> public override object GetProperty(int propId) { ThreadHelper.ThrowIfNotOnUIThread(); __VSHPROPID id = (__VSHPROPID)propId; switch (id) { case __VSHPROPID.VSHPROPID_IsNonMemberItem: return(this.IsNonMemberItem); case __VSHPROPID.VSHPROPID_DefaultNamespace: return(this.ProjectMgr.GetProperty(propId)); } return(base.GetProperty(propId)); }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="hierarchyId">The Id of the hierarchy node from which to retrieve the property.</param> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public override bool GetProperty(uint hierarchyId, __VSHPROPID propertyId, out object propertyValue) { bool supported = true; propertyValue = null; switch (propertyId) { case __VSHPROPID.VSHPROPID_ConfigurationProvider: propertyValue = this.ConfigurationProvider; break; case __VSHPROPID.VSHPROPID_DefaultEnableBuildProjectCfg: // Specifies whether "Build" should be initially checked by default in the solution cfg. // Normally "Build" is checked by default if the project supports IVsBuildableProjectCfg. propertyValue = true; break; case __VSHPROPID.VSHPROPID_ProjectDir: propertyValue = this.RootDirectory; break; case __VSHPROPID.VSHPROPID_ProjectIDGuid: propertyValue = this.ProjectGuid; break; case __VSHPROPID.VSHPROPID_TypeName: propertyValue = this.NativeResources.GetString(ResId.IDS_OFFICIALNAME); break; default: supported = false; break; } if (supported) { this.IncrementSupportedGetProperty(propertyId); } else { // Let the base class have a chance to get the property. supported = base.GetProperty(hierarchyId, propertyId, out propertyValue); } return(supported); }
/// <summary> /// Gets properties of a given node or of the hierarchy. /// </summary> /// <param name="propId">Identifier of the hierarchy property</param> /// <returns>It return an object which type is dependent on the propid.</returns> public override object GetProperty(int propId) { __VSHPROPID vshPropId = (__VSHPROPID)propId; switch (vshPropId) { default: return(base.GetProperty(propId)); case __VSHPROPID.VSHPROPID_Expandable: return(true); case __VSHPROPID.VSHPROPID_BrowseObject: case __VSHPROPID.VSHPROPID_HandlesOwnReload: return(this.DelegateGetPropertyToNested(propId)); } }
public int GetGuidProperty(uint itemid, int propid, out Guid pguid) { __VSHPROPID vshPropId = (__VSHPROPID)propid; switch (vshPropId) { case __VSHPROPID.VSHPROPID_ProjectIDGuid: if (itemid == VSConstants.VSITEMID_ROOT) { pguid = Guid; return(VSConstants.S_OK); } break; case __VSHPROPID.VSHPROPID_TypeGuid: if (itemid == VSConstants.VSITEMID_ROOT) { pguid = TypeGuid; } else if (IsProject(itemid)) { pguid = GetProject(itemid).TypeGuid; } else if (IsChild(itemid)) { pguid = VSConstants.GUID_ItemType_PhysicalFile; } else if (IsFolder(itemid)) { pguid = VSConstants.GUID_ItemType_PhysicalFolder; } else { pguid = Guid.Empty; return(VSConstants.S_FALSE); } return(VSConstants.S_OK); } pguid = Guid.Empty; return(VSConstants.DISP_E_MEMBERNOTFOUND); }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public override bool GetProperty(__VSHPROPID propertyId, out object propertyValue) { bool supported = true; propertyValue = null; // Get the property from the node. switch (propertyId) { case __VSHPROPID.VSHPROPID_OpenFolderIconHandle: propertyValue = this.GetImageHandle(this.OpenImage); break; default: supported = base.GetProperty(propertyId, out propertyValue); break; } return(supported); }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public virtual bool GetProperty(__VSHPROPID propertyId, out object propertyValue) { propertyValue = null; bool supported = true; // Get the property from the node. switch (propertyId) { case __VSHPROPID.VSHPROPID_BrowseObject: if (this.Properties != null) { propertyValue = new DispatchWrapper(this.Properties); } break; case __VSHPROPID.VSHPROPID_Caption: propertyValue = this.Caption; break; case __VSHPROPID.VSHPROPID_ItemDocCookie: // We cast it to an IntPtr because some callers expect a VT_INT propertyValue = (IntPtr)this.DocumentCookie; break; case __VSHPROPID.VSHPROPID_EditLabel: if (this.CaptionEditable) { propertyValue = this.Caption; } else { supported = false; } break; case __VSHPROPID.VSHPROPID_Expandable: propertyValue = this.Expandable; break; case __VSHPROPID.VSHPROPID_ExpandByDefault: propertyValue = this.ExpandByDefault; break; case __VSHPROPID.VSHPROPID_Expanded: propertyValue = this.Expanded; break; case __VSHPROPID.VSHPROPID_FirstChild: case __VSHPROPID.VSHPROPID_FirstVisibleChild: propertyValue = (this.FirstChild != null ? this.FirstChild.HierarchyId : NativeMethods.VSITEMID_NIL); break; case __VSHPROPID.VSHPROPID_IconHandle: propertyValue = this.GetImageHandle(this.Image); if ((IntPtr)propertyValue == IntPtr.Zero) { supported = false; propertyValue = null; } break; case __VSHPROPID.VSHPROPID_Name: propertyValue = this.Caption; break; case __VSHPROPID.VSHPROPID_NextSibling: case __VSHPROPID.VSHPROPID_NextVisibleSibling: propertyValue = (this.NextSibling != null ? this.NextSibling.HierarchyId : NativeMethods.VSITEMID_NIL); break; case __VSHPROPID.VSHPROPID_Parent: propertyValue = (this.Parent != null ? this.Parent.HierarchyId : NativeMethods.VSITEMID_NIL); break; case __VSHPROPID.VSHPROPID_SaveName: propertyValue = this.SaveName; break; case __VSHPROPID.VSHPROPID_TypeGuid: propertyValue = this.VisualStudioTypeGuid; break; default: supported = false; break; } return supported; }
/// <summary> /// Sets the value of the specified property on this node. /// </summary> /// <param name="propertyId">The Id of the property to set.</param> /// <param name="value">The value to set.</param> /// <returns> /// An HRESULT that is the result of the operation. Usually S_OK indicates that the property was set. /// If the property is not supported, returns DISP_E_MEMBERNOTFOUND. /// </returns> public virtual int SetProperty(__VSHPROPID propertyId, object value) { int hr = NativeMethods.S_OK; // Get the property from the node. switch (propertyId) { case __VSHPROPID.VSHPROPID_Caption: case __VSHPROPID.VSHPROPID_EditLabel: if (this.CaptionEditable) { hr = this.SetCaption((string)value); } break; case __VSHPROPID.VSHPROPID_Expanded: this.Expanded = (bool)value; break; case __VSHPROPID.VSHPROPID_ItemDocCookie: this.SetDocumentCookie((uint)value); break; default: hr = NativeMethods.DISP_E_MEMBERNOTFOUND; break; } return hr; }
/// <summary> /// Calls the <b>Hierarchy.OnPropertyChanged</b> method. /// </summary> /// <param name="propId">The property Id that changed.</param> protected void OnPropertyChanged(__VSHPROPID propId) { this.MakeDirty(); this.Hierarchy.OnPropertyChanged(this, propId); }
private static bool TryGetItemNextId(IVsHierarchy hierarchy, uint itemId, __VSHPROPID property, out uint nextId) { object value = null; var result = TryGetItemProperty(hierarchy, itemId, property, out value); nextId = result ? (uint)(int)value : VSConstants.VSITEMID_NIL; return result; }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="hierarchyId">The Id of the hierarchy node from which to retrieve the property.</param> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public virtual bool GetProperty(uint hierarchyId, __VSHPROPID propertyId, out object propertyValue) { bool supported = true; Node node = null; propertyValue = null; // First we'll catch any properties that we're interested in. switch (propertyId) { case __VSHPROPID.VSHPROPID_Root: propertyValue = this.RootNode.HierarchyId; break; default: supported = false; break; } // If we didn't catch the property, then let's let the node have a chance to deal with it. if (!supported) { // Get the hierarchy node. if (hierarchyId == NativeMethods.VSITEMID_NIL) { // We can't return a property on a null node. We won't do anything here, // but we'll make sure that we don't do anything on our null node below. } else if (hierarchyId == NativeMethods.VSITEMID_SELECTION) { node = this.SelectedNode; } else { // Attempt to find the node in our hierarchy (don't throw if we can't find it). node = this.GetNode(hierarchyId, false); } // Let the node handle the property. if (node != null) { supported = node.GetProperty(propertyId, out propertyValue); } } // Increment our counters that are used in the trace summary. if (supported) { this.IncrementSupportedGetProperty(propertyId); } else { this.IncrementUnsupportedGetProperty(propertyId); } return supported; }
private void IncrementPropertyCount(__VSHPROPID propertyId, Hashtable hashtable) { if (hashtable.ContainsKey(propertyId)) { int count = (int)hashtable[propertyId]; hashtable[propertyId] = ++count; } else { hashtable.Add(propertyId, 1); } }
public object GetProperty(__VSHPROPID vsPropID) { object objOut = null; m_vsHierarchy.GetProperty((uint)m_vsItemID, (int)vsPropID, out objOut); return objOut; }
/// <summary> /// Sets the value of the specified property. /// </summary> /// <param name="hierarchyId">The Id of the hierarchy node on which to set the property.</param> /// <param name="propertyId">The Id of the property to set.</param> /// <param name="value">The value to set.</param> /// <returns> /// An HRESULT that is the result of the operation. Usually S_OK indicates that the property was set. /// If the property is not supported, returns DISP_E_MEMBERNOTFOUND. /// </returns> public virtual int SetProperty(uint hierarchyId, __VSHPROPID propertyId, object value) { int hr; Node node = null; // Get the hierarchy node. if (hierarchyId == NativeMethods.VSITEMID_NIL) { this.IncrementUnsupportedSetProperty(propertyId); return NativeMethods.DISP_E_MEMBERNOTFOUND; } else if (hierarchyId == NativeMethods.VSITEMID_SELECTION) { node = this.SelectedNode; } else { // Attempt to find the node in our hierarchy (throw if we can't find it). node = this.GetNode(hierarchyId, true); } Tracer.Assert(node != null, "node should not have been null by this point."); hr = node.SetProperty(propertyId, value); if (NativeMethods.Succeeded(hr)) { this.IncrementSupportedSetProperty(propertyId); } else { this.IncrementUnsupportedSetProperty(propertyId); } return hr; }
public void OnPropertyChanged(Node node, __VSHPROPID propertyId) { // Let all of our listeners know that an item was changed. this.eventListeners.OnPropertyChanged(node, propertyId); }
private static bool TryGetItemProperty(IVsHierarchy hierarchy, uint itemId, __VSHPROPID property, out object value) { return ErrorHandler.Succeeded(hierarchy.GetProperty(itemId, (int)property, out value)); }
public static object GetProp(this IVsHierarchy hierarchy, uint currentItem, __VSHPROPID prop) { object obj; hierarchy.GetProperty(currentItem, (int)prop, out obj); return obj; }
private static uint GetReleativeItemId(this IVsHierarchy hierarchy, uint referenceItemId, __VSHPROPID relativeType) { object relative; hierarchy.GetProperty(referenceItemId, (int) relativeType, out relative); return relative == null ? (uint)VSConstants.VSITEMID.Nil : (uint)(int)relative; }
/// <summary> /// Sets the value of the specified property on this node. /// </summary> /// <param name="hierarchyId">The unique identifier of the node.</param> /// <param name="propertyId">The Id of the property to set.</param> /// <param name="value">The value to set.</param> /// <returns> /// An HRESULT that is the result of the operation. Usually S_OK indicates that the property was set. /// If the property is not supported, returns DISP_E_MEMBERNOTFOUND. /// </returns> public override int SetProperty(uint hierarchyId, __VSHPROPID propertyId, object value) { int hr = NativeMethods.S_OK; switch (propertyId) { case __VSHPROPID.VSHPROPID_ProjectIDGuid: this.ProjectGuid = (Guid)value; break; default: hr = NativeMethods.DISP_E_MEMBERNOTFOUND; break; } if (NativeMethods.Succeeded(hr)) { this.IncrementSupportedSetProperty(propertyId); } else { // Let the base class do its stuff. hr = base.SetProperty(hierarchyId, propertyId, value); } return hr; }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public override bool GetProperty(__VSHPROPID propertyId, out object propertyValue) { bool supported = true; propertyValue = null; // Get the property from the node. switch (propertyId) { case __VSHPROPID.VSHPROPID_OpenFolderIconHandle: propertyValue = this.GetImageHandle(this.OpenImage); break; default: supported = base.GetProperty(propertyId, out propertyValue); break; } return supported; }
protected void IncrementUnsupportedSetProperty(__VSHPROPID propertyId) { this.IncrementPropertyCount(propertyId, this.unsupportedSets); }
/// <summary> /// Gets the value of the specified property. /// </summary> /// <param name="hierarchyId">The Id of the hierarchy node from which to retrieve the property.</param> /// <param name="propertyId">The Id of the property to retrieve.</param> /// <param name="propertyValue">The value of the specified property, or null if the property is not supported.</param> /// <returns>true if the property is supported; otherwise false.</returns> public override bool GetProperty(uint hierarchyId, __VSHPROPID propertyId, out object propertyValue) { bool supported = true; propertyValue = null; switch (propertyId) { case __VSHPROPID.VSHPROPID_ConfigurationProvider: propertyValue = this.ConfigurationProvider; break; case __VSHPROPID.VSHPROPID_DefaultEnableBuildProjectCfg: // Specifies whether "Build" should be initially checked by default in the solution cfg. // Normally "Build" is checked by default if the project supports IVsBuildableProjectCfg. propertyValue = true; break; case __VSHPROPID.VSHPROPID_ProjectDir: propertyValue = this.RootDirectory; break; case __VSHPROPID.VSHPROPID_ProjectIDGuid: propertyValue = this.ProjectGuid; break; case __VSHPROPID.VSHPROPID_TypeName: propertyValue = this.NativeResources.GetString(ResId.IDS_OFFICIALNAME); break; default: supported = false; break; } if (supported) { this.IncrementSupportedGetProperty(propertyId); } else { // Let the base class have a chance to get the property. supported = base.GetProperty(hierarchyId, propertyId, out propertyValue); } return supported; }