public static CacheModel Deserialize(XmlNode node, ConfigurationScope configScope)
        {
            CacheModel          model      = new CacheModel();
            NameValueCollection attributes = NodeUtils.ParseAttributes(node, configScope.Properties);

            model.Id             = NodeUtils.GetStringAttribute(attributes, "id");
            model.Implementation = NodeUtils.GetStringAttribute(attributes, "implementation");
            model.Implementation = configScope.SqlMapper.TypeHandlerFactory.GetTypeAlias(model.Implementation).Class.AssemblyQualifiedName;
            model.IsReadOnly     = NodeUtils.GetBooleanAttribute(attributes, "readOnly", true);
            model.IsSerializable = NodeUtils.GetBooleanAttribute(attributes, "serialize", false);
            int count = node.ChildNodes.Count;

            for (int i = 0; i < count; i++)
            {
                if (node.ChildNodes[i].LocalName == "flushInterval")
                {
                    FlushInterval       interval = new FlushInterval();
                    NameValueCollection values2  = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties);
                    interval.Hours        = NodeUtils.GetIntAttribute(values2, "hours", 0);
                    interval.Milliseconds = NodeUtils.GetIntAttribute(values2, "milliseconds", 0);
                    interval.Minutes      = NodeUtils.GetIntAttribute(values2, "minutes", 0);
                    interval.Seconds      = NodeUtils.GetIntAttribute(values2, "seconds", 0);
                    model.FlushInterval   = interval;
                }
            }
            return(model);
        }
Пример #2
0
 public override string ToString() => new ToStringBuilder("")
 {
     { nameof(ArgsIndex), ArgsIndex },
     { nameof(MaxQueueEventCount), MaxQueueEventCount },
     { nameof(MaxBatchEventCount), MaxBatchEventCount },
     { nameof(FlushInterval), (FlushInterval?.ToHms()).AsNullableToString() }
 }.ToString();
Пример #3
0
            public virtual IReporter GetReporter(IMetrics metrics)
            {
                IReporter reporter = new RemoteReporter.Builder()
                                     .WithLoggerFactory(_loggerFactory)
                                     .WithMetrics(metrics)
                                     .WithSender(SenderConfig.GetSender())
                                     .WithFlushInterval(FlushInterval.GetValueOrDefault(RemoteReporter.DefaultFlushInterval))
                                     .WithMaxQueueSize(MaxQueueSize.GetValueOrDefault(RemoteReporter.DefaultMaxQueueSize))
                                     .Build();

                if (LogSpans)
                {
                    IReporter loggingReporter = new LoggingReporter(_loggerFactory);
                    reporter = new CompositeReporter(reporter, loggingReporter);
                }
                return(reporter);
            }
Пример #4
0
        /// <summary>
        /// Returns copy of cached object
        /// </summary>
        public void TestReturnCopyOfCachedOject()
        {
            ICacheController cacheController = new LruCacheController();
            IDictionary      props           = new HybridDictionary();

            props.Add("CacheSize", "1");
            cacheController.Configure(props);

            FlushInterval interval = new FlushInterval();

            interval.Hours = 1;
            interval.Initialize();

            CacheModel cacheModel = new CacheModel();

            cacheModel.FlushInterval   = interval;
            cacheModel.CacheController = cacheController;
            cacheModel.IsReadOnly      = false;
            cacheModel.IsSerializable  = true;

            Order order = new Order();

            order.CardNumber          = "CardNumber";
            order.Date                = DateTime.Now;
            order.LineItemsCollection = new LineItemCollection();
            LineItem item = new LineItem();

            item.Code = "Code1";
            order.LineItemsCollection.Add(item);
            item      = new LineItem();
            item.Code = "Code2";
            order.LineItemsCollection.Add(item);

            CacheKey key = new CacheKey();

            key.Update(order);

            int firstId = HashCodeProvider.GetIdentityHashCode(order);

            cacheModel[key] = order;

            Order order2   = cacheModel[key] as Order;
            int   secondId = HashCodeProvider.GetIdentityHashCode(order2);

            Assert.AreNotEqual(firstId, secondId, "hasCode equal");
        }