public void SetNodeCheckStateFromCollection(TreeNode node) { IResource resourceTag = (IResource)node.Tag; if (resourceTag != null) { HashMap.Entry checkEntry = _checkStates.GetEntry(resourceTag.Id); NodeCheckState check = NodeCheckState.Checked; if (checkEntry != null) { check = (NodeCheckState)checkEntry.Value; } else { if (!Folder.IsIgnoreImport(resourceTag)) { check = NodeCheckState.Checked; } else { check = NodeCheckState.Unchecked; } } SetNodeCheckState(node, check); } }
public static bool IsMailExported(string entryId) { if (String.IsNullOrEmpty(entryId)) { return(false); } lock ( _exportingMail ) { HashMap.Entry entry = _exportingMail.GetEntry(entryId); bool bRet = entry != null; if (bRet) { DateTime date = (DateTime)entry.Value; TimeSpan dif = DateTime.Now - date; if (dif.TotalMilliseconds > 10000) { bRet = false; } } EndExportingMail(entryId); if (bRet) { _tracer.Trace("Ignore event for entryId = " + entryId); } return(bRet); } }
public void RegisterResourceTypeRestriction(string prep, string displayType, string resType) { #region Preconditions if (String.IsNullOrEmpty(prep)) { throw new ArgumentNullException("prep", "SearchQueryExtensions -- Preposition is NULL or empty."); } if (String.IsNullOrEmpty(displayType)) { throw new ArgumentNullException("displayType", "SearchQueryExtensions -- Displayable name for a resource type is NULL or empty."); } if (String.IsNullOrEmpty(resType)) { throw new ArgumentNullException("resType", "SearchQueryExtensions -- resource type name is NULL or empty."); } #endregion Preconditions HashMap.Entry e = _prep2ResTypeExtensions.GetEntry(prep); if (e == null) { ArrayList list = new ArrayList(); list.Add(new Pair(displayType, resType)); _prep2ResTypeExtensions[prep] = list; } else { Debug.Assert(e.Value is ArrayList); ((ArrayList)e.Value).Add(new Pair(displayType, resType)); } }
public void Invoke(string url) { if (url == null) { return; } int pos = url.IndexOf(':'); if (pos != -1) { string protocol = url.Substring(0, pos); HashMap.Entry entry = null; lock ( _handlers ) { entry = _handlers.GetEntry(protocol); } if (entry != null) { ++pos; string URL = url.Substring(pos, url.Length - pos); ProtocolHandler handler = entry.Value as ProtocolHandler; if (handler != null) { try { handler.Invoke(URL); } catch (Exception exception) { Core.ReportException(exception, ExceptionReportFlags.AttachLog); } } } } }
public void RegisterSingleTokenRestriction(string prep, string token, IResource stdCondition) { #region Preconditions if (String.IsNullOrEmpty(prep)) { throw new ArgumentNullException("prep", "SearchQueryExtensions -- Preposition is NULL or empty."); } if (String.IsNullOrEmpty(token)) { throw new ArgumentNullException("token", "SearchQueryExtensions -- Anchor token for a resource type is NULL or empty."); } if (stdCondition == null) { throw new ArgumentNullException("stdCondition", "SearchQueryExtensions -- Mapped condition is null."); } #endregion Preconditions HashMap.Entry e = _prep2TokenExtensions.GetEntry(prep); if (e == null) { ArrayList list = new ArrayList(); list.Add(new Pair(token, stdCondition)); _prep2TokenExtensions[prep] = list; } else { Debug.Assert(e.Value is ArrayList); ((ArrayList)e.Value).Add(new Pair(token, stdCondition)); } }
private void ProcessLinkChange(int linkId, IResource target, LinkChange change) { if (change.ChangeType == LinkChangeType.Add) { if (target.Type == (string)TracedLinks[linkId]) { IResource rule = target.GetLinkProp("ExpirationRuleLink"); if (rule == null) { IResource resType = null; HashMap.Entry entry = _resourceTypesForDefaultExpirationRules.GetEntry(target.Type); if (entry != null) { resType = (IResource)entry.Value; } else { resType = Core.ResourceStore.FindUniqueResource("ResourceType", Core.Props.Name, target.Type); _resourceTypesForDefaultExpirationRules.Add(target.Type, resType); } if (resType != null) { rule = resType.GetLinkProp("ExpirationRuleLink"); } } if (rule != null) { // If we submit repeatable job with the same signature, they are // merged in the queue. Thus we fire the actual rule only once. Core.ResourceAP.QueueJobAt(DateTime.Now.AddSeconds(20.0), new ExpRuleDelegate(UpdateFolder), rule, target); } } } }
private void SetUrlCookie(string domain, string path, string cookie) { if (domain.IndexOf("://") < 0) { domain = "http://" + domain; } Uri uri; try { uri = new Uri(new Uri(domain), path); } catch { return; } HashMap.Entry entry = _cookies.GetEntry(uri.AbsoluteUri); if (entry == null) { _cookies.Add(uri.AbsoluteUri, cookie); } else { string oldCookie = (string)entry.Value; entry.Value = oldCookie + "; " + cookie; } }
public void RegisterFreestyleRestriction(string prep, IQueryTokenMatcher matcher) { #region Preconditions if (String.IsNullOrEmpty(prep)) { throw new ArgumentNullException("prep", "SearchQueryExtensions -- Preposition is NULL or empty."); } if (matcher == null) { throw new ArgumentNullException("matcher", "SearchQueryExtensions -- Token stream matcher handler is NULL."); } #endregion Preconditions HashMap.Entry e = _prep2FreestyleExtensions.GetEntry(prep); if (e == null) { ArrayList list = new ArrayList(); list.Add(matcher); _prep2FreestyleExtensions[prep] = list; } else { Debug.Assert(e.Value is ArrayList); ((ArrayList)e.Value).Add(matcher); } }
public override AbstractJob GetNextJob() { if (!Interrupted && _folderEnumerator.MoveNext()) { HashMap.Entry entry = (HashMap.Entry)_folderEnumerator.Current; string path = (string)entry.Key; IResource folder = (IResource)entry.Value; Core.UIManager.GetStatusWriter(this, StatusPane.UI).ShowStatus(path); string jobName = "Scanning file folder - " + path; _args[0] = folder; if (IsPathDeferred(path) || IsPathMonitored(path)) { if (_indexHidden) { return(new DelegateJob(jobName, _enumerateDelegate, _args)); } DirectoryInfo info = IOTools.GetDirectoryInfo(path); if (info != null && (IOTools.GetAttributes(info) & FileAttributes.Hidden) == 0) { return(new DelegateJob(jobName, _enumerateDelegate, _args)); } } return(new DelegateJob(jobName, _excludeDelegate, _args)); } return(null); }
private FileSystemWatcher FolderWatcher(string path) { HashMap.Entry E = _folderWatchers.GetEntry(path); if (E != null) { return((FileSystemWatcher)E.Value); } FileSystemWatcher watcher = new FileSystemWatcher(); try { watcher.Path = path; } catch (ArgumentException e) { Trace.WriteLine(e.Message, "FilePlugin"); // FileSystemWatcher can treat a path as "invalid" // so seems FileSystemWatcher itself is invalid return(null); } watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; watcher.Changed += OnCreatedOrChanged; watcher.Created += OnCreatedOrChanged; watcher.Deleted += OnDeleted; watcher.Renamed += OnRenamed; watcher.EnableRaisingEvents = false; _folderWatchers[path] = watcher; return(watcher); }
public static IEMsgStore OpenMsgStore(string storeId) { if (OutlookSession.OutlookProcessor != null && OutlookSession.OutlookProcessor.ShuttingDown) { return(null); } HashMap.Entry entry = _msgStores.GetEntry(storeId); if (entry != null) { return((IEMsgStore)entry.Value); } IEMsgStore msgStore = null; try { msgStore = _eSession.OpenMsgStore(storeId); } catch (COMException exc) { if (!Trapped(exc)) { throw exc; } _tracer.TraceException(exc); } finally { _msgStores[storeId] = msgStore; } return(msgStore); }
public Icon GetFavIcon(string favIconUrl) { Guard.EmptyStringArgument(favIconUrl, "favIconUrl"); HashMap.Entry entry = _favIcons.GetEntry(favIconUrl); if (entry != null) { return((Icon)entry.Value); } try { IResource resFavIcon = GetFavIconResource(favIconUrl); if (resFavIcon != null) { Stream stream = resFavIcon.GetBlobProp(_propFavIcon); if (stream != null) { Icon icon = new Icon(stream); icon = new Icon(icon, 16, 16); _favIcons.Add(favIconUrl, icon); return(icon); } } } catch { _favIcons.Add(favIconUrl, null); } return(null); }
static public Phone GetPhone(string name) { HashMap.Entry entry = _nameToPhone.GetEntry(name); if (entry != null) { return((Phone)entry.Value); } return(null); }
static public int GetColorIndex(IResource resource) { Guard.NullArgument(resource, "resource"); HashMap.Entry entry = _resId2ColorIndex.GetEntry(resource.GetPropText(ResourceFlag._propFlagId)); if (entry != null) { return((int)entry.Value); } return(6); }
public bool FolderFetched(FolderDescriptor parent, FolderDescriptor folder, out FolderDescriptor folderTag) { folderTag = folder; Console.WriteLine("Folder name = " + folder.Name); HashMap.Entry entry = _folders.GetEntry(folder.Name); if (entry != null) { entry.Value = folder; } return(true); }
private void InvokeMakeDefault(string protocol) { Guard.NullArgument(protocol, "protocol"); lock ( _makeDefaultHandler ) { HashMap.Entry entry = _makeDefaultHandler.GetEntry(protocol); if (entry != null) { ((MethodInvoker)entry.Value).Invoke(); } } }
public HashNode InsertResource(IResource resource) { HashMap.Entry entry = _map.GetEntry(resource.Id); if (entry == null) { HashNode hashNode = new HashNode(resource); _map.Add(resource.Id, hashNode); return(hashNode); } else { return((HashNode)entry.Value); } }
private void _deleteItem_Click(object sender, EventArgs e) { if (_lastClickedLabel != null) { HashMap.Entry E = _phoneControls.GetEntry(_lastClickedLabel); if (E != null) { Controls.Remove(_lastClickedLabel); Controls.Remove((Control)E.Value); _phoneControls.Remove(_lastClickedLabel); Core.UIManager.QueueUIJob(new MethodInvoker(RedrawPhones)); } _lastClickedLabel = null; } }
private int CheckSection(string sectionName) { int secId; HashMap.Entry entry = _sectionsMapping.GetEntry(sectionName); if (entry != null) { secId = (int)entry.Value; } else { IResource section = RegisterDocumentSection(sectionName); secId = section.GetIntProp("SectionOrder"); } return(secId); }
private void AddProviderToGroup(ISearchProvider host, string group) { ArrayList hosts; HashMap.Entry e = _ProvidersGroups.GetEntry(group); if (e == null) { hosts = new ArrayList(); _ProvidersGroups.Add(group, hosts); } else { hosts = (ArrayList)e.Value; } hosts.Add(host); }
private static bool AddResourceRestriction(ResourceRestriction restriction) { lock ( _restrictions ) { HashMap.Entry E = _restrictions.GetEntry(restriction.ResourceType); HashSet restrictionsSet = (E == null) ? new HashSet() : (HashSet)E.Value; if (!restrictionsSet.Contains(restriction)) { restrictionsSet.Add(restriction); if (E == null) { _restrictions[restriction.ResourceType] = restrictionsSet; } return(true); } return(false); } }
private void SetCurrentFont(int fontNum) { HashMap.Entry entry = _fonts.GetEntry(fontNum); if (entry == null) { _fonts.Add(fontNum, _defaultEncoding); //throw new FontMismatching( "Cannot set current font. Such fontNum '" + fontNum + // "' was not included in \\fonttbl tag.", _currentPosition ); } if (entry != null && entry.Value != null) { _curState.encoding = (Encoding)entry.Value; } else { _curState.encoding = _defaultEncoding; } }
public static HashMap GetProtocols(IResourceList protocolHandlers) { HashMap protocolSet = new HashMap(protocolHandlers.Count); foreach (IResource protocol in protocolHandlers) { string friendlyName = protocol.GetPropText(_propFriendlyName); HashMap.Entry entry = protocolSet.GetEntry(friendlyName); if (entry == null) { ArrayList list = new ArrayList(); list.Add(protocol); protocolSet.Add(friendlyName, list); } else { ((ArrayList)entry.Value).Add(protocol); } } return(protocolSet); }
public Encoding GetEncoding(int charset) { HashMap.Entry entry = _encoders.GetEntry(charset); if (entry == null) { return(null); } Encoding encoding = entry.Value as Encoding; if (encoding == null) { try { encoding = Encoding.GetEncoding((int)entry.Value); } catch { encoding = null; } entry.Value = encoding; } return(encoding); }
public int StoreMapping(string wordform, string lexeme) { Debug.Assert(!WordformsVariant.Contains(wordform)); int derivationVariant; ArrayList forms; HashMap.Entry e = WordformsValues.GetEntry(lexeme); if (e != null) { forms = (ArrayList)e.Value; } else { forms = new ArrayList(); WordformsValues[lexeme] = forms; } forms.Add(wordform); WordformsVariant[wordform] = derivationVariant = forms.Count; WordformsChanged = true; return(derivationVariant); }
/** * Propagates a valid state change notification from one of the contact blocks * to the entire pane. */ private void block_ValidStateChanged(object sender, ValidStateEventArgs e) { if (e.IsValid) { _blockValidationErrors.Remove(sender); if (_blockValidationErrors.Count > 0) { IEnumerator errEnumerator = _blockValidationErrors.GetEnumerator(); errEnumerator.MoveNext(); HashMap.Entry entry = (HashMap.Entry)errEnumerator.Current; OnValidStateChanged((ValidStateEventArgs)entry.Value); } else { OnValidStateChanged(new ValidStateEventArgs(true)); } } else { _blockValidationErrors[sender] = e; OnValidStateChanged(e); } }
public void DeRegisterProfile(IBookmarkProfile profile) { Guard.NullArgument(profile, "profile"); using ( profile ) { string name = NormalizeProfileName(profile.Name); HashMap.Entry e = _profileNames2RootResources.GetEntry(name); if (e == null) { throw new InvalidOperationException("Bookmark profile '" + profile.Name + "' was not registered"); } IResource profileRoot = (IResource)e.Value; _profileNames2RootResources.Remove(name); _rootResources2Profiles.Remove(profileRoot); if (_rootResources2Profiles.Count != _profileNames2RootResources.Count) { throw new Exception("Root resources and profiles count mismatch. Last removed profile name: " + profile.Name); } if (profileRoot.HasProp(FavoritesPlugin._propInvisible)) { DeleteFolder(profileRoot); } } }
//--------------------------------------------------------------------- // NB: Exceptional conditions are possible if e.g. we failed to flush // wordforms file into HD (due to any external conditions) and // reread its previous state. //--------------------------------------------------------------------- public string GetLexemeMapping(string lexeme, int mapVariant) { if (mapVariant <= 0) { throw new ArgumentOutOfRangeException("DictionaryServer -- Mapping variant parameter must be positive."); } HashMap.Entry e = WordformsValues.GetEntry(lexeme); if (e == null) { throw new ArgumentException("DictionaryServer -- Illegal call to GetMappingLexeme - lexeme [" + lexeme + " is not present with index " + mapVariant); } ArrayList forms = (ArrayList)e.Value; if (mapVariant > forms.Count) { throw new ArgumentOutOfRangeException("DictionaryServer -- Mapping variant [" + mapVariant + "] is greater than the number of possible wordforms " + forms.Count); } return((string)forms[mapVariant - 1]); }
private static Icon GetFileSmallIcon(string path, uint format) { #region NULL if empty path or no extension if (String.IsNullOrEmpty(path)) { return(null); } string extension = IOTools.GetExtension(path); if (extension.Length == 0) { return(null); } #endregion NULL if empty path or no extension extension = extension.ToLower(); if (extension == ".dll" || extension == ".exe") { extension = path; } Icon result = null; HashMap.Entry E = _files2SmallIcons.GetEntry(extension); if (E != null) { result = (Icon)E.Value; } else { Stream tempFile = null; try { if (!File.Exists(path)) { path = Path.Combine(Path.GetTempPath(), Path.GetFileName(path)); tempFile = IOTools.CreateFile(path); } WindowsAPI.SHFILEINFO fileInfo = new WindowsAPI.SHFILEINFO(); WindowsAPI.SHGetFileInfo(path, 0, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), WindowsAPI.SHGFI_ICON | format); result = Icon.FromHandle(fileInfo.hIcon); if (format == WindowsAPI.SHGFI_SMALLICON) { _files2SmallIcons[extension] = result; } else { _files2LargeIcons[extension] = result; } } catch { // nothing to do, just ignore any problems from shell32.dll } finally { if (tempFile != null) { tempFile.Close(); IOTools.DeleteFile(path); } } } return(result); }
private void EnumerateFiles(IResource folder) { try { DateTime lastUpdated = folder.GetDateProp(_ftm.propLastModified); string directory = folder.GetPropText(FileProxy._propDirectory); FileInfo[] fileInfos = IOTools.GetFiles(directory); if (fileInfos != null) { DateTime updated = DateTime.Now; HashMap fileNames = null; /** * at first create missing resources */ if (fileInfos.Length > 0) { fileNames = new HashMap(fileInfos.Length / 2); foreach (FileInfo fileInfo in fileInfos) { fileNames[IOTools.GetName(fileInfo)] = fileInfo; if (IOTools.GetLastWriteTime(fileInfo) > lastUpdated && (_indexHidden || (IOTools.GetAttributes(fileInfo) & FileAttributes.Hidden) == 0)) { FindOrCreateFile(fileInfo, false); } } } /** * then remove obsolete resources */ foreach (IResource child in folder.GetLinksTo(null, FileProxy._propParentFolder).ValidResources) { if (child.Type == FileProxy._folderResourceType) { if (!Directory.Exists(child.GetPropText(FileProxy._propDirectory))) { DeleteResource(child); } } else { if (child.GetPropText(FileProxy._propDirectory) != directory) { new ResourceProxy(child).SetProp(FileProxy._propDirectory, directory); } string name = child.GetPropText(Core.Props.Name); HashMap.Entry E = (fileNames == null) ? null : fileNames.GetEntry(name); /** * check if file exists */ if (E == null) { DeleteResource(child); } else { /** * if exists, check its atributes */ FileInfo fileInfo = (FileInfo)E.Value; if (fileInfo == null || (!_indexHidden && (IOTools.GetAttributes(fileInfo) & FileAttributes.Hidden) != 0)) { DeleteResource(child); } } } } ResourceProxy proxy = new ResourceProxy(folder); proxy.BeginUpdate(); proxy.SetProp(_ftm.propLastModified, updated); proxy.SetProp(FileProxy._propFileType, "Folder"); proxy.EndUpdateAsync(); FileProxy.UpdateFoldersTreePane(folder); } } catch (InvalidResourceIdException) {} catch (ResourceDeletedException) {} }