public static string CreateToolPath() { var spPath = UserOptionsHelper.GetOption <string>(UserOptionProperties.SolutionPackagerToolPath); if (string.IsNullOrEmpty(spPath)) { OutputLogger.WriteToOutputWindow(Resource.ErrorMessage_SetSolutionPackagerPath, MessageType.Error); return(null); } if (!spPath.EndsWith("\\", StringComparison.CurrentCultureIgnoreCase)) { spPath += "\\"; } var toolPath = @"""" + spPath + "SolutionPackager.exe" + @""""; if (File.Exists(spPath + "SolutionPackager.exe")) { return(toolPath); } OutputLogger.WriteToOutputWindow($"S{Resource.ErrorMessage_SolutionPackagerNotFound}: {spPath}", MessageType.Error); return(null); }
private static void OpenPage(string contentUrl) { try { var useInternalBrowser = UserOptionsHelper.GetOption <bool>(UserOptionProperties.UseInternalBrowser); if (!(Package.GetGlobalService(typeof(DTE)) is DTE dte)) { throw new ArgumentNullException(Resources.Resource.ErrorMessage_ErrorAccessingDTE); } if (useInternalBrowser) //Internal VS browser { dte.ItemOperations.Navigate(contentUrl); } else //User's default browser { System.Diagnostics.Process.Start(contentUrl); } } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resources.Resource.ErrorMessage_ErrorAccessingDTE, ex); throw; } }
private static void DisplayCrmIntellisense(object sender, EventArgs eventArgs) { if (!(sender is OleMenuCommand menuCommand)) { return; } bool useIntellisense = UserOptionsHelper.GetOption <bool>(UserOptionProperties.UseIntellisense); if (!useIntellisense) { return; } var value = SharedGlobals.GetGlobal("UseCrmIntellisense", _dte); if (value == null) { menuCommand.Visible = menuCommand.CommandID.ID == 264; return; } bool isEnabled = (bool)value; if (isEnabled) { menuCommand.Visible = menuCommand.CommandID.ID != 264; } else { menuCommand.Visible = menuCommand.CommandID.ID == 264; } }
public static void LogToFile(Logger logger, string message, LogLevel logLevel) { if (UserOptionsHelper.GetOption <bool>(UserOptionProperties.ExtensionLoggingEnabled)) { logger.Log(logLevel, message); } }
private static void ProcessMetadata(RetrieveAllEntitiesResponse metaDataResponse) { ExLogger.LogToFile(Logger, Resource.Message_ProcessingMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_ProcessingMetadata, MessageType.Info); var entities = metaDataResponse.EntityMetadata; Metadata = new List <CompletionValue>(); var entityTriggerCharacter = UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseEntityTriggerCharacter); var entityFieldCharacter = UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseFieldTriggerCharacter); foreach (var entityMetadata in entities) { Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}", entityMetadata.LogicalName, GetDisplayName(entityMetadata.DisplayName), MetadataType.Entity)); Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}{entityFieldCharacter}?field?", $"{entityTriggerCharacter}{entityMetadata.LogicalName}", GetDisplayName(entityMetadata.DisplayName), MetadataType.None)); foreach (var attribute in entityMetadata.Attributes.Where(attribute => attribute.IsValidForCreate.GetValueOrDefault() || attribute.IsValidForUpdate.GetValueOrDefault() || attribute.IsValidForRead.GetValueOrDefault())) { Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}_{attribute.LogicalName}", attribute.LogicalName, $"{GetDisplayName(attribute.DisplayName)}: {attribute.AttributeType.GetValueOrDefault()}", MetadataType.Attribute)); } } Metadata = Metadata.OrderBy(m => m.Name).ToList(); }
internal CrmCSharpCompletionCommandHandler(IVsTextView textViewAdapter, ITextView textView, CrmCSharpCompletionHandlerProvider provider) { _mTextView = textView; _mProvider = provider; _entityTriggerCharacter = char.Parse(UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseEntityTriggerCharacter)); _entityFieldCharacter = char.Parse(UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseFieldTriggerCharacter)); textViewAdapter.AddCommandFilter(this, out _mNextCommandHandler); }
private static void EnableXrmToolingLogging() { if (!UserOptionsHelper.GetOption <bool>(UserOptionProperties.XrmToolingLoggingEnabled)) { return; } TraceControlSettings.TraceLevel = SourceLevels.All; var logPath = XrmToolingLogging.GetLogFilePath(); TraceControlSettings.AddTraceListener(new TextWriterTraceListener(logPath)); }
private static void OpenPage(DTE dte, string contentUrl) { bool useInternalBrowser = UserOptionsHelper.GetOption <bool>(UserOptionProperties.UseInternalBrowser); if (useInternalBrowser) //Internal VS browser { dte.ItemOperations.Navigate(contentUrl); } else //User's default browser { System.Diagnostics.Process.Start(contentUrl); } }
public static string GetLogFilePath() { string logFilePath = UserOptionsHelper.GetOption <string>(UserOptionProperties.XrmToolingLogFilePath); if (!string.IsNullOrEmpty(logFilePath)) { return(Path.Combine(logFilePath, "CrmDevExXrmToolingLog_" + DateTime.Now.ToString("MMddyyyy") + ".log")); } logFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); OutputLogger.WriteToOutputWindow(Resource.WarningMessage_MissingXrmToolingLogPath, MessageType.Warning); return(Path.Combine(logFilePath, "CrmDevExXrmToolingLog_" + DateTime.Now.ToString("MMddyyyy") + ".log")); }
private static string GetLogFilePath() { string logFilePath = UserOptionsHelper.GetOption <string>(UserOptionProperties.ExtensionLogFilePath); if (!string.IsNullOrEmpty(logFilePath)) { return(Path.Combine(logFilePath, CreateLogFileName())); } logFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); OutputLogger.WriteToOutputWindow(Resource.WarningMessage_MissingExtensionLogPath, MessageType.Warning); return(Path.Combine(logFilePath, CreateLogFileName())); }
private Dictionary <string, string> PreHandleCustomItem(Dictionary <string, string> replacementsDictionary) { var templateFolder = UserOptionsHelper.GetOption <string>(UserOptionProperties.CustomTemplatesPath); _addFile = CustomTemplateHandler.ValidateTemplateFolder(templateFolder); if (!_addFile) { return(replacementsDictionary); } _addFile = CustomTemplateHandler.ValidateTemplateFile(templateFolder); if (!_addFile) { return(replacementsDictionary); } var templates = CustomTemplateHandler.GetTemplateConfig(templateFolder); if (templates == null) { _addFile = false; return(replacementsDictionary); } var results = CustomTemplateHandler.GetTemplatesByLanguage(templates, "CSharp"); if (results.Count == 0) { MessageBox.Show(Resource.MessageBox_AddCustomTemplate); _addFile = false; return(replacementsDictionary); } var templatePicker = CustomTemplateHandler.GetCustomTemplate(results); if (templatePicker.SelectedTemplate == null) { _addFile = false; return(replacementsDictionary); } _customTemplate = templatePicker.SelectedTemplate; var content = CustomTemplateHandler.GetTemplateContent(templateFolder, _customTemplate, replacementsDictionary); replacementsDictionary.Add("$customtemplate$", content); return(replacementsDictionary); }
private static string CreateKeyName(string destDirectory) { string defaultKeyName = UserOptionsHelper.GetOption <string>(UserOptionProperties.DefaultKeyFileName); if (!FileSystem.IsValidFilename(defaultKeyName, destDirectory)) { defaultKeyName = CrmDeveloperExtensions2.Core.Resources.Resource.DefaultKeyName; } if (!defaultKeyName.EndsWith(".snk", StringComparison.CurrentCultureIgnoreCase)) { defaultKeyName = $"{defaultKeyName}.snk"; } return(defaultKeyName); }
public bool IsIntellisenseEnabled(DTE dte) { var useIntellisense = UserOptionsHelper.GetOption <bool>(UserOptionProperties.UseIntellisense); if (!useIntellisense) { return(false); } var value = SharedGlobals.GetGlobal("UseCrmIntellisense", dte); if (value == null) { return(false); } var isEnabled = (bool?)value; return(!(bool)!isEnabled); }
private static void UpdatePrtPath(string installPath, NuGetPackage selectedPackage) { string prtPath = UserOptionsHelper.GetOption <string>(UserOptionProperties.PluginRegistrationToolPath); if (!string.IsNullOrEmpty(prtPath)) { return; } MessageBoxResult updatePrt = System.Windows.MessageBox.Show(Resource.ConfirmMessage_UpdatePrtPath, Resource.ConfirmMessage_UpdateUserSetting_Title, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (updatePrt != MessageBoxResult.Yes) { return; } string newPrtPath = $@"{installPath}\{ExtensionConstants.MicrosoftCrmSdkXrmToolingPrt.ToLower()}.{selectedPackage.VersionText}\tools"; UserOptionsHelper.SetOption(UserOptionProperties.PluginRegistrationToolPath, newPrtPath); }
public static void OpenPrt() { string path = UserOptionsHelper.GetOption <string>(UserOptionProperties.PluginRegistrationToolPath); if (string.IsNullOrEmpty(path)) { MessageBox.Show(Resource.MessageBox_SetPRTOptionsPath); return; } if (!path.EndsWith("exe", StringComparison.CurrentCultureIgnoreCase)) { path = Path.Combine(path, "PluginRegistration.exe"); } if (!File.Exists(path)) { MessageBox.Show($"{Resource.MessageBox_PRTNotFound}: " + path); return; } StartPrt(path); }
private static void UpdateCorePath(string installPath, NuGetPackage selectedPackage) { string spPath = UserOptionsHelper.GetOption <string>(UserOptionProperties.SolutionPackagerToolPath); string crmSvcPath = UserOptionsHelper.GetOption <string>(UserOptionProperties.CrmSvcUtilToolPath); if (!string.IsNullOrEmpty(spPath) && !string.IsNullOrEmpty(crmSvcPath)) { return; } MessageBoxResult updateCore = System.Windows.MessageBox.Show(Resource.ConfirmMessage_UpdateCrmSvcUtilSolutionPackagerPath, Resource.ConfirmMessage_UpdateUserSetting_Title, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (updateCore != MessageBoxResult.Yes) { return; } string newCorePath = $@"{installPath}\{ExtensionConstants.MicrosoftCrmSdkCoreTools.ToLower()}.{selectedPackage.VersionText}\content\bin\coretools"; UserOptionsHelper.SetOption(UserOptionProperties.CrmSvcUtilToolPath, newCorePath); UserOptionsHelper.SetOption(UserOptionProperties.SolutionPackagerToolPath, newCorePath); }
private static void SetupUserOptionsHelper(DTE dte) { UserOptionsHelper userOptionsHelper = new UserOptionsHelper(dte); }