Example #1
0
        public void SolutionEventsOnBeforeClosing()
        {
            try
            {
                if (!(GetGlobalService(typeof(DTE)) is DTE dte))
                {
                    throw new ArgumentNullException(Core.Resources.Resource.ErrorMessage_ErrorAccessingDTE);
                }

                SharedGlobals.SetGlobal("UseCrmIntellisense", null, dte);

                if (SharedGlobals.GetGlobal("CrmService", dte) != null)
                {
                    SharedGlobals.SetGlobal("CrmService", null, dte);
                }

                if (SharedGlobals.GetGlobal("CrmMetadata", dte) != null)
                {
                    SharedGlobals.SetGlobal("CrmMetadata", null, dte);
                    OutputLogger.WriteToOutputWindow("Clearing metadata", MessageType.Info);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogException(Logger, null, ex);
                throw;
            }
        }
Example #2
0
        private void GetUserOptions(DTE dte)
        {
            var intellisenseOptions = (UserOptionsGridIntellisense)GetDialogPage(typeof(UserOptionsGridIntellisense));

            SharedGlobals.SetGlobal("IntellisenseEntityTriggerCharacter", intellisenseOptions.IntellisenseEntityTriggerCharacter, dte);
            SharedGlobals.SetGlobal("IntellisenseFieldTriggerCharacter", intellisenseOptions.IntellisenseFieldTriggerCharacter, dte);
            SharedGlobals.SetGlobal("UseIntellisense", intellisenseOptions.UseIntellisense, dte);

            var loggingOptions = (UserOptionsGridLogging)GetDialogPage(typeof(UserOptionsGridLogging));

            SharedGlobals.SetGlobal("ExtensionLoggingEnabled", loggingOptions.ExtensionLoggingEnabled, dte);
            SharedGlobals.SetGlobal("ExtensionLogFilePath", loggingOptions.ExtensionLogFilePath, dte);
            SharedGlobals.SetGlobal("XrmToolingLogFilePath", loggingOptions.XrmToolingLogFilePath, dte);
            SharedGlobals.SetGlobal("XrmToolingLoggingEnabled", loggingOptions.XrmToolingLoggingEnabled, dte);

            var templateOptions = (UserOptionsGridTemplates)GetDialogPage(typeof(UserOptionsGridTemplates));

            SharedGlobals.SetGlobal("CustomTemplatesPath", templateOptions.CustomTemplatesPath, dte);
            SharedGlobals.SetGlobal("DefaultKeyFileName", templateOptions.DefaultKeyFileName, dte);

            var toolsOptions = (UserOptionsGridTools)GetDialogPage(typeof(UserOptionsGridTools));

            SharedGlobals.SetGlobal("CrmSvcUtilToolPath", toolsOptions.CrmSvcUtilToolPath, dte);
            SharedGlobals.SetGlobal("PluginRegistrationToolPath", toolsOptions.PluginRegistrationToolPath, dte);
            SharedGlobals.SetGlobal("SolutionPackagerToolPath", toolsOptions.SolutionPackagerToolPath, dte);

            var webBrowserOptions = (UserOptionsGridWebBrowser)GetDialogPage(typeof(UserOptionsGridWebBrowser));

            SharedGlobals.SetGlobal("UseInternalBrowser", webBrowserOptions.UseInternalBrowser, dte);
        }
        private void SetGlobalConnection(CrmServiceClient client)
        {
            if (!(Package.GetGlobalService(typeof(DTE)) is DTE dte))
            {
                return;
            }

            SharedGlobals.SetGlobal("CrmService", client, dte);
        }
Example #4
0
        private static void ToggleCrmIntellisense(object sender, EventArgs e, DTE dte)
        {
            bool isEnabled;
            var  value = SharedGlobals.GetGlobal("UseCrmIntellisense", dte);

            if (value == null)
            {
                isEnabled = false;
                SharedGlobals.SetGlobal("UseCrmIntellisense", true, dte);
            }
            else
            {
                isEnabled = (bool)value;
                SharedGlobals.SetGlobal("UseCrmIntellisense", !isEnabled, dte);
            }

            ExLogger.LogToFile(Logger, $"{Resource.Message_CRMIntellisenseEnabled}: {!isEnabled}", LogLevel.Info);

            if (!isEnabled) //On
            {
                if (HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null)
                {
                    return;
                }
            }
            else
            {
                if (!HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null)
                {
                    SharedGlobals.SetGlobal("CrmService", null, dte);
                }

                CrmMetadata.Metadata = null;
                SharedGlobals.SetGlobal("CrmMetadata", null, dte);

                ExLogger.LogToFile(Logger, Resource.Message_ClearingMetadata, LogLevel.Info);
                OutputLogger.WriteToOutputWindow(Resource.Message_ClearingMetadata, MessageType.Info);

                return;
            }

            var result = MessageBox.Show(Resource.MessageBox_ConnectToCrm, Resource.MessageBox_ConnectToCrm_Title,
                                         MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            ConnectToCrm();
        }
Example #5
0
        public void SolutionEventsOnBeforeClosing()
        {
            SharedGlobals.SetGlobal("UseCrmIntellisense", null, _dte);

            if (SharedGlobals.GetGlobal("CrmService", _dte) != null)
            {
                SharedGlobals.SetGlobal("CrmService", null, _dte);
            }

            if (SharedGlobals.GetGlobal("CrmMetadata", _dte) != null)
            {
                SharedGlobals.SetGlobal("CrmMetadata", null, _dte);
                OutputLogger.WriteToOutputWindow("Clearing metadata", MessageType.Info);
            }
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (!PositionHelper.IsStringLiteral(session, _mTextBuffer))
            {
                return;
            }

            if (!(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE)) is DTE dte))
            {
                return;
            }

            var metadata = (List <Completion>)SharedGlobals.GetGlobal("CrmMetadata", dte);

            if (metadata == null)
            {
                if (CrmMetadata.Metadata == null)
                {
                    return;
                }

                var strList = CrmMetadata.Metadata;
                metadata = new List <Completion>();
                foreach (var completionValue in strList)
                {
                    metadata.Add(new Completion(completionValue.Name, completionValue.Replacement,
                                                completionValue.Description, MonikerHelper.GetImage(completionValue.MetadataType), null));
                }

                SharedGlobals.SetGlobal("CrmMetadata", metadata, dte);
            }

            completionSets.Add(new CompletionSet(
                                   "CRM",
                                   "CRM",
                                   FindTokenSpanAtPosition(session.GetTriggerPoint(_mTextBuffer), session),
                                   metadata,
                                   null)
                               );
        }
 private static void SetGlobalConnection(CrmServiceClient client)
 {
     SharedGlobals.SetGlobal("CrmService", client);
 }
Example #8
0
 public static void SetOption <T>(UserOptionProperty userOptionProperty, T value)
 {
     SharedGlobals.SetGlobal(userOptionProperty.Name, value);
 }