private static void GetCurrentSelectionCallback(object caller, CallbackArgs arguments)
        {
            // Read the current selection data
            VSITEMSELECTION[] selection = (VSITEMSELECTION[])((BaseMock)caller)["Selection"];

            // Initialize output parameters for empty selection
            arguments.SetParameter(0, IntPtr.Zero);                 // hierarchyPtr
            arguments.SetParameter(1, VSConstants.VSITEMID_NIL);    // itemid
            arguments.SetParameter(2, null);                        // multiItemSelect
            arguments.SetParameter(3, IntPtr.Zero);                 // selectionContainer

            if (selection != null)
            {
                if (selection.Length == 1)
                {
                    if (selection[0].pHier != null)
                    {
                        IntPtr ptrHier = Marshal.GetComInterfaceForObject(selection[0].pHier, typeof(IVsHierarchy));
                        arguments.SetParameter(0, ptrHier);                // hierarchyPtr
                    }
                    arguments.SetParameter(1, selection[0].itemid);    // itemid
                }
                else
                {
                    // Multiple selection, return IVsMultiItemSelect interface
                    arguments.SetParameter(1, VSConstants.VSITEMID_SELECTION);    // itemid
                    arguments.SetParameter(2, caller as IVsMultiItemSelect);      // multiItemSelect
                }
            }

            arguments.ReturnValue = VSConstants.S_OK;
        }
Exemplo n.º 2
0
        private static void CreateToolWindowNegativeTestCallBack(object caller, CallbackArgs arguments)
        {
            arguments.ReturnValue = VSConstants.S_OK;

            //set the windowframe object to null
            arguments.SetParameter(9, null);
        }
Exemplo n.º 3
0
 private void OutputWindowPaneCallback(object sender, CallbackArgs args) {
     callbackExecuted = true;
     string expectedText = "Global SrcML Service Function called.\n";
     string inputText = (string)args.GetParameter(0);
     Assert.AreEqual(expectedText, inputText, "OutputString called with wrong text.");
     args.ReturnValue = 0;
 }
Exemplo n.º 4
0
        private static void CreateToolWindowCallBack(object caller, CallbackArgs arguments)
        {
            arguments.ReturnValue = VSConstants.S_OK;

            // Create the output mock object for the frame
            IVsWindowFrame frame = WindowFrameMock.GetBaseFrame();
            arguments.SetParameter(9, frame);
        }
Exemplo n.º 5
0
 private static void CreateInstanceCallBack(object caller, CallbackArgs arguments)
 {
     // Create the output mock object for the frame
     IVsTextLines textLines = (IVsTextLines)GetIVsTextLinesInstance();
     ///GCHandle handle = GCHandle.Alloc(textLines);
     arguments.SetParameter(4, Marshal.GetComInterfaceForObject(textLines, typeof(IVsTextLines)));
     arguments.ReturnValue = VSConstants.S_OK;
 }
Exemplo n.º 6
0
        private static void GetPropertyCallBack2(object caller, CallbackArgs arguments)
        {
            if ((int)arguments.GetParameter(0) == (int)__VSSPROPID.VSSPROPID_IsInCommandLineMode)
            {
                arguments.SetParameter(1, false);
                arguments.ReturnValue = VSConstants.S_OK;
                return;
            }

            arguments.ReturnValue = VSConstants.E_NOTIMPL;
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        private static void ReadCallback(object caller, CallbackArgs arguments)
        {
            string propertyName = (string)arguments.GetParameter(0);
            if (propertyName == strSolutionControlledProperty)
            {
                arguments.SetParameter(1, true);
                arguments.ReturnValue = VSConstants.S_OK;
                return;
            }
            else if (propertyName == strSolutionBindingsProperty)
            {
                arguments.SetParameter(1, "Solution's location");
                arguments.ReturnValue = VSConstants.S_OK;
                return;
            }

            arguments.ReturnValue = VSConstants.E_NOTIMPL;
        }
 private static void FindConnectionPointCallback(object sender, CallbackArgs args)
 {
     BaseMock mock = (BaseMock)sender;
     Dictionary<Guid, IConnectionPoint> connectionPoints =
         (Dictionary<Guid, IConnectionPoint>)mock[connectionPointsCollection];
     Guid eventGuid = (Guid)args.GetParameter(0);
     IConnectionPoint connectionPoint;
     if (!connectionPoints.TryGetValue(eventGuid, out connectionPoint))
     {
         // This container does not contain a connection point for this event type,
         // so set the out parameter to null and return an error.
         args.SetParameter(1, null);
         args.ReturnValue = Microsoft.VisualStudio.VSConstants.E_NOINTERFACE;
         return;
     }
     // The connection point is handled.
     args.SetParameter(1, connectionPoint);
     args.ReturnValue = Microsoft.VisualStudio.VSConstants.S_OK;
 }
Exemplo n.º 10
0
 private static void SetWaitCursorCallBack(object caller, CallbackArgs arguments)
 {
     arguments.ReturnValue = VSConstants.S_OK;
 }
Exemplo n.º 11
0
        private static void GetSelectionInfoCallback(object caller, CallbackArgs arguments)
        {
            // Read the current selection data
            VSITEMSELECTION[] selection = (VSITEMSELECTION[])((BaseMock)caller)["Selection"];

            // Initialize output parameters for empty selection
            arguments.SetParameter(0, (uint)0);    // numberOfSelectedItems
            arguments.SetParameter(1, (int)1);    // isSingleHierarchyInt

            if (selection != null)
            {
                arguments.SetParameter(0, (uint)selection.Length);    // numberOfSelectedItems
                if (selection.Length > 0)
                {
                    for (int i = 1; i < selection.Length; i++)
                    {
                        if (selection[i].pHier != selection[0].pHier)
                        {
                            arguments.SetParameter(1, (int)0);    // isSingleHierarchyInt
                            break;
                        }
                    }
                }
            }

            arguments.ReturnValue = VSConstants.S_OK;
        }
Exemplo n.º 12
0
        private static void GetSelectedItemsCallback(object caller, CallbackArgs arguments)
        {
            // Read the current selection data
            VSITEMSELECTION[] selection = (VSITEMSELECTION[])((BaseMock)caller)["Selection"];

            // Get the arguments
            uint grfGSI = (uint)arguments.GetParameter(0);
            uint cRequestedItems = (uint)arguments.GetParameter(1);
            VSITEMSELECTION[] rgItemSel = (VSITEMSELECTION[])arguments.GetParameter(2);

            if (selection == null && cRequestedItems > 0 ||
                selection.Length < cRequestedItems)
            {
                arguments.ReturnValue = VSConstants.E_INVALIDARG;
                return;
            }

            for (int i = 0; i< cRequestedItems; i++)
            {
                rgItemSel[i].itemid = selection[i].itemid;
                if ((grfGSI & (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs) == 0)
                {
                    rgItemSel[i].pHier = selection[i].pHier;
                }
            }

            arguments.ReturnValue = VSConstants.S_OK;
        }
Exemplo n.º 13
0
 private static void EventSourceAddTaskStarted(object sender, CallbackArgs args)
 {
     BaseMock mock = (BaseMock)sender;
     mock["TaskStarted"] = args.GetParameter(0);
 }
Exemplo n.º 14
0
 private static void ShowMessageBoxYes(object caller, CallbackArgs arguments)
 {
     arguments.SetParameter(10, (int)DialogResult.Yes);
     arguments.ReturnValue = VSConstants.S_OK;
 }
Exemplo n.º 15
0
 private static void NextCallBack0(object caller, CallbackArgs arguments)
 {
     arguments.ReturnValue = VSConstants.S_FALSE;
     arguments.SetParameter(2, (uint)0);
 }
Exemplo n.º 16
0
        private static void CreateToolWindowCallBack(object caller, CallbackArgs arguments)
        {
            arguments.ReturnValue = VSConstants.S_OK;

            // Create the output mock object for the frame
            IVsWindowFrame frame = MockWindowFrameProvider.GetBaseFrame();
            arguments.SetParameter(9, frame);

            // The window pane (if one is provided) needs to be sited
            IVsWindowPane pane = arguments.GetParameter(2) as IVsWindowPane;
            if (pane != null)
            {
                // Create a service provider to site the window pane
                OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();
                // It needs to provide STrackSelection
                GenericMockFactory trackSelectionFactory = MockWindowFrameProvider.TrackSelectionFactory;
                serviceProvider.AddService(typeof(STrackSelection), trackSelectionFactory.GetInstance(), false);
                // Add support for output window
                serviceProvider.AddService(typeof(SVsOutputWindow), new OutputWindowService(), false);
                // Finally we need support for FindToolWindow
                serviceProvider.AddService(typeof(SVsUIShell), GetWindowEnumerator0(), false);

                pane.SetSite(serviceProvider);
            }
        }
Exemplo n.º 17
0
 private static void OutputStringCallback(object sender, CallbackArgs args)
 {
     BaseMock mock = (BaseMock)sender;
     System.Text.StringBuilder builder = (System.Text.StringBuilder)mock["StringBuilder"];
     string text = (string)args.GetParameter(0);
     builder.Append(text);
     args.ReturnValue = 0;
 }
 private static void ReplaceLinesThrow(object sender, CallbackArgs args)
 {
     throw new TestStreamException();
 }
 private static void ReplaceLinesCallback(object sender, CallbackArgs args)
 {
     Assert.IsTrue(11 == (int)args.GetParameter(0));
     Assert.IsTrue(42 == (int)args.GetParameter(1));
     Assert.IsTrue(11 == (int)args.GetParameter(2));
     Assert.IsTrue(42 == (int)args.GetParameter(3));
     IntPtr stringPointer = (IntPtr)args.GetParameter(4);
     int stringLen = (int)args.GetParameter(5);
     Assert.IsTrue(IntPtr.Zero != stringPointer);
     Assert.IsTrue(stringLen > 0);
     string newText = Marshal.PtrToStringAuto(stringPointer, stringLen);
     BaseMock mock = (BaseMock)sender;
     mock["Text"] = (string)mock["Text"] + newText;
     args.ReturnValue = Microsoft.VisualStudio.VSConstants.S_OK;
 }
Exemplo n.º 20
0
 private static void SaveDocDataToFileCallBack(object caller, CallbackArgs arguments)
 {
     arguments.ReturnValue = VSConstants.S_OK;
 }
 private static void IncludeDebugInformationCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["IncludeDebugInformation"] = arguments.GetParameter(0);
 }
Exemplo n.º 22
0
 private static void ShowMessageBoxCallBack(object caller, CallbackArgs arguments)
 {
     arguments.ReturnValue = VSConstants.S_OK;
     arguments.SetParameter(10, (int)System.Windows.Forms.DialogResult.Yes);
 }
 private static void MainFileCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["MainFile"] = arguments.GetParameter(0);
 }
Exemplo n.º 24
0
        private static void GetToolWindowEnumCallBack2(object caller, CallbackArgs arguments)
        {
            arguments.ReturnValue = VSConstants.S_OK;

            // Create the output mock object
            if (enumWindowsFactory2 == null)
                enumWindowsFactory2 = new GenericMockFactory("EnumWindows2", new Type[] { typeof(IEnumWindowFrames) });
            BaseMock enumWindows = enumWindowsFactory2.GetInstance();
            // Add support for Next
            string name = string.Format("{0}.{1}", typeof(IEnumWindowFrames).FullName, "Next");
            enumWindows.AddMethodCallback(name, new EventHandler<CallbackArgs>(NextCallBack2));
            windowCount = 0;

            arguments.SetParameter(0, enumWindows);
        }
 private static void OutputAssemblyCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["OutputAssembly"] = arguments.GetParameter(0);
 }
Exemplo n.º 26
0
        private static void NextCallBack2(object caller, CallbackArgs arguments)
        {
            if (windowCount >= 2)
            {
                // We already enumerated 2 window frames, we are done (0 left to enumerate)
                NextCallBack0(caller, arguments);
                return;
            }

            arguments.ReturnValue = VSConstants.S_OK;
            // Create the list of properties we expect being asked for
            Dictionary<int, object> properties = new Dictionary<int,object>();
            properties.Add((int)__VSFPROPID.VSFPROPID_Caption, "Tool Window " + windowCount.ToString());
            ++windowCount;
            properties.Add((int)__VSFPROPID.VSFPROPID_GuidPersistenceSlot, Guid.NewGuid());
            // Create the output mock object for the frame
            object o = arguments.GetParameter(1);
            IVsWindowFrame[] frame = (IVsWindowFrame[])o;
            frame[0] = MockWindowFrameProvider.GetFrameWithProperties(properties);
            // fetched 1 frame
            arguments.SetParameter(2, (uint)1);
        }
 private static void ReferencedAssembliesCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["ReferencedAssemblies"] = arguments.GetParameter(0);
 }
		private static void ProfferServiceCallback(object sender, CallbackArgs args)
		{
			args.SetParameter(2, (uint)0);
			args.ReturnValue = 0;
		}
 private static void SourceFilesCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["SourceFiles"] = arguments.GetParameter(0);
 }
 private static void TargetKindCallBack(object caller, CallbackArgs arguments)
 {
     BaseMock compiler = (BaseMock)caller;
     compiler["TargetKind"] = arguments.GetParameter(0);
 }
Exemplo n.º 31
0
 private static void ProfferServiceCallback(object sender, CallbackArgs args)
 {
     args.SetParameter(2, (uint)0);
     args.ReturnValue = 0;
 }