Пример #1
0
        private void SingleConsumerManualLoop(object obj)
        {
            var state = (Tuplet <int, IBlockingQueue <string>, List <string>, ManualResetEvent>)obj;

            for (int i = 0; i < state.Item1; i++)
            {
                string guid = state.Item2.Dequeue();
                if (guid == null)
                {
                    _log.WarnMethodCall("guid is null");
                }
                Assert.IsNotNull(guid);
                state.Item3.Add(guid);
            }
            state.Item4.Set();
        }
Пример #2
0
 private void CommentChanged(DateTime eventTime, CommentBE comment, PageBE parent, UserBE user, params string[] channelPath)
 {
     try {
         XUri     channel  = _channel.At(COMMENTS).At(channelPath);
         XUri     resource = CommentBL.GetUri(comment).WithHost(_wikiid);
         string[] origin   = new string[] { CommentBL.GetUri(comment).AsServerUri().ToString() };
         string   path     = parent.Title.AsUiUriPath() + "#comment" + comment.Number;
         XDoc     doc      = new XDoc("deki-event")
                             //userid is deprecated and user/id should be used instead
                             .Elem("userid", comment.PosterUserId)
                             .Elem("pageid", comment.PageId)
                             .Elem("uri.page", PageBL.GetUriCanonical(parent).AsServerUri().ToString())
                             .Start("user")
                             .Attr("id", user.ID)
                             .Attr("anonymous", UserBL.IsAnonymous(user))
                             .Elem("uri", UserBL.GetUri(user))
                             .End()
                             .Elem("channel", channel)
                             .Elem("uri", CommentBL.GetUri(comment).AsServerUri().ToString())
                             .Elem("path", path)
                             .Start("content").Attr("uri", CommentBL.GetUri(comment).AsServerUri().At("content").ToString()).End();
         if (comment.Content.Length < 255)
         {
             doc["content"].Attr("type", comment.ContentMimeType).Value(comment.Content);
         }
         Queue(eventTime, channel, resource, origin, doc);
     } catch (Exception e) {
         _log.WarnMethodCall("CommentChanged", "event couldn't be created");
     }
 }
        //--- Methods ---
        public IDictionaryEnumerator GetEnumerator()
        {
            Dictionary <String, String> resources = new Dictionary <String, String>();

            if (System.IO.File.Exists(_filename))
            {
                char[]   brackets = new char[] { ']' };
                char[]   equals   = new char[] { '=' };
                string[] parts;

                // read the file into the hashtable
                using (StreamReader sr = new StreamReader(_filename, System.Text.Encoding.UTF8, true)) {
                    int    count   = 0;
                    string section = null;
                    for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
                    {
                        line = line.TrimStart();
                        ++count;

                        // check if line is a comment
                        if (line.StartsWith(";"))
                        {
                            continue;
                        }

                        // check if line is a new section
                        if (line.StartsWith("["))
                        {
                            parts = line.Substring(1).Split(brackets, 2);
                            if (!string.IsNullOrEmpty(parts[0]))
                            {
                                section = parts[0].Trim();
                            }
                            else
                            {
                                section = null;
                                _log.WarnMethodCall("missing namespace name", _filename, count);
                            }
                            continue;
                        }

                        // parse the line as key=value
                        parts = line.Split(equals, 2);
                        if (parts.Length == 2)
                        {
                            if (!string.IsNullOrEmpty(parts[0]))
                            {
                                string key;

                                // check if a section is defined
                                if (section != null)
                                {
                                    key = section + "." + parts[0];
                                }
                                else
                                {
                                    key = parts[0];
                                    _log.WarnMethodCall("missing namespace prefix", _filename, count, parts[0]);
                                }

                                // check if key already exists
                                if (resources.ContainsKey(key))
                                {
                                    _log.WarnMethodCall("duplicate key", _filename, count, key);
                                }
                                resources[key] = PhpUtil.ConvertToFormatString(parts[1]);
                            }
                            else
                            {
                                _log.WarnMethodCall("empty key", _filename, count, line);
                            }
                        }
                        else if (line != string.Empty)
                        {
                            _log.WarnMethodCall("bad key/value pair", _filename, count, line);
                        }
                    }
                    sr.Close();
                }
            }
            return(resources.GetEnumerator());
        }