public static bool TryGetPropertyValue(this IVsShell shell, __VSSPROPID id, out IntPtr value) { var hresult = shell.GetProperty((int)id, out var objValue); if (ErrorHandler.Succeeded(hresult) && objValue != null) { value = (IntPtr.Size == 4) ? (IntPtr)(int)objValue : (IntPtr)(long)objValue; return(true); } value = default; return(false); }
private static void GetPropertyCallBack(object caller, CallbackArgs arguments) { __VSSPROPID propertyID = (__VSSPROPID)arguments.GetParameter(0); switch (propertyID) { case __VSSPROPID.VSSPROPID_IsInCommandLineMode: arguments.SetParameter(1, true); break; default: break; } arguments.ReturnValue = VSConstants.S_OK; }
private static void GetPropertyCallBack(object caller, CallbackArgs arguments) { __VSSPROPID propertyID = (__VSSPROPID)arguments.GetParameter(0); switch (propertyID) { case __VSSPROPID.VSSPROPID_IsInCommandLineMode: // fake that we are running in command line mode in order to load normally (security) arguments.SetParameter(1, true); break; default: break; } arguments.ReturnValue = VSConstants.S_OK; }
internal static bool TryGetShellProperty <T>(this IServiceProvider provider, __VSSPROPID propId, out T value) { object obj; if (ErrorHandler.Failed(provider.GetShell().GetProperty((int)propId, out obj))) { value = default(T); return(false); } try { value = (T)obj; return(true); } catch (InvalidCastException) { Debug.Fail("Expected property of type {0} but got value of type {1}".FormatUI(typeof(T).FullName, obj.GetType().FullName)); value = default(T); return(false); } }
private static bool TryGetShellProperty <T>(this IServiceProvider provider, __VSSPROPID propId, out T value) { object obj; var shell = (IVsShell)provider.GetService(typeof(SVsShell)); if (shell == null || shell.GetProperty((int)propId, out obj) != 0) { value = default(T); return(false); } try { value = (T)obj; return(true); } catch (InvalidCastException) { Debug.Fail("Expected property of type {0} but got value of type {1}".FormatUI(typeof(T).FullName, obj.GetType().FullName)); value = default(T); return(false); } }
public int OnShellPropertyChange(int propid, object var) { __VSSPROPID prop = (__VSSPROPID)propid; switch (prop) { case __VSSPROPID.VSSPROPID_Zombie: if (!(var is bool)) { break; } _zombie = (bool)var; if (!VSVersion.VS2010OrLater) { // VSSPROPID_ShellInitialized was added in VS2010. goto case VSSPROPID_ShellInitialized; } break; case VSSPROPID_ShellInitialized: if (!(var is bool)) { break; } if (!_zombie) { IAnkhServiceEvents se = GetService <IAnkhServiceEvents>(); if (se != null) { se.OnUIShellActivate(EventArgs.Empty); } } break; } return(VSErr.S_OK); }