//----------------------------------------------------------------------- // // Copyright (c) 2018 Sirenix IVS // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //----------------------------------------------------------------------- namespace VRC.Udon.Serialization.OdinSerializer.Utilities { using System; using System.Collections.Generic; /// /// Various LinQ extensions. /// public static class LinqExtensions { /// /// Perform an action on each item. /// /// The source. /// The action to perform. public static IEnumerable ForEach(this IEnumerable source, Action action) { foreach (var item in source) { action(item); } return source; } /// /// Perform an action on each item. /// /// The source. /// The action to perform. public static IEnumerable ForEach(this IEnumerable source, Action action) { int counter = 0; foreach (var item in source) { action(item, counter++); } return source; } /// /// Add a collection to the end of another collection. /// /// The collection. /// The collection to append. public static IEnumerable Append(this IEnumerable source, IEnumerable append) { foreach (var item in source) { yield return item; } foreach (var item in append) { yield return item; } } } }