Example #1
0
 public override void Dispose()
 {
     base.Dispose();
     _elmItems   = null;
     _elmTitle   = null;
     _elmWrapper = null;
 }
Example #2
0
        public void CheckReportCreation(List <string> text, string expected)
        {
            UnorderedList testObject = new UnorderedList(text);
            string        actual     = testObject.Create();

            Assert.Equal(expected, actual);
        }
Example #3
0
            /// <summary>
            /// Creates a new system. Entities are added to the system based on if they pass the
            /// given filter.
            /// </summary>
            public EntityCache(Filter filter)
            {
                _filter      = filter;
                _metadataKey = EntityManagerMetadata.GetUnorderedListMetadataIndex();

                CachedEntities = new UnorderedList <IEntity>();
            }
Example #4
0
 public void Dispose()
 {
     _elmMain              = null;
     _elmTitle             = null;
     _elmTabTitleContainer = null;
     _tabCount             = 0;
 }
Example #5
0
        protected virtual void Awake()
        {
            State            = CC_State.None;
            WaterState       = CC_Water.None;
            Collisions       = CC_Collision.None;
            jumpGraceTimer   = Profile.JumpGraceTime;
            TriedJumping     = 0;
            ignoredColliders = new UnorderedList <Collider>();

            if (controllerView)
            {
                localViewPosition = originalViewPosition = controllerView.localPosition;
            }

            SetupCollider();
            SetupRigidbody();

            // load custom movements
            if (autoFillMovements)
            {
                retroMovements = GetComponentsInChildren <RetroMovement>();
            }

            for (int i = 0; i < retroMovements.Length; i++)
            {
                retroMovements[i].OnAwake(this);
            }

            FixedPosition   = transform.position;
            FixedUpdateTime = Time.time;
        }
Example #6
0
 void IListPool <T> .Release(ref UnorderedList <T> _list)
 {
     // HACK: Render manager wakes the thread pool before waiting so at worst
     //  we will wait until the end of the frame to clear and return lists, which
     //  is way better than constantly burning cycles waking the thread group
     Release(ref _list, WorkQueueNotifyMode.Never);
 }
Example #7
0
        public UnorderedList <T> Allocate(int?capacity, bool capacityIsHint = false)
        {
            UnorderedList <T> result = null;

            var isBig = capacity.HasValue &&
                        (capacity.Value > SmallPoolMaxItemSize);

            if (
                (LargePoolCapacity > 0) && isBig
                )
            {
                if (_LargePool.Count > 0)
                {
                    lock (_LargePool)
                        _LargePool.TryPopFront(out result);
                }
            }

            if (capacityIsHint || !isBig || (LargePoolCapacity <= 0))
            {
                if (_Pool.Count > 0)
                {
                    lock (_Pool)
                        _Pool.TryPopFront(out result);
                }
            }

            if (result == null)
            {
                result = new UnorderedList <T>(capacity.GetValueOrDefault(InitialItemSize), Allocator);
            }

            return(result);
        }
Example #8
0
 void CreateUnorderedList(UnorderedList ul)
 {
     for (int i = 0; i < ul.Items.Length; i++)
     {
         CreateUIElement(ul.Items[i].Element);
     }
 }
Example #9
0
        public void Release(ref UnorderedList <T> _list)
        {
            var list = _list;

            _list = null;

            if (list == null)
            {
                return;
            }

            if (list.Capacity > MaxItemCapacity)
            {
                lock (_LargePool) {
                    if (_LargePool.Count >= LargePoolCapacity)
                    {
                        return;
                    }

                    _LargePool.Add(list);
                }

                return;
            }

            lock (_Pool) {
                if (_Pool.Count >= PoolCapacity)
                {
                    return;
                }

                _Pool.Add(list);
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            _ = new Header();
            _ = new UnorderedList();
            _ = new StringBuilder();


            string moreText = string1 + string2;

            Console.WriteLine(moreText);


            //with string builder
            StringBuilder paragraph = new StringBuilder();

            paragraph.Append(string1);
            paragraph.Append(string2);
            paragraph.Append("Adding yet more text. ");

            Console.WriteLine(paragraph.ToString());

            StringBuilder htmlText = new StringBuilder();



            string bodyOpen         = "<body>";
            string bodyClose        = "</body>";
            string headingOpen      = "<h1>";
            string headingClose     = "</h1>";
            string UnorderListOpen  = "<ul>";
            string UnorderListClose = "</ul>";


            string pOpen  = "<p>";
            string pClose = "</p>";

            Console.WriteLine("Enter some text you want to put on your web page.");
            string dynamicHTML = Console.ReadLine();

            Console.WriteLine("Enter some text for your first item");
            _ = Console.ReadLine();
            Console.WriteLine("Enter some text for your second item");
            _ = Console.ReadLine();



            htmlText.Append(bodyOpen);
            htmlText.Append(pOpen);
            htmlText.Append(headingOpen);
            htmlText.Append(headingClose);
            htmlText.Append(UnorderListOpen);
            htmlText.Append(UnorderListClose);


            htmlText.Append(dynamicHTML);
            htmlText.Append(pClose);
            htmlText.Append(bodyClose);
            mywriter.CreateHTML(htmlText);
        }
Example #11
0
 internal void Initialize(RenderManager renderManager, int index)
 {
     Batches           = _ListPool.Allocate(null);
     RenderManager     = renderManager;
     Index             = index;
     InitialBatchCount = Batch.LifetimeCount;
     State             = State_Initialized;
 }
Example #12
0
        public IHtmlControl Create(Item control)
        {
            var ul = new UnorderedList {
                Items = control.TableValue
            };

            return(ul);
        }
Example #13
0
        new protected void Initialize(
            IBatchContainer container, int layer, Material material,
            int?capacity = null
            )
        {
            base.Initialize(container, layer, material);

            _DrawCalls = _ListPool.Allocate(capacity);
        }
Example #14
0
        UnorderedList listWithCode(string[] arr)
        {
            var ul = new UnorderedList();

            foreach (var x in arr)
            {
                ul.AddItem($"<code>{x}</code>");
            }
            return(ul);
        }
Example #15
0
 /// <summary>
 /// Create a new Updater. The current thread will be considered the main thread.
 /// </summary>
 public Updater(Action <Exception> onException, int initialSize = 16, int stepIncrement = 16)
 {
     this.onException = onException;
     mainThread       = Thread.CurrentThread;
     for (int i = 0; i < recurrentCallbacks.Length; i++)
     {
         recurrentCallbacks[i] = new UnorderedList <ActionWrapped>(initialSize, stepIncrement);
         delayedRemoves[i]     = new UnorderedList <UpdateReference>(initialSize, stepIncrement);
     }
 }
Example #16
0
        /// <summary>
        /// Named "Attempt" because it is a valid case if the DOM element is not present in the DOM.
        /// This is unlike all the components whose DOM elements are expected to be there and
        /// it is a bug if they are not when Attach() is called.
        /// </summary>
        internal void AttemptAttachDOMElements()
        {
            ListItem elm = (ListItem)Browser.Document.GetById(Id);

            if (!CUIUtility.IsNullOrUndefined(elm))
            {
                _elmMain              = elm;
                _elmTitle             = (Div)_elmMain.ChildNodes[0].ChildNodes[0];
                _elmTabTitleContainer = (UnorderedList)_elmMain.ChildNodes[1];
            }
        }
            public static void Free(UnorderedList <T> queue)
            {
                queue.Clear();

                if (UnusedLists.Count > Capacity)
                {
                    return;
                }

                UnusedLists.Add(queue);
            }
Example #18
0
        public override void VisitAttributeEntry(AttributeEntry attributeEntry)
        {
            if (attributeEntry.Name == "includes-from-dirs")
            {
                var thisFileUri = new Uri(_destination.FullName);
                var directories = attributeEntry.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var counter     = 1;

                foreach (var file in DirectoryFiles(directories))
                {
                    var fileInfo          = new FileInfo(file);
                    var referencedFileUri = new Uri(fileInfo.FullName);
                    var relativePath      = thisFileUri.MakeRelativeUri(referencedFileUri);
                    var include           = new Include(relativePath.OriginalString);

                    if (attributeEntry.Parent != null)
                    {
                        attributeEntry.Parent.Insert(attributeEntry.Parent.IndexOf(attributeEntry) + counter, include);
                        ++counter;
                    }
                    else
                    {
                        _document.Add(include);
                    }
                }
            }
            else if (attributeEntry.Name == "anchor-list")
            {
                var directories = attributeEntry.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var list        = new UnorderedList();

                foreach (var file in DirectoryFiles(directories))
                {
                    var fileInfo = new FileInfo(file);
                    var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name);

                    list.Items.Add(new UnorderedListItem
                    {
                        new Paragraph(new InternalAnchor(fileNameWithoutExtension, fileNameWithoutExtension.LowercaseHyphenToPascal()))
                    });
                }

                if (attributeEntry.Parent != null)
                {
                    attributeEntry.Parent.Insert(attributeEntry.Parent.IndexOf(attributeEntry) + 1, list);
                }
                else
                {
                    _document.Add(list);
                }
            }

            base.VisitAttributeEntry(attributeEntry);
        }
Example #19
0
        public void Release(ref UnorderedList <T> _list)
        {
            var list = _list;

            _list = null;

            if (list == null)
            {
                return;
            }

            if (list.Capacity > SmallPoolMaxItemSize)
            {
                if (list.Capacity < LargePoolMaxItemSize)
                {
                    lock (_LargePool) {
                        if (_LargePool.Count >= LargePoolCapacity)
                        {
                            return;
                        }
                    }

                    list.Clear();

                    lock (_LargePool) {
                        if (_LargePool.Count >= LargePoolCapacity)
                        {
                            return;
                        }

                        _LargePool.Add(list);
                    }
                }

                return;
            }

            lock (_Pool) {
                if (_Pool.Count >= SmallPoolCapacity)
                {
                    return;
                }
            }

            list.Clear();

            lock (_Pool) {
                if (_Pool.Count >= SmallPoolCapacity)
                {
                    return;
                }
                _Pool.Add(list);
            }
        }
Example #20
0
        UnorderedList htmlListPerms(ChannelPermission?channel, GuildPermission?guild)
        {
            var perms = listPerms(channel, guild);
            var ul    = new UnorderedList();

            foreach (var x in perms)
            {
                ul.AddItem(x);
            }
            return(ul);
        }
Example #21
0
        /// <summary>
        /// Write an unordered list to the console.
        /// </summary>
        /// <param name="unorderedList">The unordered list to write to console.</param>
        public void Write(UnorderedList unorderedList)
        {
            if (unorderedList == null)
            {
                throw new ArgumentNullException(nameof(unorderedList));
            }

            foreach (var item in unorderedList.Items)
            {
                WriteLine($"{unorderedList.ItemPrefix}{item}", unorderedList.ItemColor);
            }
        }
Example #22
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <string> text = new List <string>();

            DA.GetDataList(0, text);

            string        report;
            UnorderedList reportObject = new UnorderedList(text);

            report = reportObject.Create();

            DA.SetData(0, report);
        }
Example #23
0
        public void AddItems () {
            var l = new UnorderedList<int>();

            l.Add(0);
            l.Add(2);
            l.Add(3);
            l.Add(5);

            Assert.AreEqual(
                new int[] { 0, 2, 3, 5 },
                l.ToArray()
            );                
        }
Example #24
0
        private void AddChild(CancellationScope child)
        {
            if (this == Null)
            {
                return;
            }

            if (Children == null)
            {
                Children = new UnorderedList <CancellationScope>();
            }

            Children.Add(child);
        }
Example #25
0
 public void Dispose()
 {
     _Count = 0;
     Item1  = Item2 = Item3 = Item4 = default(T);
     if (ListPool != null)
     {
         ListPool.Release(ref Items);
     }
     else
     {
         Items = null;
     }
     _HasList = false;
 }
Example #26
0
        public void MutableEnumerator () {
            var l = new UnorderedList<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            using (var e = l.GetEnumerator())
            while (e.MoveNext()) {
                if ((e.Current % 2) == 0)
                    e.RemoveCurrent();
            }

            Assert.AreEqual(
                new int[] { 1, 9, 3, 7, 5 },
                l.ToArray()
            );
        }
Example #27
0
        public void RemoveAt () {
            var l = new UnorderedList<int>(new int[] { 1, 2, 3, 4, 5 });

            l.RemoveAt(1);
            Assert.AreEqual(
                new int[] { 1, 5, 3, 4 },
                l.ToArray()
            );

            l.RemoveAt(2);
            Assert.AreEqual(
                new int[] { 1, 5, 4 },
                l.ToArray()
            );
        }
        public override void Prepare()
        {
            if (Count > 0)
            {
#if PSM
                _BufferGenerator = Container.RenderManager.GetBufferGenerator <PSMBufferGenerator <GeometryVertex> >();
#else
                _BufferGenerator = Container.RenderManager.GetBufferGenerator <XNABufferGenerator <GeometryVertex> >();
#endif

                _DrawArguments = _DrawArgumentsListPool.Allocate(null);
                var swb = _BufferGenerator.Allocate(VertexCount, IndexCount, true);
                _SoftwareBuffer = swb;

                var vb = new Internal.VertexBuffer <GeometryVertex>(swb.Vertices);
                var ib = new Internal.IndexBuffer(swb.Indices);
                int vertexOffset = 0, indexOffset = 0;

                foreach (var kvp in Lists)
                {
                    var l = kvp.Value;
                    var c = l.Count;

#if PSM
                    l.Timsort(_DrawCallSorter);
#else
                    l.Sort(_DrawCallSorter);
#endif

                    int vertexCount = vb.Count, indexCount = ib.Count;

                    var _l = l.GetBuffer();
                    for (int i = 0; i < c; i++)
                    {
                        var dc = _l[i];
                        dc.Preparer(ref vb, ref ib, ref dc);
                    }

                    vertexCount = vb.Count - vertexCount;
                    indexCount  = ib.Count - indexCount;

                    MakeDrawArguments(kvp.Key, ref vb, ref ib, ref vertexOffset, ref indexOffset, vertexCount, indexCount);
                }

                int done = 0;
                done = 1;
            }
        }
Example #29
0
        public override void Prepare()
        {
            if (_DrawCalls.Count == 0)
            {
                return;
            }

            if (_NativeBatches == null)
            {
                // If the batch contains a lot of draw calls, try to make sure we allocate our native batch from the large pool.
                int?nativeBatchCapacity = null;
                if (_DrawCalls.Count >= BatchCapacityLimit)
                {
                    nativeBatchCapacity = Math.Min(NativeBatchCapacityLimit + 2, _DrawCalls.Count / 8);
                }

                _NativeBatches = _NativePool.Allocate(nativeBatchCapacity);
            }

            var sorter =
                UseZBuffer ? DrawCallTextureComparer : DrawCallComparer;

            // FIXME: This sort takes a *TON* of time on large element sets with many identical elements.
            // Use a merge sort, perhaps? Good worst-case time.
#if PSM
            _DrawCalls.Timsort(sorter);
#else
            _DrawCalls.Sort(sorter);
#endif

            var count = _DrawCalls.Count;

#if PSM
            _BufferGenerator = Container.RenderManager.GetBufferGenerator <PSMBufferGenerator <BitmapVertex> >();
#else
            _BufferGenerator = Container.RenderManager.GetBufferGenerator <XNABufferGenerator <BitmapVertex> >();
#endif

            var _drawCalls        = _DrawCalls.GetBuffer();
            int drawCallsPrepared = 0;

            while (drawCallsPrepared < count)
            {
                FillOneSoftwareBuffer(_drawCalls, ref drawCallsPrepared, count);
            }

            _Prepared = true;
        }
Example #30
0
        public void Clear () {
            var l = new UnorderedList<int>(new int[] { 1, 2 });

            l.Clear();
            Assert.AreEqual(
                new int[0],
                l.ToArray()
            );

            l.Add(1);
            l.Add(2);
            Assert.AreEqual(
                new int[] { 1, 2 },
                l.ToArray()
            );
        }
Example #31
0
        public void MutableEnumeratorRemoveCurrentAndGetNext()
        {
            var l = new UnorderedList<int>();
            l.Add(1);
            l.Add(2);

            int item;
            using (var e = l.GetEnumerator())
            while (e.GetNext(out item))
                e.RemoveCurrent();

            Assert.AreEqual(
                new int[] { },
                l.ToArray()
            );
        }
        public void When_rendering_UnorderedList_Then_is_built_properly()
        {
            var dates   = new DateTime[] { new DateTime(2011, 09, 01), new DateTime(2011, 09, 02), new DateTime(2011, 09, 03) };
            var control = new UnorderedList <DateTime>(dates, d => d.ToString("yyyy-MM-dd"), d => "class-" + d.Day);

            string actual  = control.ToString();
            var    element = this.GetHtmlNode(actual);

            var nodes = element.ChildNodes.Where(c => c.NodeType == HtmlNodeType.Element).ToList();

            Assert.That(element.Name, Is.EqualTo("ul"));
            for (int i = 0; i < dates.Length; i++)
            {
                var node = nodes[i];
                Assert.That(node.Name, Is.EqualTo("li"));
                Assert.That(node.Attributes["class"].Value, Is.EqualTo("class-" + dates[i].Day));
                Assert.That(node.InnerText.Trim(), Is.EqualTo(dates[i].ToString("yyyy-MM-dd")));
            }
        }
            public static UnorderedList <T> Allocate(int?initialCapacity = null)
            {
                UnorderedList <T> result;

                if (!UnusedLists.TryTake(out result))
                {
                    if (initialCapacity.HasValue)
                    {
                        result = new UnorderedList <T>(initialCapacity.Value);
                    }
                    else
                    {
                        result = new UnorderedList <T>();
                    }
                }

                result.Clear();
                return(result);
            }
Example #34
0
        protected override void Prepare(PrepareManager manager)
        {
            if (Count > 0)
            {
                _BufferGenerator = Container.RenderManager.GetBufferGenerator <BufferGenerator <GeometryVertex> >();

                _DrawArguments = _DrawArgumentsListPool.Allocate(null);
                var swb = _BufferGenerator.Allocate(VertexCount, IndexCount, true);
                _SoftwareBuffer = swb;

                var vb = new Internal.VertexBuffer <GeometryVertex>(swb.Vertices);
                var ib = new Internal.IndexBuffer(swb.Indices);
                int vertexOffset = 0, indexOffset = 0;
                int totalPrimCount = 0;

                foreach (var kvp in Lists)
                {
                    var l = kvp.Value;
                    var c = l.Count;

                    l.FastCLRSort(_DrawCallSorter);

                    int vertexCount = vb.Count, indexCount = ib.Count;

                    var _l = l.GetBuffer();
                    for (int i = 0; i < c; i++)
                    {
                        var dc = _l[i];
                        dc.Preparer(ref vb, ref ib, ref dc);
                    }

                    vertexCount = vb.Count - vertexCount;
                    indexCount  = ib.Count - indexCount;

                    int primCount;
                    MakeDrawArguments(kvp.Key, ref vb, ref ib, ref vertexOffset, ref indexOffset, out primCount, vertexCount, indexCount);

                    totalPrimCount += primCount;
                }

                NativeBatch.RecordPrimitives(totalPrimCount);
            }
        }
Example #35
0
        private void CreateList(int?capacity = null)
        {
            if (!capacity.HasValue)
            {
                capacity = ListCapacity;
            }

            _HasList = true;
            if (ListPool != null)
            {
                Items = ListPool.Allocate(capacity);
            }
            else if (capacity.HasValue)
            {
                Items = new UnorderedList <T>(capacity.Value);
            }
            else
            {
                Items = new UnorderedList <T>();
            }

            if (_Count > 0)
            {
                Items.Add(ref Item1);
            }
            if (_Count > 1)
            {
                Items.Add(ref Item2);
            }
            if (_Count > 2)
            {
                Items.Add(ref Item3);
            }
            if (_Count > 3)
            {
                Items.Add(ref Item4);
            }
            Item1  = Item2 = Item3 = Item4 = default(T);
            _Count = 0;
        }
Example #36
0
		public override void Visit(Open open)
		{
			// include links to all the query dsl usage and aggregation usage pages on the landing query dsl and aggregations pages, respectively.
			string usageFilePath;
			if (IncludeDirectories.TryGetValue(_destination.Name, out usageFilePath))
			{
				var usageDoc = Document.Load(Path.Combine(Program.OutputDirPath, usageFilePath));

				var includeAttribute = usageDoc.Attributes.FirstOrDefault(a => a.Name == "includes-from-dirs");

				if (includeAttribute != null)
				{
					var directories = includeAttribute.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

					var list = new UnorderedList();

					foreach (var directory in directories)
					{
						foreach (var file in Directory.EnumerateFiles(Path.Combine(Program.OutputDirPath, directory), "*usage.asciidoc", SearchOption.AllDirectories))
						{
							var fileInfo = new FileInfo(file);
							var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name);

							list.Items.Add(new UnorderedListItem
							{
								new Paragraph(new InternalAnchor(fileNameWithoutExtension, fileNameWithoutExtension.LowercaseHyphenToPascal()))
							});
						}
					}

					open.Add(list);
				}
			}

			base.Visit(open);
		}
Example #37
0
        private void AddChild (CancellationScope child) {
            if (this == Null)
                return;

            if (Children == null)
                Children = new UnorderedList<CancellationScope>();

            Children.Add(child);
        }
Example #38
0
 public ClockSystem()
 {
     _clocks = new UnorderedList<WeakReference>();
 }
 public void Visit(UnorderedList unorderedList)
 {
     var uiElements = BuildChildUIList(unorderedList);
     DirectlyPlaceUIContent(new MarkdownList(false, uiElements));
 }
Example #40
0
            /// <summary>
            /// Creates a new system. Entities are added to the system based on if they pass the
            /// given filter.
            /// </summary>
            public EntityCache(Filter filter) {
                _filter = filter;
                _metadataKey = EntityManagerMetadata.GetUnorderedListMetadataIndex();

                CachedEntities = new UnorderedList<IEntity>();
            }
 public void Visit(UnorderedList unorderedList)
 {
     var uiElements = BuildChildUIList(unorderedList);
     var inlineContainer = new InlineUIContainer();
     inlineContainer.Child = new MarkdownList(false, uiElements);
     MaybeSplitForParagraph();
     _currentParagraph.Inlines.Add(inlineContainer);
 }