Esempio n. 1
0
        /// <summary>
        /// TResult is the same type as T1 (output collection is the same generic as input)
        /// </summary>
        /// <typeparam name="T1"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="files_in"></param>
        /// <param name="func"></param>
        private static List <TResult> ChangeContent <T1, T2, TResult>(ChangeContentArgs a, Func <T1, T2, TResult> func, List <T1> files_in, T2 t2)
        {
            List <TResult> result = new List <TResult>(files_in.Count);

            for (int i = 0; i < files_in.Count; i++)
            {
                // Fully generic - no strict string can't return the same collection
                result.Add(func.Invoke(files_in[i], t2));
            }

            CA.RemoveDefaultT <TResult>(result);
            return(result);
        }
Esempio n. 2
0
        private static void RemoveNullOrEmpty(ChangeContentArgs a, List <string> files_in)
        {
            if (a != null)
            {
                if (a.removeNull)
                {
                    CA.RemoveDefaultT <string>(files_in);
                }

                if (a.removeEmpty)
                {
                    CA.RemoveStringsEmpty2(files_in);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Will be delete after final refactoring
        /// Automaticky ořeže poslední znad A1
        /// Pokud máš inty v A2, použij metodu JoinMakeUpTo2NumbersToZero
        /// </summary>
        /// <param name="delimiter"></param>
        /// <param name="parts"></param>
        public static string Join(IEnumerable parts, object delimiter)
        {
            if (CA.Count(parts) == 0)
            {
                return(string.Empty);
            }

            var d = delimiter.ToString();

            StringBuilder sb = new StringBuilder();

            foreach (var item in parts)
            {
                sb.Append(item.ToString() + d);
            }

            var vr = sb.ToString();

            return(vr.Substring(0, vr.Length - d.Length));
        }