Пример #1
0
        public CrawlerContext()
        {
            CommandQueue = new SynchronizedCollection<Command>();

            CrawledCreators = new SynchronizedSet<string>(new HashedSet<string>());
            CrawledIdentifiers = new SynchronizedSet<string>(new HashedSet<string>());
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StrategyNameGenerator"/>.
        /// </summary>
        /// <param name="strategy">Strategy.</param>
        public StrategyNameGenerator(Strategy strategy)
        {
            _strategy = strategy ?? throw new ArgumentNullException(nameof(strategy));
            _strategy.PropertyChanged += (s, e) =>
            {
                if (_selectors.Contains(e.PropertyName))
                {
                    Refresh();
                }
            };

            ShortName = new string(_strategy.GetType().Name.Where(char.IsUpper).ToArray());

            _formatter = Smart.CreateDefaultSmartFormat();
            _formatter.SourceExtensions.Add(new Source(_formatter, new Dictionary <string, string>
            {
                { "FullName", _strategy.GetType().Name },
                { nameof(ShortName), ShortName },
            }));

            _selectors = new SynchronizedSet <string>();

            AutoGenerateStrategyName = true;
            Pattern = "{ShortName}{Security:_{0.Security}|}{Portfolio:_{0.Portfolio}|}";
        }
        protected Collections.ISet <ContextEventListener> getMaskListeners(String mask, String eventString)
        {
            var cel = getContextMaskListeners(mask);

            var eel = cel[eventString];

            if (eel == null)
            {
                eel = new SynchronizedSet <ContextEventListener>(new ListSet <ContextEventListener>());
                cel.Add(eventString, eel);
            }

            return(eel);
        }
Пример #4
0
        public ConcurrentSet(IEnumerable <T> collection, IEqualityComparer <T> comparer)
        {
            var hashSet = collection is HashSet <T> actualSet && Equals(actualSet.Comparer, comparer) ? actualSet : new HashSet <T>(collection, comparer);

            set = new SynchronizedSet <T>(hashSet);
        }
Пример #5
0
 public ConcurrentSet(IEnumerable <T> collection)
 {
     set = new SynchronizedSet <T>(collection.AsHashSet());
 }
Пример #6
0
 public ConcurrentSet(IEqualityComparer <T> comparer)
 {
     set = new SynchronizedSet <T>(new HashSet <T>(comparer));
 }
Пример #7
0
 public ConcurrentSet()
 {
     set = new SynchronizedSet <T>(new HashSet <T>());
 }
        //-----------------------------------------------------------------------

        /**
         * Returns a synchronized set backed by the given set.
         * <p>
         * You must manually synchronize on the returned buffer's iterator to
         * avoid non-deterministic behavior:
         *
         * <pre>
         * Set s = SetUtils.synchronizedSet(mySet);
         * synchronized (s) {
         *     Iterator i = s.iterator();
         *     while (i.hasNext()) {
         *         process (i.next());
         *     }
         * }
         * </pre>
         *
         * This method uses the implementation in the decorators subpackage.
         *
         * @param set  the set to synchronize, must not be null
         * @return a synchronized set backed by the given set
         * @throws IllegalArgumentException  if the set is null
         */
        public static java.util.Set <Object> synchronizedSet(java.util.Set <Object> set)
        {
            return(SynchronizedSet.decorate(set));
        }
Пример #9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="StrategyNameGenerator"/>.
		/// </summary>
		/// <param name="strategy">Strategy.</param>
		public StrategyNameGenerator(Strategy strategy)
		{
			if (strategy == null)
				throw new ArgumentNullException("strategy");

			_strategy = strategy;
			_strategy.SecurityChanged += () =>
			{
				if (_selectors.Contains("Security"))
					Refresh();
			};
			_strategy.PortfolioChanged += () =>
			{
				if (_selectors.Contains("Portfolio"))
					Refresh();
			};

			ShortName = new string(_strategy.GetType().Name.Where(char.IsUpper).ToArray());

			_formatter = Smart.CreateDefaultSmartFormat();
			_formatter.SourceExtensions.Add(new Source(_formatter, new Dictionary<string, string>
			{
				{ "FullName", _strategy.GetType().Name },
				{ "ShortName", ShortName },
			}));

			_selectors = new SynchronizedSet<string>();

			AutoGenerateStrategyName = true;
			Pattern = "{ShortName}{Security:_{0.Security}|}{Portfolio:_{0.Portfolio}|}";
		}