System.Collections.Generic.IList.RemoveAt(int)

Here are the examples of the csharp api System.Collections.Generic.IList.RemoveAt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

657 Examples 7

19 View Source File : ListSnapshot.cs
License : MIT License
Project Creator : 0x0ade

public void RemoveAt(int index) {
            ((IList<T>) List).RemoveAt(index);
        }

19 View Source File : BindableObjectCollection.cs
License : MIT License
Project Creator : 1iveowl

public void RemoveAt(int index)
        {
            var oldItem = this[index];
            _items.RemoveAt(index);
            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, oldItem, index));
        }

19 View Source File : CollectionExtension.cs
License : MIT License
Project Creator : 3F

public static bool Remove<T>(this IList<T> src, T elem, Func<T, T, bool> comparer)
        {
            for(int i = 0; i < src.Count; ++i)
            {
                if(comparer(src[i], elem)) {
                    src.RemoveAt(i);
                    return true;
                }
            }
            return false;
        }

19 View Source File : JsonData.cs
License : MIT License
Project Creator : 404Lcc

void IDictionary.Remove (object key)
        {
            EnsureDictionary ().Remove (key);

            for (int i = 0; i < object_list.Count; i++) {
                if (object_list[i].Key == (string) key) {
                    object_list.RemoveAt (i);
                    break;
                }
            }

            json = null;
        }

19 View Source File : JsonData.cs
License : MIT License
Project Creator : 404Lcc

void IOrderedDictionary.RemoveAt (int idx)
        {
            EnsureDictionary ();

            inst_object.Remove (object_list[idx].Key);
            object_list.RemoveAt (idx);
        }

19 View Source File : OVRShaderBuildProcessor.cs
License : MIT License
Project Creator : absurd-joy

public void OnProcessShader(
		Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> shaderCompilerData)
	{
		var projectConfig = OVRProjectConfig.GetProjectConfig();
		if (projectConfig == null)
		{
			return;
		}

		if (!projectConfig.skipUnneededShaders)
		{
			return;
		}

		if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
		{
			return;
		}

		var strippedGraphicsTiers = new HashSet<GraphicsTier>();

		// Unity only uses shader Tier2 on Quest and Go (regardless of graphics API)
		if (projectConfig.targetDeviceTypes.Contains(OVRProjectConfig.DeviceType.Quest))
		{
			strippedGraphicsTiers.Add(GraphicsTier.Tier1);
			strippedGraphicsTiers.Add(GraphicsTier.Tier3);
		}

		if (strippedGraphicsTiers.Count == 0)
		{
			return;
		}

		for (int i = shaderCompilerData.Count - 1; i >= 0; --i)
		{
			if (strippedGraphicsTiers.Contains(shaderCompilerData[i].graphicsTier))
			{
				shaderCompilerData.RemoveAt(i);
			}
		}
	}

19 View Source File : DispatcherObservableCollection.cs
License : MIT License
Project Creator : ABTSoftware

public void RemoveAt(int index)
        {
            lock (_syncRoot)
            {
                if (_collection.Count == 0 || _collection.Count <= index)
                {
                    return;
                }
                _collection.RemoveAt(index);
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            }
        }

19 View Source File : ACBrConsultaCNPJ.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
		{
			var ret = string.Empty;
			for (var i = 0; i < retorno.Count; i++)
			{
				var linha = retorno[i].Trim();
				if (linha != campo) continue;

				ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
				retorno.RemoveAt(i);
				break;
			}

			return ret;
		}

19 View Source File : ConsultaSintegraBA.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
        {
            var ret = string.Empty;
            for (var i = 0; i < retorno.Count; i++)
            {
                var linha = retorno[i].Trim();
                if (linha != campo) continue;

                ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
                retorno.RemoveAt(i);
                break;
            }

            return ret.RemoveDoubleSpaces();
        }

19 View Source File : ConsultaSintegraDF.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
        {
            var ret = string.Empty;
            var log = string.Empty;
            for (var i = 0; i < retorno.Count; i++)
            {
                var linha = retorno[i].Trim();
                if (linha != campo) continue;

                if (campo == "ATIVIDADE PRINCIPAL")
                {
                    ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
                    log = retorno[i + 2].Trim().Replace(" ", string.Empty);
                    ret = ret + " " + log;
                    break;
                }
                ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
                retorno.RemoveAt(i);
                break;
            }

            return ret;
        }

19 View Source File : ConsultaSintegraES.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
        {
            var ret = string.Empty;
            for (var i = 0; i < retorno.Count; i++)
            {
                var linha = retorno[i].Trim();
                if (linha != campo) continue;

                ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
                retorno.RemoveAt(i);
                break;
            }

            return ret;
        }

19 View Source File : ConsultaSintegraGO.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
        {
            var ret = string.Empty;
            var log = string.Empty;
            for (var i = 0; i < retorno.Count; i++)
            {
                var linha = retorno[i].Trim();
                if (linha != campo) continue;

                ret = retorno[i + 1].Trim().Replace(" ", string.Empty);
                retorno.RemoveAt(i);
                break;
            }

            return ret;
        }

19 View Source File : ACBrPessoa.cs
License : MIT License
Project Creator : ACBrNet

private static string LerCampo(IList<string> retorno, string campo)
		{
			var ret = string.Empty;
			for (var i = 0; i < retorno.Count; i++)
			{
				var linha = retorno[i].Trim();
				if (!linha.Contains(campo)) continue;

				ret = linha.Replace(campo, string.Empty).Trim();
				retorno.RemoveAt(i);
				break;
			}

			return ret;
		}

public static bool RemovePage(this IList<PropertiesBookPageData> value, int index, ReaderWriterLockSlim rwLock)
        {
            if (value == null)
                return false;

            rwLock.EnterWriteLock();
            try
            {
                if (value.Count <= index)
                    return false;

                value.RemoveAt(index);

                return true;
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }

19 View Source File : Container.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

private void SortWorldObjectsIntoInventory(IList<WorldObject> worldObjects)
        {
            // This will pull out all of our main pack items and side slot items (foci & containers)
            for (int i = worldObjects.Count - 1; i >= 0; i--)
            {
                if ((worldObjects[i].ContainerId ?? 0) == Biota.Id)
                {
                    Inventory[worldObjects[i].Guid] = worldObjects[i];
                    worldObjects[i].Container = this;

                    if (worldObjects[i].WeenieType != WeenieType.Container) // We skip over containers because we'll add their burden/value in the next loop.
                    {
                        EnreplacedbranceVal += (worldObjects[i].EnreplacedbranceVal ?? 0);
                        Value += (worldObjects[i].Value ?? 0);
                    }

                    worldObjects.RemoveAt(i);
                }
            }

            // Make sure placement positions are correct. They could get out of sync from a client issue, server issue, or orphaned biota
            var mainPackItems = Inventory.Values.Where(wo => !wo.UseBackpackSlot).OrderBy(wo => wo.PlacementPosition).ToList();
            for (int i = 0; i < mainPackItems.Count; i++)
                mainPackItems[i].PlacementPosition = i;
            var sidPackItems = Inventory.Values.Where(wo => wo.UseBackpackSlot).OrderBy(wo => wo.PlacementPosition).ToList();
            for (int i = 0; i < sidPackItems.Count; i++)
                sidPackItems[i].PlacementPosition = i;

            InventoryLoaded = true;

            // All that should be left are side pack sub contents.

            var sideContainers = Inventory.Values.Where(i => i.WeenieType == WeenieType.Container).ToList();
            foreach (var container in sideContainers)
            {
                ((Container)container).SortWorldObjectsIntoInventory(worldObjects); // This will set the InventoryLoaded flag for this sideContainer
                EnreplacedbranceVal += container.EnreplacedbranceVal; // This value includes the containers burden itself + all child items
                Value += container.Value; // This value includes the containers value itself + all child items
            }

            OnInitialInventoryLoadCompleted();
        }

19 View Source File : IVisitorContext.cs
License : MIT License
Project Creator : adrianoc

static void ConditionalUnregister(IList<DefinitionVariable> variables, int index)
        {
            var v = variables[index];
            if (v.Kind == MemberKind.LocalVariable || v.Kind == MemberKind.Parameter || v.Kind == MemberKind.TypeParameter) 
                variables.RemoveAt(index);
        }

19 View Source File : IVisitorContext.cs
License : MIT License
Project Creator : adrianoc

static void UnconditionalUnregister(IList<DefinitionVariable> variables, int index) => variables.RemoveAt(index);

19 View Source File : RedisLite.cs
License : MIT License
Project Creator : AElfProject

public void ResetSendBuffer()
        {
            _currentBufferIndex = 0;
            for (int i = _cmdBuffer.Count - 1; i >= 0; i--)
            {
                var buffer = _cmdBuffer[i].Array;
                BufferPool.ReleaseBufferToPool(ref buffer);
                _cmdBuffer.RemoveAt(i);
            }
        }

19 View Source File : Platform.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static void ExpandPaths(IList<string> stream,
			string extension, IEnumerable<string> paths) 
		{
			int pathsC = paths == null ? 0 : paths.Count();

			foreach (string libraryPath in stream.ToArray())
			{
				if (-1 == libraryPath.IndexOf(extension)) continue;

				int libraryPathI = stream.IndexOf(libraryPath);
				stream.RemoveAt(libraryPathI);

				if (pathsC == 0)
				{
					// just continue, don't Insert them again
					continue;
				}

				if (pathsC == 1)
				{
					stream.Insert(libraryPathI, libraryPath.Replace(extension, paths.ElementAt(0)));
					continue;
				}

				foreach (string realLibraryPath in paths)
				{
					stream.Insert(libraryPathI, libraryPath.Replace(extension, realLibraryPath));
					++libraryPathI;
				}

			}
		}

19 View Source File : JsonSchemaBuilder.cs
License : MIT License
Project Creator : akaskela

private JsonSchema Pop()
        {
            JsonSchema poppedSchema = _currentSchema;
            _stack.RemoveAt(_stack.Count - 1);
            _currentSchema = _stack.LastOrDefault();

            return poppedSchema;
        }

19 View Source File : JContainer.cs
License : MIT License
Project Creator : akaskela

internal virtual void RemoveItemAt(int index)
        {
            IList<JToken> children = ChildrenTokens;

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "Index is less than 0.");
            }
            if (index >= children.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "Index is equal to or greater than Count.");
            }

            CheckReentrancy();

            JToken item = children[index];
            JToken previous = (index == 0) ? null : children[index - 1];
            JToken next = (index == children.Count - 1) ? null : children[index + 1];

            if (previous != null)
            {
                previous.Next = next;
            }
            if (next != null)
            {
                next.Previous = previous;
            }

            item.Parent = null;
            item.Previous = null;
            item.Next = null;

            children.RemoveAt(index);

#if !(DOTNET || PORTABLE40 || PORTABLE)
            if (_listChanged != null)
            {
                OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
            }
#endif
#if !(NET20 || NET35 || PORTABLE40)
            if (_collectionChanged != null)
            {
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
            }
#endif
        }

19 View Source File : JsonSchemaGenerator.cs
License : MIT License
Project Creator : akaskela

private TypeSchema Pop()
        {
            TypeSchema popped = _stack[_stack.Count - 1];
            _stack.RemoveAt(_stack.Count - 1);
            TypeSchema newValue = _stack.LastOrDefault();
            if (newValue != null)
            {
                _currentSchema = newValue.Schema;
            }
            else
            {
                _currentSchema = null;
            }

            return popped;
        }

19 View Source File : ObservableViewModelCollection.cs
License : MIT License
Project Creator : Aminator

protected virtual void OnViewModelCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            INotifyCollectionChanged? notifyCollection = modelCollection as INotifyCollectionChanged;

            if (notifyCollection != null)
            {
                notifyCollection.CollectionChanged -= OnModelCollectionChanged;
            }

            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    for (int i = 0; i < e.NewItems.Count; i++)
                    {
                        modelCollection.Insert(e.NewStartingIndex + i, CreateModel((TViewModel)e.NewItems[i]));
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                    if (e.OldItems.Count == 1 && modelCollection is ObservableCollection<TModel> observableCollection)
                    {
                        observableCollection.Move(e.OldStartingIndex, e.NewStartingIndex);
                    }
                    else
                    {
                        List<TModel> items = modelCollection.Skip(e.OldStartingIndex).Take(e.OldItems.Count).ToList();

                        for (int i = 0; i < e.OldItems.Count; i++)
                        {
                            modelCollection.RemoveAt(e.OldStartingIndex);
                        }

                        for (int i = 0; i < items.Count; i++)
                        {
                            modelCollection.Insert(e.NewStartingIndex + i, items[i]);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    for (int i = 0; i < e.OldItems.Count; i++)
                    {
                        modelCollection.RemoveAt(e.OldStartingIndex);
                    }
                    break;
                case NotifyCollectionChangedAction.Replace:
                    for (int i = 0; i < e.OldItems.Count; i++)
                    {
                        modelCollection.RemoveAt(e.OldStartingIndex);
                    }

                    goto case NotifyCollectionChangedAction.Add;
                case NotifyCollectionChangedAction.Reset:
                    modelCollection.Clear();
                    break;
            }

            if (notifyCollection != null)
            {
                notifyCollection.CollectionChanged += OnModelCollectionChanged;
            }
        }

19 View Source File : SplitDataSourceBase.cs
License : MIT License
Project Creator : amwx

public void Replace(int indexInOriginalVector, T value)
        {
            Debug.replacedert(indexInOriginalVector >= 0);

            var index = IndexFromIndexInOriginalVector(indexInOriginalVector);
            var vect = vector;
            vect.RemoveAt(index);
            vect.Insert(index, value);
        }

19 View Source File : SplitDataSourceBase.cs
License : MIT License
Project Creator : amwx

public void RemoveAt(int indexInOriginalVector)
        {
            Debug.replacedert(indexInOriginalVector >= 0);
            var index = IndexFromIndexInOriginalVector(indexInOriginalVector);
            Debug.replacedert(index < indicesInOriginalVector.Count);
            vector.RemoveAt(index);
            indicesInOriginalVector.RemoveAt(index);
        }

19 View Source File : IndexRange.cs
License : MIT License
Project Creator : amwx

public static int Intersect(
            IList<IndexRange> ranges,
            IndexRange range,
            IList<IndexRange> removed = null)
        {
            var result = 0;

            for (var i = 0; i < ranges.Count && range != s_invalid; ++i)
            {
                var existing = ranges[i];

                if (existing.End < range.Begin || existing.Begin > range.End)
                {
                    removed?.Add(existing);
                    ranges.RemoveAt(i--);
                    result += existing.Count;
                }
                else
                {
                    if (existing.Begin < range.Begin)
                    {
                        var except = new IndexRange(existing.Begin, range.Begin - 1);
                        removed?.Add(except);
                        ranges[i] = existing = new IndexRange(range.Begin, existing.End);
                        result += except.Count;
                    }

                    if (existing.End > range.End)
                    {
                        var except = new IndexRange(range.End + 1, existing.End);
                        removed?.Add(except);
                        ranges[i] = new IndexRange(existing.Begin, range.End);
                        result += except.Count;
                    }
                }
            }

            MergeRanges(ranges);

            if (removed is object)
            {
                MergeRanges(removed);
            }

            return result;
        }

19 View Source File : IndexRange.cs
License : MIT License
Project Creator : amwx

public static int Remove(
            IList<IndexRange> ranges,
            IndexRange range,
            IList<IndexRange> removed = null)
        {
            var result = 0;

            for (var i = 0; i < ranges.Count; ++i)
            {
                var existing = ranges[i];

                if (range.Intersects(existing))
                {
                    if (range.Begin <= existing.Begin && range.End >= existing.End)
                    {
                        ranges.RemoveAt(i--);
                        removed?.Add(existing);
                        result += existing.Count;
                    }
                    else if (range.Begin > existing.Begin && range.End >= existing.End)
                    {
                        ranges[i] = new IndexRange(existing.Begin, range.Begin - 1);
                        removed?.Add(new IndexRange(range.Begin, existing.End));
                        result += existing.End - (range.Begin - 1);
                    }
                    else if (range.Begin > existing.Begin && range.End < existing.End)
                    {
                        ranges[i] = new IndexRange(existing.Begin, range.Begin - 1);
                        ranges.Insert(++i, new IndexRange(range.End + 1, existing.End));
                        removed?.Add(range);
                        result += range.Count;
                    }
                    else if (range.End <= existing.End)
                    {
                        var remove = new IndexRange(existing.Begin, range.End);
                        ranges[i] = new IndexRange(range.End + 1, existing.End);
                        removed?.Add(remove);
                        result += remove.Count;
                    }
                }
            }

            return result;
        }

19 View Source File : IndexRange.cs
License : MIT License
Project Creator : amwx

private static void MergeRanges(IList<IndexRange> ranges)
        {
            for (var i = ranges.Count - 2; i >= 0; --i)
            {
                var r = ranges[i];
                var r1 = ranges[i + 1];

                if (r.Intersects(r1) || r.End == r1.Begin - 1)
                {
                    ranges[i] = new IndexRange(r.Begin, r1.End);
                    ranges.RemoveAt(i + 1);
                }
            }
        }

19 View Source File : HotReloader.cs
License : MIT License
Project Creator : AndreiMisiukevich

private void ReloadElement(object obj, ReloadItem reloadItem, Type csharpType = null)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(reloadItem.Code) && csharpType != null)
                {
                    var prop = obj.GetType().GetProperty("HotReloadCtorParams", BindingFlags.Instance | BindingFlags.NonPublic)
                        ?? obj.GetType().GetProperty("HotReloadCtorParams", BindingFlags.Instance | BindingFlags.Public);
                    var parameters = (prop?.GetValue(obj) as object[]) ?? new object[0];
                    switch (obj)
                    {
                        case Page page:
                            var newPage = Activator.CreateInstance(csharpType, parameters) as Page;
                            if (newPage == null)
                            {
                                return;
                            }
                            _ignoredElementInit = newPage;
                            if (App.MainPage == page)
                            {
                                App.MainPage = newPage;
                                break;
                            }
                            newPage.BindingContext = page.BindingContext;


                            if (page.Parent is MultiPage<Page> mPage)
                            {
                                mPage.Children.Insert(mPage.Children.IndexOf(page), newPage);
                                mPage.Children.Remove(page);
                                break;
                            }
                            if (page.Parent is MasterDetailPage mdPage)
                            {
                                if (mdPage.Master == page)
                                {
                                    mdPage.Master = newPage;
                                }
                                else if (mdPage.Detail == page)
                                {
                                    mdPage.Detail = newPage;
                                }
                                break;
                            }
                            page.Navigation.InsertPageBefore(newPage, page);
                            if (page.Navigation.NavigationStack.LastOrDefault() == page)
                            {
                                page.Navigation.PopAsync(false);
                            }
                            else
                            {
                                page.Navigation.RemovePage(page);
                            }
                            break;
                        case View view:
                            var newView = Activator.CreateInstance(csharpType, parameters) as View;
                            if (newView == null)
                            {
                                return;
                            }
                            _ignoredElementInit = newView;
                            switch (view.Parent)
                            {
                                case ContentView contentView:
                                    contentView.Content = newView;
                                    break;
                                case ScrollView scrollView:
                                    scrollView.Content = newView;
                                    break;
                                case Layout<View> layout:
                                    layout.Children.Insert(layout.Children.IndexOf(view), newView);
                                    layout.Children.Remove(view);
                                    break;
                                case ContentPage page:
                                    page.Content = newView;
                                    break;
                            }
                            break;
                    }
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine("### HOTRELOAD ERROR: CANNOT RELOAD C# CODE ###");
            }

            if (!reloadItem.HasXaml)
            {
                OnLoaded(obj, csharpType != null);
                return;
            }

            var xamlDoc = reloadItem.Xaml;

            if (obj is VisualElement ve)
            {
                ve.Resources = null;
            }

            //[0] Parse new xaml with resources
            var rebuildEx = RebuildElement(obj, xamlDoc);
            if (!(obj is VisualElement) && !(obj is Application))
            {
                if (rebuildEx != null)
                {
                    throw rebuildEx;
                }
                OnLoaded(obj, true);
                return;
            }

            //[1] Check if any dictionary was updated before
            foreach (var dict in GetResourceDictionaries((obj as VisualElement)?.Resources ?? (obj as Application)?.Resources).ToArray())
            {
                var name = dict.GetType().FullName;

                //[1.0] update own res
                if (_resourceMapping.TryGetValue(name, out ReloadItem item))
                {
                    dict.Clear();
                    LoadFromXaml(dict, item.Xaml);
                }

                //[1.1] Update Source resources
                var sourceItem = GereplacedemForReloadingSourceRes(dict.Source, obj);
                if (sourceItem != null)
                {
                    //(?): Seems no need in this stuff
                    //dict.GetType().GetField("_source", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(dict, null);
                    //var resType = obj.GetType().replacedembly.GetType(RetrieveClreplacedName(sourceItem.Xaml.InnerXml));
                    //var rd = Activator.CreateInstance(resType) as ResourceDictionary;
                    //rd.Clear();
                    //rd.LoadFromXaml(sourceItem.Xaml.InnerXml);
                    //dict.Add(rd);
                    var rd = new ResourceDictionary();
                    LoadFromXaml(rd, sourceItem.Xaml);
                    foreach (var key in rd.Keys)
                    {
                        dict.Remove(key);
                    }
                    LoadFromXaml(dict, sourceItem.Xaml);
                }
                else if (dict.Source != null)
                {
                    var dId = GetResId(dict.Source, obj);
                    if (dId != null)
                    {
                        sourceItem = _resourceMapping.FirstOrDefault(it => it.Key.EndsWith(dId, StringComparison.Ordinal)).Value;
                        if (sourceItem != null)
                        {
                            var rd = new ResourceDictionary();
                            LoadFromXaml(rd, sourceItem.Xaml);
                            foreach (var key in rd.Keys)
                            {
                                dict.Remove(key);
                            }
                            LoadFromXaml(dict, sourceItem.Xaml);
                        }
                    }
                }

                var styleSheets = dict.GetType().GetProperty("StyleSheets", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(dict) as IList<StyleSheets.StyleSheet>;
                if (styleSheets != null)
                {
                    var sheets = xamlDoc.GetElementsByTagName("StyleSheet");
                    for (var i = 0; i < styleSheets.Count; ++i)
                    {
                        var src = sheets[i].Attributes["Source"];
                        if (src == null)
                        {
                            continue;
                        }
                        var rId = GetResId(new Uri(src.Value, UriKind.Relative), obj);
                        if (rId == null)
                        {
                            continue;
                        }
                        var rItem = _resourceMapping.FirstOrDefault(it => it.Key.EndsWith(rId, StringComparison.Ordinal)).Value;
                        if (rItem == null)
                        {
                            continue;
                        }
                        styleSheets.RemoveAt(i);
                        var newSheet = StyleSheets.StyleSheet.FromString(rItem.Css);
                        styleSheets.Insert(i, newSheet);
                        break;
                    }
                }
            }

            var modifiedXml = new XmlDoreplacedent();
            modifiedXml.LoadXml(xamlDoc.InnerXml);

            var isResourceFound = false;

            if (!(obj is Application))
            {
                foreach (XmlNode node in modifiedXml.LastChild)
                {
                    if (node.Name.EndsWith(".Resources", StringComparison.CurrentCulture))
                    {
                        node.ParentNode.RemoveChild(node);
                        isResourceFound = true;
                        break;
                    }
                }
            }

            //[2] Update object without resources (Force to re-apply all styles)
            if (isResourceFound)
            {
                rebuildEx = RebuildElement(obj, modifiedXml);
            }

            if (rebuildEx != null)
            {
                throw rebuildEx;
            }

            SetupNamedChildren(obj);
            OnLoaded(obj, true);
        }

19 View Source File : Simulator.cs
License : Apache License 2.0
Project Creator : AnotherEnd15

void updateDeleteAgent()
        {
            bool isDelete = false;
            for (int i = agents.Count - 1; i >= 0; i--)
            {
                if (agents[i].needDelete)
                {
                    agents.RemoveAt(i);
                    isDelete = true;
                }
            }
            if (isDelete)
                onDelAgent();
        }

19 View Source File : IThreadSafeList.cs
License : GNU General Public License v3.0
Project Creator : anydream

public static void RemoveAt_NoLock<T>(this IList<T> list, int index) {
#if THREAD_SAFE
			var tsList = list as ThreadSafe.IList<T>;
			if (tsList != null)
				tsList.RemoveAt_NoLock(index);
			else
#endif
				list.RemoveAt(index);
		}

19 View Source File : AdvancedMessageBus.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools

public void Unsubscribe<T>(IHandleMessage<T> subscriber)
        {
            IList<WeakReference> subscribers;

            lock (_subscriptions)
            {
                if (!_subscriptions.TryGetValue(typeof(T), out subscribers))
                {
                    return;
                }

                lock (subscribers)
                {
                    for (int i = 0; i < subscribers.Count; i++)
                    {
                        if (object.ReferenceEquals(subscribers[i].Target, subscriber))
                        {
                            subscribers.RemoveAt(i);
                            break;
                        }
                    }

                    if (subscribers.Count == 0)
                    {
                        _subscriptions.Remove(typeof(T));
                    }
                }
            }
        }

19 View Source File : AdvancedMessageBus.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools

public void Post<T>(T message)
        {
            IList<WeakReference> subscribers;

            lock (_subscriptions)
            {
                if (!_subscriptions.TryGetValue(typeof(T), out subscribers))
                {
                    return;
                }
            }

            lock (subscribers)
            {
                for (int i = subscribers.Count - 1; i >= 0; i--)
                {
                    var subscriber = subscribers[i].Target as IHandleMessage<T>;

                    if (subscriber != null)
                    {
                        subscriber.Handle(message);
                    }
                    else
                    {
                        subscribers.RemoveAt(i);
                    }
                }
            }

            //Clean up subscriber list. Its done this rather replacedbersome way since we want to separate the locks above in order not to lock the entire bus while posting a specific message, since message posting may take time.
            if (subscribers.Count == 0)
            {
                lock (_subscriptions)
                {
                    if (!_subscriptions.TryGetValue(typeof(T), out subscribers))
                    {
                        return;
                    }

                    lock (subscribers)
                    {
                        if (subscribers.Count == 0)
                        {
                            _subscriptions.Remove(typeof(T));
                        }
                    }
                }
            }
        }

19 View Source File : AdvancedMessageBus.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools

private IEnumerator BalancedPoster<T>(IList<WeakReference> subscribers, T message)
        {
            lock (subscribers)
            {
                for (int i = subscribers.Count - 1; i >= 0; i--)
                {
                    var subscriber = subscribers[i].Target as IHandleMessage<T>;

                    if (subscriber != null)
                    {
                        subscriber.Handle(message);
                    }
                    else
                    {
                        subscribers.RemoveAt(i);
                    }

                    yield return null;
                }
            }

            //Clean up subscriber list. Its done this rather replacedbersome way since we want to separate the locks above in order not to lock the entire bus while posting a specific message, since message posting may take time.
            if (subscribers.Count == 0)
            {
                lock (_subscriptions)
                {
                    if (!_subscriptions.TryGetValue(typeof(T), out subscribers))
                    {
                        yield break;
                    }

                    lock (subscribers)
                    {
                        if (subscribers.Count == 0)
                        {
                            _subscriptions.Remove(typeof(T));
                        }
                    }
                }
            }
        }

19 View Source File : ExcelDataValidationFormulaList.cs
License : Apache License 2.0
Project Creator : Appdynamics

void IList<string>.RemoveAt(int index)
            {
                _items.RemoveAt(index);
                OnListChanged();
            }

19 View Source File : TokenFactory.cs
License : Apache License 2.0
Project Creator : Appdynamics

public Token Create(IEnumerable<Token> tokens, string token, string worksheet)
        {
            Token tokenSeparator = null;
            if (_tokenSeparatorProvider.Tokens.TryGetValue(token, out tokenSeparator))
            {
                return tokenSeparator;
            }
            var tokenList = (IList<Token>)tokens;
            //Address with worksheet-string before  /JK
            if (token.StartsWith("!") && tokenList[tokenList.Count-1].TokenType == TokenType.String)
            {
                string addr = "";
                var i = tokenList.Count - 2;
                if (i > 0)
                {
                    if (tokenList[i].TokenType == TokenType.StringContent)
                    {
                        addr = "'" + tokenList[i].Value.Replace("'", "''") + "'";
                    }
                    else
                    {
                        throw(new ArgumentException(string.Format("Invalid formula token sequence near {0}",token)));
                    }
                    //Remove the string tokens and content
                    tokenList.RemoveAt(tokenList.Count - 1);
                    tokenList.RemoveAt(tokenList.Count - 1);
                    tokenList.RemoveAt(tokenList.Count - 1);

                    return new Token(addr + token, TokenType.ExcelAddress);
                }
                else
                {
                    throw(new ArgumentException(string.Format("Invalid formula token sequence near {0}",token)));
                }
                
            }

            if (tokens.Any() && tokens.Last().TokenType == TokenType.String)
            {
                return new Token(token, TokenType.StringContent);
            }
            if (!string.IsNullOrEmpty(token))
            {
                token = token.Trim();
            }
            if (Regex.IsMatch(token, RegexConstants.Decimal))
            {
                return new Token(token, TokenType.Decimal);
            }
            if(Regex.IsMatch(token, RegexConstants.Integer))
            {
                return new Token(token, TokenType.Integer);
            }
            if (Regex.IsMatch(token, RegexConstants.Boolean, RegexOptions.IgnoreCase))
            {
                return new Token(token, TokenType.Boolean);
            }
            if (token.ToUpper(CultureInfo.InvariantCulture).Contains("#REF!"))
            {
                return new Token(token, TokenType.InvalidReference);
            }
            if (token.ToUpper(CultureInfo.InvariantCulture) == "#NUM!")
            {
                return new Token(token, TokenType.NumericError);
            }
            if (token.ToUpper(CultureInfo.InvariantCulture) == "#VALUE!")
            {
                return new Token(token, TokenType.ValueDataTypeError);
            }
            if (token.ToUpper(CultureInfo.InvariantCulture) == "#NULL!")
            {
                return new Token(token, TokenType.Null);
            }
            if (_nameValueProvider != null && _nameValueProvider.IsNamedValue(token, worksheet))
            {
                return new Token(token, TokenType.NameValue);
            }
            if (_functionNameProvider.IsFunctionName(token))
            {
                return new Token(token, TokenType.Function);
            }
            if (tokenList.Count > 0 && tokenList[tokenList.Count - 1].TokenType == TokenType.OpeningEnumerable)
            {
                return new Token(token, TokenType.Enumerable);
            }
            var at = OfficeOpenXml.ExcelAddressBase.IsValid(token, _r1c1);
            if (at==ExcelAddressBase.AddressType.InternalAddress)
            {
                return new Token(token.ToUpper(CultureInfo.InvariantCulture), TokenType.ExcelAddress);
            } 
            else if (at == ExcelAddressBase.AddressType.R1C1)
            {
                return new Token(token.ToUpper(CultureInfo.InvariantCulture), TokenType.ExcelAddressR1C1);
            }
            return new Token(token, TokenType.Unrecognized);

        }

19 View Source File : MahjongLogic.cs
License : MIT License
Project Creator : ArcturusZhang

private static void CombinationBackTrack<T>(IList<T> list, int count, int start, IList<T> current, IList<List<T>> result)
        {
            // exits
            if (current.Count == count)
            {
                result.Add(new List<T>(current));
                return;
            }
            for (int i = start; i < list.Count; i++)
            {
                current.Add(list[i]);
                CombinationBackTrack(list, count, i + 1, current, result);
                // back track
                current.RemoveAt(current.Count - 1);
            }
        }

19 View Source File : AudioPlaylist.cs
License : Apache License 2.0
Project Creator : artemshuba

public void ClearAllExceptCurrent()
        {
            int i = 0;
            while (i < Items.Count)
            {
                if (Items[i] != Currenreplacedem)
                    Items.RemoveAt(i);
                else
                    i++;
            }

            _currentIndex = 0;
        }

19 View Source File : Utils.cs
License : GNU Lesser General Public License v3.0
Project Creator : autocore-ai

public static void RemoveLast<T>(this IList<T> list)
        {
            if (list.Count > 0)
            {
                list.RemoveAt(list.Count - 1);
            }
        }

19 View Source File : ScriptCompiler.cs
License : GNU Lesser General Public License v2.1
Project Creator : axiom3d

private void _processVariables(ref IList<AbstractNode> nodes)
        {
            for (var i = 0; i < nodes.Count; ++i)
            {
                var cur = nodes[i];

                if (cur is ObjectAbstractNode)
                {
                    // Only process if this object is not abstract
                    var obj = (ObjectAbstractNode)cur;
                    if (!obj.IsAbstract)
                    {
                        _processVariables(ref obj.Children);
                        _processVariables(ref obj.Values);
                    }
                }
                else if (cur is PropertyAbstractNode)
                {
                    var prop = (PropertyAbstractNode)cur;
                    _processVariables(ref prop.Values);
                }
                else if (cur is VariableGetAbstractNode)
                {
                    var var = (VariableGetAbstractNode)cur;

                    // Look up the enclosing scope
                    ObjectAbstractNode scope = null;
                    var temp = var.Parent;
                    while (temp != null)
                    {
                        if (temp is ObjectAbstractNode)
                        {
                            scope = (ObjectAbstractNode)temp;
                            break;
                        }
                        temp = temp.Parent;
                    }

                    // Look up the variable in the environment
                    var varAccess = new KeyValuePair<bool, string>(false, string.Empty);
                    if (scope != null)
                    {
                        varAccess = scope.GetVariable(var.Name);
                    }

                    if (scope == null || !varAccess.Key)
                    {
                        var found = this._environment.ContainsKey(var.Name);
                        if (found)
                        {
                            varAccess = new KeyValuePair<bool, string>(true, this._environment[var.Name]);
                        }
                        else
                        {
                            varAccess = new KeyValuePair<bool, string>(false, varAccess.Value);
                        }
                    }

                    if (varAccess.Key)
                    {
                        // Found the variable, so process it and insert it into the tree
                        var lexer = new ScriptLexer();
                        var tokens = lexer.Tokenize(varAccess.Value, var.File);
                        var parser = new ScriptParser();
                        var cst = parser.ParseChunk(tokens);
                        var ast = _convertToAST(cst);

                        // Set up ownership for these nodes
                        foreach (var currentNode in ast)
                        {
                            currentNode.Parent = var.Parent;
                        }

                        // Recursively handle variable accesses within the variable expansion
                        _processVariables(ref ast);

                        // Insert the nodes in place of the variable
                        for (var j = 0; j < ast.Count; j++)
                        {
                            nodes.Insert(j, ast[j]);
                        }
                    }
                    else
                    {
                        // Error
                        AddError(CompileErrorCode.UndefinedVariable, var.File, var.Line);
                    }

                    // Remove the variable node
                    nodes.RemoveAt(i);
                    i--;
                }
            }
        }

19 View Source File : CollectionExtensions.cs
License : MIT License
Project Creator : ay2015

public static TSource RemoveLast<TSource>(this IList<TSource> source)
    {
        Contract.Requires(source != null);
        Contract.Requires(source.Count > 0);
        TSource item = source[source.Count - 1];
        source.RemoveAt(source.Count - 1);
        return item;
    }

19 View Source File : SchemaAndRowsetJSONSerializationTests.cs
License : MIT License
Project Creator : azist

[Run("rowsAsMap=true")]
    [Run("rowsAsMap=false")]
    public void Rowset_FromJSON_FieldMissed(bool rowsAsMap)
    {
      var row = new Person { Name = "Henry", Age = 43 };
      var rowSet = new Rowset(row.Schema);
      rowSet.Add(row);
      var options = new Azos.Serialization.JSON.JsonWritingOptions
      {
        RowsetMetadata = true,
        RowsAsMap = rowsAsMap
      };
      var json = rowSet.ToJson(options);
      var map = JsonReader.DeserializeDataObject(json) as JsonDataMap;
      var rows = (map["Rows"] as IList<object>);
      if (rowsAsMap)
      {
        var pers = rows[0] as IDictionary<string, object>;
        pers.Remove("Age");
      }
      else
      {
        var pers = rows[0] as IList<object>;
        pers.RemoveAt(1);
      }

      var trg = RowsetBase.FromJSON(map, out bool allMatched);

      Aver.IsFalse(allMatched);
      var trgRow = trg[0];
      Aver.AreEqual(trgRow.Schema.FieldCount, 2);
      Aver.AreObjectsEqual(trgRow["Name"], "Henry");
      Aver.IsNull(trgRow["Age"]);
    }

19 View Source File : SchemaAndRowsetJSONSerializationTests.cs
License : MIT License
Project Creator : azist

[Run("rowsAsMap=true")]
    [Run("rowsAsMap=false")]
    public void Rowset_FromJSON_DefMissed(bool rowsAsMap)
    {
      var row = new Person { Name = "Henry", Age = 43 };
      var rowSet = new Rowset(row.Schema);
      rowSet.Add(row);
      var options = new Azos.Serialization.JSON.JsonWritingOptions
      {
        RowsetMetadata = true,
        RowsAsMap = rowsAsMap
      };
      var json = rowSet.ToJson(options);
      var map = JsonReader.DeserializeDataObject(json) as JsonDataMap;
      var schema = (map["Schema"] as IDictionary<string, object>);
      var defs = schema["FieldDefs"] as IList<object>;
      defs.RemoveAt(1);

      bool allMatched;
      var trg = RowsetBase.FromJSON(map, out allMatched);

      Aver.IsFalse(allMatched);
      var trgRow = trg[0];
      Aver.AreEqual(trgRow.Schema.FieldCount, 1);
      Aver.AreObjectsEqual(trgRow["Name"], "Henry");
    }

19 View Source File : IListExt.cs
License : MIT License
Project Creator : baba-s

public static T Dequeue<T>( this IList<T> self )
		{
			var result = self[ 0 ];
			self.RemoveAt( 0 );
			return result;
		}

19 View Source File : ListExtensions.cs
License : The Unlicense
Project Creator : BAndysc

public static void OverrideWith<T>(this IList<T> that, IList<T> with)
        {
            int i = 0;
            foreach (var r in with)
            {
                if (i < that.Count)
                    that[i] = r;
                else
                    that.Add(r);

                i++;
            }
            while (that.Count > i)
            {
                that.RemoveAt(that.Count - 1);
            }
        }

19 View Source File : ListExtensions.cs
License : The Unlicense
Project Creator : BAndysc

public static T? RemoveFirstIf<T>(this IList<T> list, Func<T, bool> pred)
        {
            for (int i = 0; i < list.Count; ++i)
            {
                if (pred(list[i]))
                {
                    var elem = list[i];
                    list.RemoveAt(i);
                    return elem;
                }
            }

            return default;
        }

19 View Source File : ListExtensions.cs
License : The Unlicense
Project Creator : BAndysc

public static T? RemoveIf<T>(this IList<T> list, Func<T, bool> pred)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (pred(list[i]))
                {
                    list.RemoveAt(i);
                }
            }

            return default;
        }

19 View Source File : NoHarmonyLoader.cs
License : MIT License
Project Creator : Bannerlord-Coop-Team

private TaskStatus NHLModel<AddType, RemoveType>(IGameStarter gameI, TaskMode mode)
            where RemoveType : GameModel
            where AddType : GameModel, new()
        {
            IList<GameModel> models = gameI.Models as IList<GameModel>;
            TaskStatus st = TaskStatus.Pending;
            int rm = 0;

            for (int index = 0; index < models.Count; ++index)
            {
                if (mode != TaskMode.Remove && models[index] is AddType)
                {
                    Log(LogLvl.Warning, typeof(AddType) + " already installed, skipping.");
                    if (mode == TaskMode.RemoveAndAdd)
                    {
                        st = TaskStatus.Warning;
                    }
                    else
                    {
                        return TaskStatus.Warning;
                    }
                }

                if (models[index] is RemoveType)
                {
                    if (mode == TaskMode.Replace || mode == TaskMode.ReplaceOrAdd)
                    {
                        models[index] = new AddType();
                        Log(
                            LogLvl.Info,
                            typeof(RemoveType) +
                            " found and replaced with " +
                            typeof(AddType) +
                            ".");
                        return TaskStatus.Completed;
                    }

                    if (mode == TaskMode.Remove || mode == TaskMode.RemoveAndAdd)
                    {
                        models.RemoveAt(index); // C# rearrange the for loop on it's own. 
                        rm++;
                        index--;
                    }
                }
            }

            if (mode != TaskMode.Replace && mode != TaskMode.Remove && st == TaskStatus.Pending)
            {
                gameI.AddModel(new AddType());
                Log(LogLvl.Info, typeof(AddType) + " added.");
            }

            if (mode == TaskMode.RemoveAndAdd)
            {
                if (rm == 0)
                {
                    Log(LogLvl.Warning, typeof(RemoveType) + " not found.");
                    st = TaskStatus.Warning;
                }

                if (st == TaskStatus.Pending)
                {
                    st = TaskStatus.Completed;
                }

                return st;
            }

            if (mode == TaskMode.Remove && rm == 0)
            {
                Log(LogLvl.Warning, typeof(RemoveType) + " not found.");
                return TaskStatus.Warning;
            }

            return TaskStatus.Completed;
        }

19 View Source File : DocumentMap.cs
License : MIT License
Project Creator : barry-jones

public void RemoveAt(int index)
        {
            _baseCollection.RemoveAt(index);
        }

19 View Source File : BrowseService.cs
License : MIT License
Project Creator : Baseflow

public void AddToRecentMedia(IMediaItem mediaItem)
        {
            var recentMedia = RecentMedia;

            var oldItem = recentMedia.FirstOrDefault(x => x.Id == mediaItem.Id);
            if (oldItem != null)
                recentMedia.Remove(oldItem);

            recentMedia.Insert(0, mediaItem);
            if (recentMedia.Count > 10)
                recentMedia.RemoveAt(RecentMedia.Count);
            RecentMedia = recentMedia;
        }

See More Examples