Esempio n. 1
0
        /// <summary>
        /// Returns a combined INI file formed by merging the specified INI files.
        /// <para>
        /// The result of this method is formed by merging the specified files together.
        /// The files are combined in order forming a chain.
        /// The first file in the list has the lowest priority.
        /// The last file in the list has the highest priority.
        /// </para>
        /// <para>
        /// The algorithm starts with all the sections and properties from the highest priority file.
        /// It then adds any sections or properties from subsequent files that are not already present.
        /// </para>
        /// <para>
        /// The algorithm can be controlled by providing a '[chain]' section.
        /// Within the 'chain' section, if 'chainNextFile' is 'false', then processing stops,
        /// and lower priority files are ignored. If the 'chainRemoveSections' property is specified,
        /// the listed sections are ignored from the files lower in the chain.
        ///
        /// </para>
        /// </summary>
        /// <param name="resources">  the INI file resources to read </param>
        /// <returns> the combined chained INI file </returns>
        /// <exception cref="UncheckedIOException"> if an IO error occurs </exception>
        /// <exception cref="IllegalArgumentException"> if the configuration is invalid </exception>
        public static IniFile combinedIniFile(IList <ResourceLocator> resources)
        {
            ArgChecker.notNull(resources, "resources");
            IDictionary <string, PropertySet> sectionMap = new LinkedHashMap <string, PropertySet>();

            foreach (ResourceLocator resource in resources)
            {
                IniFile file = IniFile.of(resource.CharSource);
                if (file.contains(CHAIN_SECTION))
                {
                    PropertySet chainSection = file.section(CHAIN_SECTION);
                    // remove everything from lower priority files if not chaining
                    if (chainSection.contains(CHAIN_NEXT) && bool.Parse(chainSection.value(CHAIN_NEXT)) == false)
                    {
                        sectionMap.Clear();
                    }
                    else
                    {
                        // remove sections from lower priority files
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method:
                        sectionMap.Keys.removeAll(chainSection.valueList(CHAIN_REMOVE));
                    }
                }
                // add entries, replacing existing data
                foreach (string sectionName in file.asMap().Keys)
                {
                    if (!sectionName.Equals(CHAIN_SECTION))
                    {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                        sectionMap.merge(sectionName, file.section(sectionName), PropertySet::overrideWith);
                    }
                }
            }
            return(IniFile.of(sectionMap));
        }
Esempio n. 2
0
        /// <summary>This method sends the remove stream for all accumulated events. </summary>
        protected void SendRemoveStream()
        {
            _callbackScheduledTime = -1;

            // If there are child views and the batch was filled, fireStatementStopped Update method
            if (HasViews)
            {
                // Convert to object arrays
                EventBean[] oldData = null;
                if (_currentBatch.IsNotEmpty())
                {
                    oldData = _currentBatch.Keys.ToArray();
                }

                if (oldData != null)
                {
                    using (Instrument.With(
                               i => i.QViewIndicate(this, _factory.ViewName, null, oldData),
                               i => i.AViewIndicate()))
                    {
                        UpdateChildren(null, oldData);
                    }
                }
            }

            _currentBatch.Clear();
        }
Esempio n. 3
0
 public void HandleClearAllCaches(ClearAllCachesEvent evnt)
 {
     lock (writeLock)
     {
         privilegeCache.Clear();
         entityTypePrivilegeCache.Clear();
     }
 }
		public void Clear()
		{
			IDictionary<string, Player> lhm = new LinkedHashMap<string, Player>();
			Player p = new Player("78945", "Someone");
			lhm[p.Id] = p;

			lhm.Clear();
			Assert.AreEqual(0, lhm.Count);

			foreach (KeyValuePair<string, Player> pair in lhm)
				Assert.Fail("Should not be any entries but found Key = " + pair.Key + " and Value = " + pair.Value);
		}
Esempio n. 5
0
        public void Clear()
        {
            IDictionary <string, Player> lhm = new LinkedHashMap <string, Player>();
            Player p = new Player("78945", "Someone");

            lhm[p.Id] = p;

            lhm.Clear();
            Assert.AreEqual(0, lhm.Count);

            foreach (KeyValuePair <string, Player> pair in lhm)
            {
                Assert.Fail("Should not be any entries but found Key = " + pair.Key + " and Value = " + pair.Value);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// This method sends the remove stream for all accumulated events.
        /// </summary>
        private void SendRemoveStream()
        {
            _callbackScheduledTime = -1;

            // If there are child views and the batch was filled, fireStatementStopped update method
            var child = Child;
            if (child != null) {
                // Convert to object arrays
                EventBean[] oldData = null;
                if (!_currentBatch.IsEmpty()) {
                    oldData = _currentBatch.Keys.ToArray();
                }

                if (oldData != null) {
                    _agentInstanceContext.InstrumentationProvider.QViewIndicate(_factory, null, oldData);
                    child.Update(null, oldData);
                    _agentInstanceContext.InstrumentationProvider.AViewIndicate();
                }
            }

            _currentBatch.Clear();
        }
		public void Performance()
		{
			// Take care with this test because the result is not the same every times

			int numOfRuns = 4;

			int numOfEntries = Int16.MaxValue;

			long[] dictPopulateTicks = new long[numOfRuns];
			long[] dictItemTicks = new long[numOfRuns];

			long[] linkPopulateTicks = new long[numOfRuns];
			long[] linkItemTicks = new long[numOfRuns];

			for (int runIndex = 0; runIndex < numOfRuns; runIndex++)
			{
				string key;
				object value;
				IDictionary<string, object> dictionary = new Dictionary<string, object>();
				IDictionary<string, object> linked = new LinkedHashMap<string, object>();

				long dictStart = DateTime.Now.Ticks;

				for (int i = 0; i < numOfEntries; i++)
				{
					dictionary.Add("test" + i, new object());
				}

				dictPopulateTicks[runIndex] = DateTime.Now.Ticks - dictStart;

				dictStart = DateTime.Now.Ticks;
				for (int i = 0; i < numOfEntries; i++)
				{
					key = "test" + i;
					value = dictionary[key];
				}
				dictItemTicks[runIndex] = DateTime.Now.Ticks - dictStart;

				dictionary.Clear();

				long linkStart = DateTime.Now.Ticks;

				for (int i = 0; i < numOfEntries; i++)
				{
					linked.Add("test" + i, new object());
				}

				linkPopulateTicks[runIndex] = DateTime.Now.Ticks - linkStart;

				linkStart = DateTime.Now.Ticks;
				for (int i = 0; i < numOfEntries; i++)
				{
					key = "test" + i;
					value = linked[key];
				}

				linkItemTicks[runIndex] = DateTime.Now.Ticks - linkStart;

				linked.Clear();
			}

			for (int runIndex = 0; runIndex < numOfRuns; runIndex++)
			{
				decimal linkPopulateOverhead = (linkPopulateTicks[runIndex] / (decimal)dictPopulateTicks[runIndex]);
				decimal linkItemOverhead = (linkItemTicks[runIndex] / (decimal)dictItemTicks[runIndex]);

				string message = string.Format("LinkedHashMap vs Dictionary (Run-{0}) :",runIndex+1);
				message += "\n POPULATE:";
				message += "\n\t linked took " + linkPopulateTicks[runIndex] + " ticks.";
				message += "\n\t dictionary took " + dictPopulateTicks[runIndex] + " ticks.";
				message += "\n\t for an overhead of " + linkPopulateOverhead;
				message += "\n RETRIVE:";
				message += "\n\t linked took " + linkItemTicks[runIndex] + " ticks.";
				message += "\n\t dictionary took " + dictItemTicks[runIndex] + " ticks.";
				message += "\n\t for an overhead of " + linkItemOverhead;

				Console.Out.WriteLine(message);
				Console.Out.WriteLine();
			}
		}
Esempio n. 8
0
        public void Performance()
        {
            // Take care with this test because the result is not the same every times

            int numOfRuns = 4;

            int numOfEntries = Int16.MaxValue;

            long[] dictPopulateTicks = new long[numOfRuns];
            long[] dictItemTicks     = new long[numOfRuns];

            long[] linkPopulateTicks = new long[numOfRuns];
            long[] linkItemTicks     = new long[numOfRuns];

            for (int runIndex = 0; runIndex < numOfRuns; runIndex++)
            {
                string key;
                object value;
                IDictionary <string, object> dictionary = new Dictionary <string, object>();
                IDictionary <string, object> linked     = new LinkedHashMap <string, object>();

                long dictStart = DateTime.Now.Ticks;

                for (int i = 0; i < numOfEntries; i++)
                {
                    dictionary.Add("test" + i, new object());
                }

                dictPopulateTicks[runIndex] = DateTime.Now.Ticks - dictStart;

                dictStart = DateTime.Now.Ticks;
                for (int i = 0; i < numOfEntries; i++)
                {
                    key   = "test" + i;
                    value = dictionary[key];
                }
                dictItemTicks[runIndex] = DateTime.Now.Ticks - dictStart;

                dictionary.Clear();

                long linkStart = DateTime.Now.Ticks;

                for (int i = 0; i < numOfEntries; i++)
                {
                    linked.Add("test" + i, new object());
                }

                linkPopulateTicks[runIndex] = DateTime.Now.Ticks - linkStart;

                linkStart = DateTime.Now.Ticks;
                for (int i = 0; i < numOfEntries; i++)
                {
                    key   = "test" + i;
                    value = linked[key];
                }

                linkItemTicks[runIndex] = DateTime.Now.Ticks - linkStart;

                linked.Clear();
            }

            for (int runIndex = 0; runIndex < numOfRuns; runIndex++)
            {
                decimal linkPopulateOverhead = (linkPopulateTicks[runIndex] / (decimal)dictPopulateTicks[runIndex]);
                decimal linkItemOverhead     = (linkItemTicks[runIndex] / (decimal)dictItemTicks[runIndex]);

                string message = string.Format("LinkedHashMap vs Dictionary (Run-{0}) :", runIndex + 1);
                message += "\n POPULATE:";
                message += "\n\t linked took " + linkPopulateTicks[runIndex] + " ticks.";
                message += "\n\t dictionary took " + dictPopulateTicks[runIndex] + " ticks.";
                message += "\n\t for an overhead of " + linkPopulateOverhead;
                message += "\n RETRIVE:";
                message += "\n\t linked took " + linkItemTicks[runIndex] + " ticks.";
                message += "\n\t dictionary took " + dictItemTicks[runIndex] + " ticks.";
                message += "\n\t for an overhead of " + linkItemOverhead;

                Console.Out.WriteLine(message);
                Console.Out.WriteLine();
            }
        }
Esempio n. 9
0
 public void Clear()
 {
     RefSet.Clear();
     _array = null;
 }
Esempio n. 10
0
 public void Clear()
 {
     OuterInstance.Clear();
 }
Esempio n. 11
0
        public void Dispose()
        {
            if (disposed || disposing)
            {
                return;
            }
            ILogger log;

            IServiceContext[] childrenCopy = null;
            writeLock.Lock();
            try
            {
                if (disposed || disposing)
                {
                    return;
                }
                log = GetService <ILoggerCache>().GetCachedLogger(this, typeof(ServiceContext));
                if (log.DebugEnabled)
                {
                    // Safe the toString-method for debugging purpose. Because this is not possible anymore if the context
                    // has been disposed and all bean-references have been cleared
                    toStringBackup = StringBuilderUtil.Concat(delegate(StringBuilder sb)
                    {
                        PrintContent(sb);
                    });
                }
                else
                {
                    toStringBackup = "n/a";
                }
                disposing = true;
                if (children != null && children.Count > 0)
                {
                    childrenCopy = new IServiceContext[children.Count];
                    children.CopyTo(childrenCopy, 0);
                    children.Clear();
                }
            }
            finally
            {
                writeLock.Unlock();
            }
            if (childrenCopy != null)
            {
                foreach (IServiceContext childContext in childrenCopy)
                {
                    try
                    {
                        childContext.Dispose();
                    }
                    catch (Exception e)
                    {
                        if (log.ErrorEnabled)
                        {
                            log.Error(e);
                        }
                    }
                }
            }
            writeLock.Lock();
            try
            {
                if (parent != null)
                {
                    parent.ChildContextDisposed(this);
                    parent = null;
                }
                if (this.linkContainers != null)
                {
                    IList <ILinkContainer> linkContainers = this.linkContainers;
                    this.linkContainers = null;
                    for (int a = linkContainers.Count; a-- > 0;)
                    {
                        ILinkContainer listenerContainer = linkContainers[a];
                        try
                        {
                            listenerContainer.Unlink();
                        }
                        catch (System.Exception e)
                        {
                            if (failOnError)
                            {
                                throw;
                            }
                            if (log.ErrorEnabled)
                            {
                                log.Error(e);
                            }
                        }
                    }
                }
                if (this.disposableObjects != null)
                {
                    IList <Object> disposableObjects = this.disposableObjects;
                    this.disposableObjects = null;
                    for (int a = disposableObjects.Count; a-- > 0;)
                    {
                        Object disposableObject = disposableObjects[a];
                        if (disposableObject is WeakReference)
                        {
                            disposableObject = ((WeakReference)disposableObject).Target;
                        }
                        if (disposableObject is IDisposableBean)
                        {
                            try
                            {
                                ((IDisposableBean)disposableObject).Destroy();
                            }
                            catch (System.Exception e)
                            {
                                if (failOnError)
                                {
                                    throw;
                                }
                                if (log.ErrorEnabled)
                                {
                                    log.Error(e);
                                }
                            }
                        }
                        else if (disposableObject is IDisposable)
                        {
                            try
                            {
                                ((IDisposable)disposableObject).Dispose();
                            }
                            catch (System.Exception e)
                            {
                                if (failOnError)
                                {
                                    throw;
                                }
                                if (log.ErrorEnabled)
                                {
                                    log.Error(e);
                                }
                            }
                        }
                        else if (disposableObject is IBackgroundWorkerParamDelegate <IServiceContext> )
                        {
                            try
                            {
                                ((IBackgroundWorkerParamDelegate <IServiceContext>)disposableObject).Invoke(this);
                            }
                            catch (System.Exception e)
                            {
                                if (failOnError)
                                {
                                    throw;
                                }
                                if (log.ErrorEnabled)
                                {
                                    log.Error(e);
                                }
                            }
                        }
                    }
                }

                if (nameToServiceDict != null)
                {
                    nameToServiceDict.Clear();
                }
                typeToServiceDict.Clear();
                if (postProcessors != null)
                {
                    postProcessors.Clear();
                }
                if (preProcessors != null)
                {
                    preProcessors.Clear();
                }
                beanContextFactory.Dispose();
            }
            finally
            {
                writeLock.Unlock();
                beanContextFactory = null;
                linkContainers     = null;
                nameToServiceDict  = null;
                postProcessors     = null;
                preProcessors      = null;
                parent             = null;
                disposed           = true;
                running            = false;
            }
        }
 public virtual void Clear()
 {
     refSet.Clear();
     _array = null;
 }
Esempio n. 13
0
 public static void Reset()
 {
     index = 0;
     time.Clear();
     count.Clear();
 }