コード例 #1
0
 public bool Leave(Account user)
 {
     try
     {
         Members.Remove(user);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: CollectionExtension.cs プロジェクト: k0956398/GCL
        /// <summary>
        /// Removes if collection contains the given element.
        /// <locDE><para />Entfernt das Element falls es in der Liste enthalten ist.</locDE>
        /// </summary>
        /// <typeparam name="T">The element type of the list.<locDE><para />Elementtyp der Liste.</locDE></typeparam>
        /// <param name="collection">The collection.<locDE><para />Die Liste.</locDE></param>
        /// <param name="value">The value.<locDE><para />Der Wert.</locDE></param>
        /// <param name="comparer">The comparer method (or null).<locDE><para />Die Vergleichsmethode (oder null).</locDE></param>
        /// <returns>True if element was contained.<locDE><para />True falls das Element in der Liste war.</locDE></returns>
        public static bool RemoveIfContains <T>(this System.Collections.Generic.ICollection <T> collection, T value,
                                                System.Collections.Generic.IEqualityComparer <T> comparer = null)
        {
            if (null == collection)
            {
                return(false);
            }

            if (IgnoreNullValues && null == value)
            {
                // Don't remove null values
                // Null Wert nicht entfernen
                return(false);
            }

            if (null == comparer)
            {
                if (collection.Contains(value))
                {
                    // Contained, remove
                    // Enthalten, entfernen
                    collection.Remove(value);
                    return(true);
                }
            }
            else
            {
                if (collection.Contains(value, comparer))
                {
                    // Contained, remove
                    // Enthalten, entfernen
                    collection.Remove(value);
                    return(true);
                }
            }

            // Not contained
            // Nicht enthalten
            return(false);
        }
コード例 #3
0
        public MarkdownEditor()
        {
            this.InitializeComponent();
            System.Collections.Generic.ICollection <CommandBinding> commandBindings = this.Editor.TextArea.DefaultInputHandler.Editing.CommandBindings;
            CommandBinding item = commandBindings.Single((CommandBinding cb) => cb.Command == AvalonEditCommands.IndentSelection);

            commandBindings.Remove(item);
            this.OriginalDocument = string.Empty;
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }
            this.LoadEditorSettings();
            this.InitializeCommands();
            this.Editor.Loaded += new RoutedEventHandler(this.Editor_Loaded);
            this.Editor.TextArea.SelectionChanged += new System.EventHandler(this.TextArea_SelectionChanged);
        }
コード例 #4
0
ファイル: CollectionExtension.cs プロジェクト: k0956398/GCL
        /// <summary>
        /// Removes multiple items (i.e. determined by Linq expression) from the specified collection.
        /// <locDE><para />Entfernt mehrere Elemente (z.B. ermittelt durch Linq Ausdruck) von der angegebenen Collection.</locDE>
        /// </summary>
        /// <typeparam name="T">The type of the T.<locDE><para />Generischer Datentyp T.</locDE></typeparam>
        /// <param name="collection">The collection.<locDE><para />Die Collection.</locDE></param>
        /// <param name="condition">The condition.<locDE><para />Die Bedingung.</locDE></param>
        /// <example>
        /// Removes all elements with IsSelected property set to true.
        /// <locDE><para />Entfernt alle Elemente, deren Eigenschaft IsSelected = true enthält.</locDE>
        /// <code>
        /// var collection = new ObservableCollection&lt;SelectableItem&gt;();
        /// collection.RemoveAll(x =&gt; x.IsSelected);
        /// </code>
        /// </example>
        /// <returns>Number of removed items.<locDE><para />Anzahl der entfernten Elemente.</locDE></returns>
        public static int RemoveAll <T>(this System.Collections.Generic.ICollection <T> collection, Func <T, bool> condition)
        {
            if (null == collection)
            {
                return(0);
            }

            // .ToList() saves us from "collection was modified" exception
            // .ToList() bewahrt uns vor einer "Collection wurde verändert" Ausnahme.
            var itemsToRemove = collection.Where(condition).ToList();

            foreach (var itemToRemove in itemsToRemove)
            {
                collection.Remove(itemToRemove);
            }

            return(itemsToRemove.Count);
        }
コード例 #5
0
ファイル: Channel.cs プロジェクト: hanaforoosh/MAssenger
 internal bool RemoveAuthor(Account author)
 {
     Authors.Remove(author);
     return(true);
 }