/// <summary> /// Initializes a new instance of the <see cref="BusyIndicator"/> class. /// </summary> /// <param name="host">The host.</param> public BusyIndicator(IUIHost host) { this.host = host; Mouse.OverrideCursor = Cursors.Wait; this.host.DoEvents(); }
public static string GetFullPath(this IVssWMComponent component, IUIHost host) { string fullPath = AppendBackslash(component.LogicalPath) + component.ComponentName; if (!fullPath.StartsWith("\\")) fullPath = "\\" + fullPath; return fullPath; }
/// <summary> /// Initializes a new instance of the VssComponentDescriptor class. /// </summary> public VssComponentDescriptor(IUIHost host, string writerName, IVssComponent component) { if (host == null) { throw new ArgumentNullException("host", "host is null."); } if (component == null) { throw new ArgumentNullException("component", "component is null."); } WriterName = writerName; ComponentName = component.ComponentName; ComponentType = component.ComponentType; LogicalPath = component.LogicalPath ?? String.Empty; if (LogicalPath.EndsWith("\\")) { FullPath = LogicalPath + ComponentName; } else { FullPath = LogicalPath + "\\" + ComponentName; } if (!FullPath.StartsWith("\\")) { FullPath = "\\" + FullPath; } }
public VssClient(IUIHost host) { if (host == null) throw new ArgumentNullException("host", "host is null."); Host = host; }
public Program(IUIHost host) { if (host == null) throw new ArgumentNullException("log", "log is null."); Host = host; m_commands = new Command[] { new HelpCommand(m_nonHelpCommands) }.Concat(m_nonHelpCommands).ToArray(); }
public void Init(IUIHost uiHost) { _uiHost = uiHost; heroRepository = HeroRepository.Create("Resources/Scripts/heros.xml"); cardRepository = CardRepository.Create("Resources/Scripts/cards.xml"); //for test runtimeData = RuntimeData.Create("Resources/Scripts/test_save.xml"); }
public static string GetUniqueVolumeNameForPath(IUIHost host, string path, bool isBackup) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Length == 0) { throw new ArgumentException("Mount point must be non-empty"); } host.WriteVerbose("- Get volume path name for \"{0}\"...", path); if (!path.EndsWith("\\")) { path = path + "\\"; } if (isBackup && ClusterIsPathOnSharedVolume(host, path)) { string volumeRootPath, volumeUniqueName; ClusterPrepareSharedVolumeForBackup(path, out volumeRootPath, out volumeUniqueName); host.WriteVerbose("- Path name: {0}", volumeRootPath); host.WriteVerbose("- Unique volume name: {0}", volumeUniqueName); return(volumeUniqueName); } else { // Get the root path of the volume StringBuilder volumeRootPath = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumePathNameW(path, volumeRootPath, (uint)volumeRootPath.Capacity)) { host.WriteVerbose("- GetVolumePathName(\"{0}\") failed with error code {1}", path, Marshal.GetLastWin32Error()); throw new Win32Exception(); } // Get the volume name alias (might be different from the unique volume name in rare cases) StringBuilder volumeName = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumeRootPath.ToString(), volumeName, (uint)volumeName.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}", volumeRootPath.ToString(), Marshal.GetLastWin32Error()); throw new Win32Exception(); } // Gte the unique volume name StringBuilder uniqueVolumeName = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumeName.ToString(), uniqueVolumeName, (uint)uniqueVolumeName.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}", volumeName.ToString(), Marshal.GetLastWin32Error()); throw new Win32Exception(); } return(uniqueVolumeName.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="BusyIndicatorNull"/> class. /// </summary> /// <param name="host">The host.</param> public BusyIndicatorNull(IUIHost host) { if (host == null) { throw new ArgumentNullException(@"host"); } this.host = host; this.host.DoEvents(); }
public static string GetFullPath(this IVssWMComponent component, IUIHost host) { string fullPath = AppendBackslash(component.LogicalPath) + component.ComponentName; if (!fullPath.StartsWith("\\")) { fullPath = "\\" + fullPath; } return(fullPath); }
public static string ClusterGetVolumeNameForVolumeMountPoint(IUIHost host, string volumeMountPoint) { host.WriteVerbose("- Calling ClusterGetVolumeNameForVolumeMountPoint(\"{0}\")...", volumeMountPoint); StringBuilder result = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.ClusterGetVolumeNameForVolumeMountPointW(volumeMountPoint, result, (uint)result.Capacity)) { throw new Win32Exception(); } return(result.ToString()); }
public Program(IUIHost host) { if (host == null) { throw new ArgumentNullException(nameof(host), $"{nameof(host)} is null."); } Host = host; m_commands = new Command[] { new HelpCommand(m_nonHelpCommands) }.Concat(m_nonHelpCommands).ToArray(); }
public static string GetAffectedVolume(this VssWMFileDescriptor fileDesc, IUIHost host) { string expandedPath = AppendBackslash(Environment.ExpandEnvironmentVariables(fileDesc.Path)); try { return Volume.GetUniqueVolumeNameForPath(host, expandedPath, true); } catch { return expandedPath; } }
public static string GetAffectedVolume(this VssWMFileDescriptor fileDesc, IUIHost host) { string expandedPath = AppendBackslash(Environment.ExpandEnvironmentVariables(fileDesc.Path)); try { return(Volume.GetUniqueVolumeNameForPath(host, expandedPath, true)); } catch { return(expandedPath); } }
public static bool ClusterIsPathOnSharedVolume(IUIHost host, string path) { if (OperatingSystemInfo.IsAtLeast(OSVersionName.Windows7)) { host.WriteVerbose("- Calling ClusterIsPathOnSharedVolume(\"{0}\")...", path); return(NativeMethods.ClusterIsPathOnSharedVolume(path)); } else { host.WriteVerbose("- Skipping call to ClusterIsPathOnSharedVolume; function does not exist on this OS."); return(false); } }
public void InitUI(IUIHost host) { var noFilterItem = new ToolStripMenuItem("No Filter", null, OnNoFilterToolStripMenuItemClick) {CheckOnClick = true}; host.AddMenuItem(UIExtensionSite.Options, noFilterItem); var negateItem = new ToolStripMenuItem("Negate", null, OnNegateToolStripMenuItemClick) {CheckOnClick = true}; host.AddMenuItem(UIExtensionSite.Options, negateItem); currentFilterItem = noFilterItem; currentFilterItem.Checked = true; }
public VssComponentDescriptor(IUIHost host, string writerName, IVssWMComponent component) { if (component == null) { throw new ArgumentNullException("component", "component is null."); } WriterName = writerName; FullPath = ExtensionMethods.AppendBackslash(component.LogicalPath) + component.ComponentName; if (!FullPath.StartsWith("\\")) { FullPath = "\\" + FullPath; } HashSet <string> affectedPaths = new HashSet <string>(StringComparer.OrdinalIgnoreCase); HashSet <string> affectedVolumes = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (VssWMFileDescriptor file in component.Files) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } foreach (VssWMFileDescriptor file in component.DatabaseFiles) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } foreach (VssWMFileDescriptor file in component.DatabaseLogFiles) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } m_affectedPaths = new List <string>(affectedPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase)); m_affectedVolumes = new List <string>(affectedVolumes.OrderBy(path => path, StringComparer.OrdinalIgnoreCase)); Caption = component.Caption; ComponentName = component.ComponentName; LogicalPath = component.LogicalPath; RestoreMetadata = component.RestoreMetadata; IsSelectable = component.Selectable; ComponentType = component.Type; NotifyOnBackupComplete = component.NotifyOnBackupComplete; Files = new List <VssWMFileDescriptor>(component.Files); DatabaseFiles = new List <VssWMFileDescriptor>(component.DatabaseFiles); DatabaseLogFiles = new List <VssWMFileDescriptor>(component.DatabaseLogFiles); Dependencies = new List <VssWMDependency>(component.Dependencies); }
public VssComponentDescriptor(IUIHost host, string writerName, IVssWMComponent component) { if (component == null) throw new ArgumentNullException("component", "component is null."); WriterName = writerName; FullPath = ExtensionMethods.AppendBackslash(component.LogicalPath) + component.ComponentName; if (!FullPath.StartsWith("\\")) FullPath = "\\" + FullPath; HashSet<string> affectedPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> affectedVolumes = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (VssWMFileDescriptor file in component.Files) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } foreach (VssWMFileDescriptor file in component.DatabaseFiles) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } foreach (VssWMFileDescriptor file in component.DatabaseLogFiles) { affectedPaths.Add(file.GetExpandedPath()); affectedVolumes.Add(file.GetAffectedVolume(host)); } m_affectedPaths = new List<string>(affectedPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase)); m_affectedVolumes = new List<string>(affectedVolumes.OrderBy(path => path, StringComparer.OrdinalIgnoreCase)); Caption = component.Caption; ComponentName = component.ComponentName; LogicalPath = component.LogicalPath; RestoreMetadata = component.RestoreMetadata; IsSelectable = component.Selectable; ComponentType = component.Type; NotifyOnBackupComplete = component.NotifyOnBackupComplete; Files = new List<VssWMFileDescriptor>(component.Files); DatabaseFiles = new List<VssWMFileDescriptor>(component.DatabaseFiles); DatabaseLogFiles = new List<VssWMFileDescriptor>(component.DatabaseLogFiles); Dependencies = new List<VssWMDependency>(component.Dependencies); }
public void InitUI(IUIHost host) { var noFilterItem = new ToolStripMenuItem("No Filter", null, OnNoFilterToolStripMenuItemClick) { CheckOnClick = true }; host.AddMenuItem(UIExtensionSite.Options, noFilterItem); var negateItem = new ToolStripMenuItem("Negate", null, OnNegateToolStripMenuItemClick) { CheckOnClick = true }; host.AddMenuItem(UIExtensionSite.Options, negateItem); currentFilterItem = noFilterItem; currentFilterItem.Checked = true; }
public VssWriterDescriptor(IUIHost host, IVssExamineWriterMetadata writerMetadata) { m_host = host ?? throw new ArgumentNullException(nameof(host), $"{nameof(host)} is null."); WriterMetadata = writerMetadata ?? throw new ArgumentNullException(nameof(writerMetadata), $"{nameof(writerMetadata)} is null."); m_components = new List <VssComponentDescriptor>(writerMetadata.Components.Select(c => new VssComponentDescriptor(host, WriterMetadata.WriterName, c))); // Discover top-level components for (int i = 0; i < m_components.Count; i++) { m_components[i].IsTopLevel = true; for (int j = 0; j < m_components.Count; j++) { if (m_components[j].IsAncestorOf(m_components[i])) { m_components[i].IsTopLevel = false; } } } }
public VssWriterDescriptor(IUIHost host, IVssExamineWriterMetadata writerMetadata) { if (writerMetadata == null) throw new ArgumentNullException("writerMetadata", "writerMetadata is null."); m_host = host; WriterMetadata = writerMetadata; m_components = new List<VssComponentDescriptor>(writerMetadata.Components.Select(c => new VssComponentDescriptor(host, WriterMetadata.WriterName, c))); // Discover top-level components for (int i = 0; i < m_components.Count; i++) { m_components[i].IsTopLevel = true; for (int j = 0; j < m_components.Count; j++) { if (m_components[j].IsAncestorOf(m_components[i])) m_components[i].IsTopLevel = false; } } }
public static bool IsVolume(IUIHost host, string volumePath) { if (volumePath == null) { throw new ArgumentNullException("volumePath"); } if (volumePath.Length == 0) { return(false); } host.WriteVerbose("- Checking if \"{0}\" is a real volume path...", volumePath); if (!volumePath.EndsWith("\\")) { volumePath = volumePath + "\\"; } StringBuilder volumeNameBuilder = new StringBuilder(NativeMethods.MAX_PATH); if (ClusterIsPathOnSharedVolume(host, volumePath)) { if (!NativeMethods.ClusterGetVolumeNameForVolumeMountPointW(volumePath, volumeNameBuilder, (uint)volumeNameBuilder.Capacity)) { host.WriteVerbose("- ClusterGetVolumeNameForVolumeMountPointW(\"{0}\") failed with error code {1}.", volumePath, Marshal.GetLastWin32Error()); return(false); } return(true); } else { if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumePath, volumeNameBuilder, (uint)volumeNameBuilder.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}.", volumePath, Marshal.GetLastWin32Error()); return(false); } return(true); } }
/// <summary> /// Initializes a new instance of the VssComponentDescriptor class. /// </summary> public VssComponentDescriptor(IUIHost host, string writerName, IVssComponent component) { if (host == null) throw new ArgumentNullException("host", "host is null."); if (component == null) throw new ArgumentNullException("component", "component is null."); WriterName = writerName; ComponentName = component.ComponentName; ComponentType = component.ComponentType; LogicalPath = component.LogicalPath ?? String.Empty; if (LogicalPath.EndsWith("\\")) FullPath = LogicalPath + ComponentName; else FullPath = LogicalPath + "\\" + ComponentName; if (!FullPath.StartsWith("\\")) FullPath = "\\" + FullPath; }
public static bool ClusterIsPathOnSharedVolume(IUIHost host, string path) { if (OperatingSystemInfo.IsAtLeast(OSVersionName.Windows7)) { host.WriteVerbose("- Calling ClusterIsPathOnSharedVolume(\"{0}\")...", path); return NativeMethods.ClusterIsPathOnSharedVolume(path); } else { host.WriteVerbose("- Skipping call to ClusterIsPathOnSharedVolume; function does not exist on this OS."); return false; } }
public virtual void Initialize(IUIHost host, IEnumerable <string> args) { if (args == null) { throw new ArgumentNullException(nameof(args), $"{nameof(args)} is null."); } Host = host ?? throw new ArgumentNullException(nameof(host), "host is null."); foreach (string argument in args) { Match match = s_argumentRegex.Match(argument); string optionName = null; string value = null; if (match.Success) { if (match.Groups["name"].Success) { optionName = match.Groups["name"].Value; } if (match.Groups["value"].Success) { value = match.Groups["value"].Value; } if (optionName == null) { if (UnnamedOption == null || ((UnnamedOption.ValueType & OptionTypes.MultipleValuesAllowed) == 0) && m_remainingArguments.Any()) { throw new ArgumentException(String.Format("Unrecognized argument \"{0}\".", value)); } m_remainingArguments.Add(value); } else { if (!Options.Any(opt => opt.Name.Equals(optionName, StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException(String.Format("Unrecognized option /{0}.", optionName)); } IList <string> values; if (!m_optionValues.TryGetValue(optionName, out values)) { values = new List <string>(); m_optionValues.Add(optionName, values); } values.Add(value); } } else { throw new ArgumentException(String.Format("Unrecognized option \"{0}\"", argument)); } } foreach (OptionSpec option in NamedOptions) { IList <string> values; bool hasOption = m_optionValues.TryGetValue(option.Name, out values); if (option.IsRequired && !hasOption) { throw new ArgumentException(String.Format("Missing required option /{0}.", option.Name)); } if (hasOption && (option.ValueType & OptionTypes.Required) != 0 && (values.Any(val => val == null) || values.Count == 0)) { throw new ArgumentException(String.Format("Missing required value for option /{0}", option.Name)); } if (hasOption && option.ValueType == OptionTypes.ValueProhibited && values.Any(val => val != null)) { throw new ArgumentException(String.Format("Option /{0} does not accept a value.", option.Name)); } if (hasOption && (option.ValueType & OptionTypes.MultipleValuesAllowed) == 0 && values.Count(val => val != null) > 1) { throw new ArgumentException(String.Format("Option /{0} must only be specified once.", option.Name)); } } if (UnnamedOption != null) { if (UnnamedOption.IsRequired && RemainingArguments.Count == 0) { throw new ArgumentException(String.Format("Missing required argument(s) \"{0}\".", UnnamedOption.ValueText)); } } ProcessOptions(); }
public Indenter(IUIHost host) { m_host = host; m_host.PushIndent(); }
public PluginManager(IUIHost host, IInterceptorRegistry registry) { this.host = host; this.registry = registry; }
public static string GetUniqueVolumeNameForPath(IUIHost host, string path, bool isBackup) { if (path == null) throw new ArgumentNullException("path"); if (path.Length == 0) throw new ArgumentException("Mount point must be non-empty"); host.WriteVerbose("- Get volume path name for \"{0}\"...", path); if (!path.EndsWith("\\")) path = path + "\\"; if (isBackup && ClusterIsPathOnSharedVolume(host, path)) { string volumeRootPath, volumeUniqueName; ClusterPrepareSharedVolumeForBackup(path, out volumeRootPath, out volumeUniqueName); host.WriteVerbose("- Path name: {0}", volumeRootPath); host.WriteVerbose("- Unique volume name: {0}", volumeUniqueName); return volumeUniqueName; } else { // Get the root path of the volume StringBuilder volumeRootPath = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumePathNameW(path, volumeRootPath, (uint)volumeRootPath.Capacity)) { host.WriteVerbose("- GetVolumePathName(\"{0}\") failed with error code {1}", path, Marshal.GetLastWin32Error()); throw new Win32Exception(); } // Get the volume name alias (might be different from the unique volume name in rare cases) StringBuilder volumeName = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumeRootPath.ToString(), volumeName, (uint)volumeName.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}", volumeRootPath.ToString(), Marshal.GetLastWin32Error()); throw new Win32Exception(); } // Gte the unique volume name StringBuilder uniqueVolumeName = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumeName.ToString(), uniqueVolumeName, (uint)uniqueVolumeName.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}", volumeName.ToString(), Marshal.GetLastWin32Error()); throw new Win32Exception(); } return uniqueVolumeName.ToString(); } }
public static bool IsVolume(IUIHost host, string volumePath) { if (volumePath == null) throw new ArgumentNullException("volumePath"); if (volumePath.Length == 0) return false; host.WriteVerbose("- Checking if \"{0}\" is a real volume path...", volumePath); if (!volumePath.EndsWith("\\")) volumePath = volumePath + "\\"; StringBuilder volumeNameBuilder = new StringBuilder(NativeMethods.MAX_PATH); if (ClusterIsPathOnSharedVolume(host, volumePath)) { if (!NativeMethods.ClusterGetVolumeNameForVolumeMountPointW(volumePath, volumeNameBuilder, (uint)volumeNameBuilder.Capacity)) { host.WriteVerbose("- ClusterGetVolumeNameForVolumeMountPointW(\"{0}\") failed with error code {1}.", volumePath, Marshal.GetLastWin32Error()); return false; } return true; } else { if (!NativeMethods.GetVolumeNameForVolumeMountPointW(volumePath, volumeNameBuilder, (uint)volumeNameBuilder.Capacity)) { host.WriteVerbose("- GetVolumeNameForVolumeMountPoint(\"{0}\") failed with error code {1}.", volumePath, Marshal.GetLastWin32Error()); return false; } return true; } }
public static string ClusterGetVolumeNameForVolumeMountPoint(IUIHost host, string volumeMountPoint) { host.WriteVerbose("- Calling ClusterGetVolumeNameForVolumeMountPoint(\"{0}\")...", volumeMountPoint); StringBuilder result = new StringBuilder(NativeMethods.MAX_PATH); if (!NativeMethods.ClusterGetVolumeNameForVolumeMountPointW(volumeMountPoint, result, (uint)result.Capacity)) throw new Win32Exception(); return result.ToString(); }
public static bool ClusterIsPathOnSharedVolume(IUIHost host, string path) { host.WriteVerbose("- Calling ClusterIsPathOnSharedVolume(\"{0}\")...", path); return(NativeMethods.ClusterIsPathOnSharedVolume(path)); }