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 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 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); }
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); } } } }
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 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 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 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); } }
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 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 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 string GetSearchProviderTitle(ISearchProvider host) { HashMap.Entry e = _SearchProviders.GetEntry(host); return((e == null) ? null : (String)((Pair)e.Value).First); }
public static DateTime ParseDate(string dateStr) { if (dateStr.EndsWith(")")) { int ppos = dateStr.LastIndexOf("("); if (ppos >= 0) { dateStr = dateStr.Substring(0, ppos).Trim(); } } // strip weekdat int weekdayIndex = dateStr.IndexOf(","); if (weekdayIndex == 3 && Char.IsLetter(dateStr, 0) && Char.IsLetter(dateStr, 1) && Char.IsLetter(dateStr, 2)) { dateStr = dateStr.Substring(4).Trim(); } int tzHours = 0; int tzMinutes = 0; int pos = dateStr.LastIndexOf(' '); if (pos >= 0) { string tz = dateStr.Substring(pos + 1).Trim(); if (tz.Length > 0) { if (tz [0] != '+' && tz [0] != '-') { HashMap.Entry entry = _timeZones.GetEntry(tz); if (entry != null) { tzHours = (int)entry.Value; } } else { int tzModifier = (tz [0] == '-') ? 1 : -1; tzHours = Int32.Parse(tz.Substring(1, 2)) * tzModifier; tzMinutes = Int32.Parse(tz.Substring(3, 2)) * tzModifier; } dateStr = dateStr.Substring(0, pos + 1) + "GMT"; } } string[] words = dateStr.Split(' '); bool wordsChanged = false; if (words.Length >= 1 && words [0].Length == 1) { words [0] = '0' + words [0]; wordsChanged = true; } if (words.Length >= 3 && words [2].Length == 2) { words [2] = DateTime.ParseExact(words [2], "yy", _cultureInfo).Year.ToString(); wordsChanged = true; } if (wordsChanged) { dateStr = String.Join(" ", words); } DateTime dt = DateTime.ParseExact(dateStr, "dd MMM yyyy HH':'mm':'ss 'GMT'", _cultureInfo); dt = dt.AddHours(tzHours); dt = dt.AddMinutes(tzMinutes); return(dt.ToLocalTime()); }
public override void Execute(IActionContext context) { IResourceStore store = Core.ResourceStore; IResourceList articles = store.GetAllResources("Article").Minus( store.FindResourcesWithProp(null, Core.Props.IsDeleted)); IResourceList resources = context.SelectedResources; if (!resources.AllResourcesOfType("NewsGroup")) { resources = null; } IStatusWriter writer = Core.UIManager.GetStatusWriter(this, StatusPane.UI); try { HashMap readers = new HashMap(); int i = 0; int percent = -1; foreach (IResource article in articles) { int p = (i++ *100) / articles.Count; if (p > percent) { percent = p; writer.ShowStatus("Looking through news articles: " + percent.ToString() + "%"); Application.DoEvents(); } if (resources != null && article.GetLinksOfType("NewsGroup", "Newsgroups").Intersect(resources).Count == 0) { continue; } string[] headers = article.GetPropText("MessageHeaders").Split('\n'); string reader = null; foreach (string headerLine in headers) { if (headerLine.StartsWith("X-Newsreader: ")) { reader = headerLine.Substring("X-Newsreader: ".Length).TrimEnd('\r', '\n'); } else if (headerLine.StartsWith("User-Agent: ")) { reader = headerLine.Substring("User-Agent: ".Length).TrimEnd('\r', '\n'); } if (reader != null) { for (int j = 1; j < reader.Length; ++j) { if (Char.IsDigit(reader[j])) { reader = reader.Substring(0, j - 1); break; } } reader = reader.Trim(); if (reader.Length == 0) { break; } HashMap.Entry entry = readers.GetEntry(reader); if (entry == null) { readers[reader] = 1; } else { entry.Value = ((int)entry.Value) + 1; } break; } } } PriorityQueue queue = new PriorityQueue(); foreach (HashMap.Entry e in readers) { queue.Push((int)e.Value, e.Key); } StringBuilder readersStat = new StringBuilder(); foreach (PriorityQueue.QueueEntry e in queue) { readersStat.Append("\r\n"); readersStat.Append(e.Value); readersStat.Append(": "); readersStat.Append(e.Key); } MessageBox.Show(readersStat.ToString(), "News Readers Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { writer.ClearStatus(); } }