Example #1
0
        public static byte[] ToUTF8ByteArrayOfStringNullOrEmptys(this IEnumerable <string> strings)
        {
            return(strings
                   .NullToEmpty()
                   .ToByteArray(
                       str =>
            {
                if (null == str)
                {
                    return new byte[] { 2 }
                }
                ;

                if (str.Length > 0)
                {
                    return (new byte[] { 0 })
                    .Concat(Encoding.UTF8.GetBytes(str))
                    .ToArray();
                }

                if (string.Empty == str)
                {
                    return new byte[] { 1 }
                }
                ;

                // Should never hit
                return new byte[] { 2 };
            }));
        }
Example #2
0
        public static TResult CreateToken <TResult>(Guid sessionId, Guid authId, Uri scope,
                                                    TimeSpan duration,
                                                    IEnumerable <Claim> claims,
                                                    Func <string, TResult> tokenCreated,
                                                    Func <string, TResult> missingConfigurationSetting,
                                                    Func <string, string, TResult> invalidConfigurationSetting,
                                                    string configNameOfIssuer       = EastFive.Security.AppSettings.TokenIssuer,
                                                    string configNameOfRSAKey       = EastFive.Security.AppSettings.TokenKey,
                                                    string configNameOfRSAAlgorithm = EastFive.Security.AppSettings.TokenAlgorithm,
                                                    IEnumerable <KeyValuePair <string, string> > tokenHeaders = default)
        {
            var claimsAuth = new[] {
                new Claim(ClaimEnableSessionAttribute.Type, sessionId.ToString()),
                new Claim(ClaimEnableActorAttribute.Type, authId.ToString())
            };
            var claimsCrypt = claims.NullToEmpty();

            var issued = DateTime.UtcNow;
            var result = EastFive.Security.Tokens.JwtTools.CreateToken(scope,
                                                                       issued, duration, claimsAuth.Concat(claimsCrypt),
                                                                       tokenCreated,
                                                                       missingConfigurationSetting,
                                                                       invalidConfigurationSetting,
                                                                       configNameOfIssuer, configNameOfRSAKey, configNameOfRSAAlgorithm, tokenHeaders);

            return(result);
        }
Example #3
0
        public virtual IEnumerable <object> LoadKeys(IEnumerable <string> tags = null, IEnumerable <Criteria> criterias = null)
        {
            if (Options.EnableLogging)
            {
                Log.Debug($"{TableName} count: tags={tags?.Join("||")}");
            }

            using (var conn = CreateConnection())
            {
                var sql = new StringBuilder($@"{SqlBuilder.BuildUseDatabase(Options.DatabaseName)} SELECT [key] FROM {TableName} WHERE [id]>0");
                foreach (var t in tags.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildTagSelect(t));
                }
                foreach (var c in criterias.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
                }
                //var sql = $@"SELECT [key] FROM {TableName} WHERE [id]>0";
                //tags.NullToEmpty().ForEach(t => sql += SqlBuilder.BuildTagSelect(t));
                //criterias.NullToEmpty().ForEach(c => sql += SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
                conn.Open();
                return(conn.Query <object>(sql.ToString()));
            }
        }
Example #4
0
 public virtual StorageAction Delete(IEnumerable <string> tags,
                                     IEnumerable <Criteria> criterias = null)
 {
     if (Options.EnableLogging)
     {
         Log.Debug($"{TableName} delete: tags={tags?.Join("||")}");
     }
     if (tags.IsNullOrEmpty())
     {
         return(StorageAction.None);
     }
     using (var conn = CreateConnection())
     {
         var sql = new StringBuilder($"{SqlBuilder.BuildUseDatabase(Options.DatabaseName)} {SqlBuilder.BuildDeleteByTags(TableName)}");
         foreach (var t in tags.NullToEmpty())
         {
             sql.Append(SqlBuilder.BuildTagSelect(t));
         }
         foreach (var c in criterias.NullToEmpty())
         {
             sql.Append(SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
         }
         //var sql = SqlBuilder.BuildDeleteByTags(TableName);
         //tags.NullToEmpty().ForEach(t => sql += SqlBuilder.BuildTagSelect(t));
         //criterias.NullToEmpty().ForEach(c => sql += SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
         conn.Open();
         var num = conn.Execute(sql.ToString());
         return(num > 0 ? StorageAction.Deleted : StorageAction.None);
     }
 }
Example #5
0
 public static byte[] ToByteArrayOfEnums(this IEnumerable <object> enums, Type enumType)
 {
     return(enums
            .NullToEmpty()
            .Select(enumValue => Enum.GetName(enumType, enumValue))
            .ToUTF8ByteArrayOfStrings());
 }
 public static IEnumerable <KeyValuePair <TKey, TValue> > PairWithValues <TKey, TValue>(this IEnumerable <TKey> keys, Func <TKey, TValue> calcValue)
 {
     foreach (var key in keys.NullToEmpty())
     {
         yield return(key.PairWithValue(calcValue(key)));
     }
 }
Example #7
0
 public static List <string> GetLocations(this IEnumerable <Type> types)
 {
     return(types
            .NullToEmpty()
            .Select(type => type.Assembly.Location)
            .Distinct()
            .ToList());
 }
Example #8
0
        /// <summary>
        /// Walks a directory tree and updates the list with  all the files found matching the specified mask.
        /// </summary>
        /// <remarks>
        ///Taken from one of the .Net tutorials in walking file structures.
        /// </remarks>
        /// <param name="root">The path to the directory to start searching</param>
        /// <param name="includeFileMask">A file mask to look for, e.g. *.txt</param>
        /// <param name="excludedFileNames">File names (not mask) to exclude</param>
        /// <returns>All files found anywhere in the directory tree of the <c>root</c> that match the mask and are not on the exclude list</returns>
        public static List <FileInfo> FindFilesInDirectoryTree(string root, string includeFileMask, IEnumerable <string> excludedFileNames = null)
        {
            excludedFileNames = excludedFileNames.NullToEmpty();
            var result = new List <FileInfo>();

            FindFilesInDirectoryTree(new DirectoryInfo(root), result, includeFileMask, excludedFileNames);
            return(result);
        }
Example #9
0
            public void GivenNonNull_ThenReturnsSameInstance()
            {
                IEnumerable <string> source  = Enumerable.Empty <string>();
                IEnumerable <int>    source2 = Enumerable.Range(0, 5);

                Assert.That(source.NullToEmpty(), Is.SameAs(source));
                Assert.That(source2.NullToEmpty(), Is.SameAs(source2));
            }
        public static TResult FlatMap <TItem, T1, TSelect, TResult>(this IEnumerable <TItem> items,
                                                                    T1 item1,
                                                                    Func <
                                                                        TItem, T1,
                                                                        Func <TSelect, T1, TResult>, // next
                                                                        Func <T1, TResult>,          // skip
                                                                        TResult> callback,
                                                                    Func <TSelect[], T1, TResult> complete)
        {
            if (typeof(TResult).IsGenericType && typeof(TResult).GetGenericTypeDefinition() == typeof(Task <>))
            {
                // Call it this way because we need to remap TResult from Task<TR> to TR
                var method  = typeof(MapReduceExtensions).GetMethod("FlatMapGenericAsync", BindingFlags.NonPublic | BindingFlags.Static);
                var generic = method.MakeGenericMethod(typeof(TItem), typeof(T1), typeof(TSelect), typeof(TResult).GenericTypeArguments.First());
                var r       = generic.Invoke(null, new object[] { items.NullToEmpty(), item1, callback, complete });
                var tr      = (TResult)r;
                return(tr);
            }

            return(items
                   .NullToEmpty()
                   .Aggregate(
                       item1.PairWithValue(new TSelect[] { }),
                       (aggr, item) =>
            {
                var block = new ManualResetEvent(false);
                var resultToDiscard = callback(
                    item, aggr.Key,
                    (selection, item1Next) =>
                {
                    aggr = item1Next.PairWithValue(aggr.Value.Append(selection).ToArray());
                    block.Set();
                    return default(TResult);
                },
                    (item1Next) =>
                {
                    aggr = item1Next.PairWithValue(aggr.Value);
                    block.Set();
                    return default(TResult);
                });
                block.WaitOne();
                return aggr;
            },
                       aggr => complete(aggr.Value, aggr.Key)));
        }
 public virtual IEnumerable <StringKey> GetKeys()
 {
     return(items
            .NullToEmpty()
            .Select(
                item => new StringKey
     {
         Equal = item,
     }));
 }
Example #12
0
 private IEnumerable<RoleAdminBindingModel> Map(IEnumerable<Role> sources)
 {
     foreach (var user in sources.NullToEmpty())
     {
         yield return new RoleAdminBindingModel
         {
             Id = user.Id.ToString(),
             Name = user.Name,
         };
     }
 }
Example #13
0
 public static byte[] ToByteArrayOfEnums <T>(this IEnumerable <T> enums) where T : System.Enum // : struct, IConvertible // When we switch to C# 7.3
 {
     if (!typeof(T).IsEnum)
     {
         throw new ArgumentException("T must be an enumerated type");
     }
     return(enums
            .NullToEmpty()
            .Select(enumValue => Enum.GetName(typeof(T), enumValue))
            .ToUTF8ByteArrayOfStrings());
 }
Example #14
0
 public static byte[] ToUTF8ByteArrayOfStrings(this IEnumerable <string> strings)
 {
     return(strings
            .NullToEmpty()
            .ToByteArray(
                str =>
     {
         return str.IsDefaultOrNull() ?
         new byte[] { }
                     :
         Encoding.UTF8.GetBytes(str);
     }));
 }
Example #15
0
 internal static IEnumerable <InvoiceValidationResult> Map(
     IEnumerable <Dto.BusinessValidationResultType> businessValidations,
     IEnumerable <Dto.TechnicalValidationResultType> technicalValidations)
 {
     return(Enumerable.Concat(
                businessValidations.NullToEmpty().Select(v => new InvoiceValidationResult(
                                                             message: v.message,
                                                             resultCode: (ValidationResultCode)v.validationResultCode
                                                             )),
                technicalValidations.NullToEmpty().Select(v => new InvoiceValidationResult(
                                                              message: v.message,
                                                              resultCode: (ValidationResultCode)v.validationResultCode
                                                              ))
                ));
 }
Example #16
0
        public DocStorage(IDbConnectionFactory connectionFactory, IStorageOptions options, ISqlBuilder sqlBuilder,
                          ISerializer serializer = null, IHasher hasher = null, IEnumerable <IIndexMap <TDoc> > indexMap = null)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (sqlBuilder == null)
            {
                throw new ArgumentNullException(nameof(sqlBuilder));
            }

            ConnectionFactory = connectionFactory;
            Options           = options;

            var builder = new SqlConnectionStringBuilder(options.ConnectionString);

            options.DataSource = builder.DataSource;
            if (!builder.InitialCatalog.IsNullOrEmpty()) // overrule database name if provided in connectionstring
            {
                Options.DatabaseName = builder.InitialCatalog;
            }

            SqlBuilder = sqlBuilder;
            Serializer = serializer ?? new JsonNetSerializer();
            Hasher     = hasher;// ?? new Md5Hasher();
            TableName  = options.GetTableName <TDoc>();
            IndexMaps  = indexMap.NullToEmpty().ToList().Where(im => im != null).OrderBy(i => i.Name);

            if (Options.EnableLogging)
            {
                Log.Debug($"datasource: {Options.DataSource}");
                Log.Debug($"database: {Options.DatabaseName}");
                Log.Debug($"schema: {Options.SchemaName}");
                Log.Debug($"table: {TableName}");
                IndexMaps.ForEach(
                    im => Log.Debug($"index map: {typeof(TDoc).Name} > {im.Name} [{im.Description}]"));
                //Log.Debug($"connection: {Options.ConnectionString}");
            }

            Initialize();
        }
Example #17
0
        public virtual IEnumerable <Stream> LoadData(object key, IEnumerable <string> tags = null,
                                                     IEnumerable <Criteria> criterias      = null,
                                                     DateTime?fromDateTime = null, DateTime?tillDateTime = null,
                                                     int skip = 0, int take = 0)
        {
            if (Options.EnableLogging)
            {
                Log.Debug(
                    $"{TableName} load: key={key}, tags={tags?.Join("||")}, criterias={criterias?.Select(c => c.Name + ":" + c.Value).Join("||")}");
            }

            using (var conn = CreateConnection())
            {
                var sql = new StringBuilder($"{SqlBuilder.BuildUseDatabase(Options.DatabaseName)} {SqlBuilder.BuildDataSelectByKey(TableName)}");
                foreach (var t in tags.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildTagSelect(t));
                }
                foreach (var c in criterias.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
                }
                sql.Append(SqlBuilder.BuildFromTillDateTimeSelect(fromDateTime, tillDateTime));
                sql.Append(SqlBuilder.BuildSortingSelect(Options.DefaultSortColumn));
                sql.Append(SqlBuilder.BuildPagingSelect(skip, take, Options.DefaultTakeSize, Options.MaxTakeSize));
                //var sql = SqlBuilder.BuildDataSelectByKey(TableName);
                //tags.NullToEmpty().ForEach(t => sql += SqlBuilder.BuildTagSelect(t));
                //criterias.NullToEmpty().ForEach(c => sql += SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
                //sql += SqlBuilder.BuildFromTillDateTimeSelect(fromDateTime, tillDateTime);
                //sql += SqlBuilder.BuildSortingSelect(Options.DefaultSortColumn);
                //sql += SqlBuilder.BuildPagingSelect(skip, take, Options.DefaultTakeSize, Options.MaxTakeSize);
                conn.Open();
                var results = conn.Query <byte[]>(sql.ToString(), new { key }, buffered: Options.BufferedLoad);
                if (results == null)
                {
                    yield break;
                }
                foreach (var data in results.Where(data => data != null))
                {
                    yield return(new MemoryStream(data.Decompress()));
                }
            }
        }
Example #18
0
        public virtual bool Exists(object key, IEnumerable <string> tags = null)
        {
            //Log.Debug($"document exists: key={key},tags={tags?.Join("||")}");

            var sql = new StringBuilder($@"{SqlBuilder.BuildUseDatabase(Options.DatabaseName)} SELECT [id] FROM {TableName} WHERE [key]='{key}'");

            foreach (var t in tags.NullToEmpty())
            {
                sql.Append(SqlBuilder.BuildTagSelect(t));
            }
            //var sql = $@"SELECT [id] FROM {TableName} WHERE [key]='{key}'";
            //tags.NullToEmpty().ForEach(t => sql += SqlBuilder.BuildTagSelect(t));

            using (var conn = CreateConnection())
            {
                conn.Open();
                return(conn.Query <int>(sql.ToString(), new { key }).Any());
            }
        }
Example #19
0
        private StorageAction Update(object key, TDoc document, Stream data, IEnumerable <string> tags, StringBuilder sql)
        {
            // UPDATE ===
            if (Options.EnableLogging)
            {
                Log.Debug($"{TableName} update: key={key},tags={tags?.Join("||")}");
            }
            var updateColumns = "[value]=@value";

            if (document != null && data != null)
            {
                updateColumns = $"{updateColumns},[data]=@data";
            }
            if (document == null && data != null)
            {
                updateColumns = "[data]=@data";
            }
            sql.Append(
                $@"
    {SqlBuilder.BuildUseDatabase(Options.DatabaseName)}
    UPDATE {TableName
                    }
    SET [tags]=@tags,[hash]=@hash,[timestamp]=@timestamp,{updateColumns
                    }
        {
                    IndexMaps.NullToEmpty()
                        .Select(
                            i =>
                                ",[" + i.Name.ToLower() + SqlBuilder.IndexColumnNameSuffix + "]=@" +
                                i.Name.ToLower() + SqlBuilder.IndexColumnNameSuffix)
                        .Join("")}
    WHERE [key]=@key");
            foreach (var t in tags.NullToEmpty())
            {
                sql.Append(SqlBuilder.BuildTagSelect(t));
            }
            return(StorageAction.Updated);
        }
Example #20
0
        public static string JwtToken(this System.Security.Cryptography.RSACryptoServiceProvider rsaProvider,
                                      string issuer, Uri scope,
                                      IEnumerable <Claim> claims,
                                      DateTime issued, TimeSpan duration,
                                      string algorithm,
                                      IEnumerable <KeyValuePair <string, string> > tokenHeaders = default)
        {
            var securityKey = new Microsoft.IdentityModel.Tokens.RsaSecurityKey(rsaProvider);

            var signature = new Microsoft.IdentityModel.Tokens.SigningCredentials(
                securityKey, algorithm);
            var expires = (issued + duration);
            var token   = new JwtSecurityToken(issuer, scope.AbsoluteUri, claims, issued, expires, signature);

            foreach (var kvp in tokenHeaders.NullToEmpty())
            {
                token.Header.Add(kvp.Key, kvp.Value);
            }

            var handler = new JwtSecurityTokenHandler();
            var jwt     = handler.WriteToken(token);

            return(jwt);
        }
        /// <summary>
        /// Helper as a lot of the API's want the main game directory and mod directories as separate items, but will process them the same, just with the order changing depending on what is to be overrriden.
        /// </summary>
        /// <param name="stellarisDirectoryHelper">The main game directoryHelper</param>
        /// <param name="modDirectoryHelpers">Directory helpers for the game mod, may be <c>null</c>.  This should be in the order they appear in the game loader (usually alphabetical) where conflicts will be resolved by a "first in wins" strategy.  E.g. Mods that are earlier on this list will overwrite mods that are later in this list.</param>
        /// <param name="position">Where the main game helper should be inserted compared to the source list of mods.  Defaults to "last" as the main game is usually overriden by all the mods, switching it to first will mean the game will override any conflicting items from mods</param>
        /// <returns>A list containing the game directory and the mod directories, with the game inserted in the specified location.  The list will be the reverse of what was passed in, because the easiest way to process things that need to override other things is to use a Dictionary and a "last in wins" strategy, which si the opposite of how the stellaris listing works.</returns>
        public static IList <StellarisDirectoryHelper> CreateCombinedList(
            StellarisDirectoryHelper stellarisDirectoryHelper,
            IEnumerable <StellarisDirectoryHelper> modDirectoryHelpers,
            StellarisDirectoryPositionModList position = StellarisDirectoryPositionModList.Last)
        {
            var stellarisDirectoryHelpers = modDirectoryHelpers.NullToEmpty().Reverse().ToList();

            // Because the source list has been reversed, we do the opposite of the insertion position to make it line up with the now reversed list
            // (because it is much easier to override thigns in a map by using a "last in wins" strategy.
            switch (position)
            {
            case StellarisDirectoryPositionModList.First:
                stellarisDirectoryHelpers.Add(stellarisDirectoryHelper);
                break;

            case StellarisDirectoryPositionModList.Last:
                stellarisDirectoryHelpers.Insert(0, stellarisDirectoryHelper);
                break;

            default: throw new Exception("Unknown StellarisDirectoryPositionModList " + position);
            }

            return(stellarisDirectoryHelpers);
        }
Example #22
0
        public virtual IEnumerable <TDoc> LoadValues(IEnumerable <string> tags        = null,
                                                     IEnumerable <Criteria> criterias = null,
                                                     DateTime?fromDateTime            = null, DateTime?tillDateTime = null,
                                                     int skip = 0, int take = 0)
        {
            if (Options.EnableLogging)
            {
                Log.Debug($"{TableName} load: tags={tags?.Join("||")}, criterias={criterias?.Select(c => c.Name + ":" + c.Value).Join("||")}");
            }

            using (var conn = CreateConnection())
            {
                var sql = new StringBuilder($"{SqlBuilder.BuildUseDatabase(Options.DatabaseName)} {SqlBuilder.BuildValueSelectByTags(TableName)}");
                foreach (var t in tags.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildTagSelect(t));
                }
                foreach (var c in criterias.NullToEmpty())
                {
                    sql.Append(SqlBuilder.BuildCriteriaSelect(IndexMaps, c));
                }
                sql.Append(SqlBuilder.BuildFromTillDateTimeSelect(fromDateTime, tillDateTime));
                sql.Append(SqlBuilder.BuildSortingSelect(Options.DefaultSortColumn));
                sql.Append(SqlBuilder.BuildPagingSelect(skip, take, Options.DefaultTakeSize, Options.MaxTakeSize));
                conn.Open();
                var documents = conn.Query <string>(sql.ToString(), buffered: Options.BufferedLoad);
                if (documents == null)
                {
                    yield break;
                }
                foreach (var document in documents)
                {
                    yield return(Serializer.FromJson <TDoc>(document));
                }
            }
        }
Example #23
0
            public void GivenNull_ThenReturnsEmpty()
            {
                IEnumerable <string>?source = null;

                Assert.That(source.NullToEmpty(), Is.Not.Null);
            }
Example #24
0
        public static IEnumerable <TItem> Reduce <TItem>(this IEnumerable <TItem> items,
                                                         ReduceCallbackDelegate <TItem> callback)
        {
            var enumerator      = items.NullToEmpty().GetEnumerator();
            var enumerationNext = new TItem[] { };

            if (!enumerator.MoveNext())
            {
                return(enumerationNext);
            }

            var  item1    = enumerator.Current;
            bool complete = true;

            while (true)
            {
                if (!enumerator.MoveNext())
                {
                    enumerationNext = enumerationNext.Append(item1).ToArray();
                    if (complete)
                    {
                        return(enumerationNext);
                    }

                    enumerator = enumerationNext.Cast <TItem>().GetEnumerator();

                    enumerator.MoveNext(); // next is always possible since item1 was added to enumerationNext before enumerator was created.
                    item1           = enumerator.Current;
                    enumerationNext = new TItem[] { };
                    complete        = true;
                    continue;
                }

                var item2    = enumerator.Current;
                var newItems = callback(item1, item2, out bool completeSingle).ToArray();
                complete = complete && completeSingle;

                // If items are returned...
                if (newItems.Any())
                {
                    // ...add all but the last item to the next iteration
                    enumerationNext = enumerationNext.Concat(newItems.Take(newItems.Length - 1)).ToArray();
                    // ...and use the last item as the new item1
                    item1 = newItems.Last();
                    continue;
                }

                #region if no items, were returned things get tricky

                // If there are more items to operate over..
                if (enumerator.MoveNext())
                {
                    // ... just use the next item as item1 and continue
                    item1 = enumerator.Current;
                    continue;
                }

                // otherwise, the interation needs to be started over again with the next round
                enumerator      = enumerationNext.Cast <TItem>().GetEnumerator();
                enumerationNext = new TItem[] { };

                // and if the next round is empty, all the items have been reduced out
                if (!enumerator.MoveNext())
                {
                    return(enumerationNext);
                }

                item1    = enumerator.Current;
                complete = true;

                #endregion
            }
        }
Example #25
0
 private IEnumerable<UserAdminBindingModel> Map(IEnumerable<User> sources)
 {
     foreach (var user in sources.NullToEmpty())
     {
             yield return new UserAdminBindingModel
             {
                 Id = user.Id.ToString(),
                 UserName = user.UserName,
                 Password = string.Empty,
                 Active = !user.Active.HasValue || user.Active.Value,
                 Organization = user.Organization,
                 Email = user.Email,
             };
     }
 }
 public static IEnumerable <TKey> SelectKeys <TKey, TValue>(this IEnumerable <KeyValuePair <TKey, TValue> > dictionary)
 {
     return(dictionary.NullToEmpty().Select(kvp => kvp.Key));
 }
Example #27
0
        public Template Create(string key, IEnumerable <string> tags = null)
        {
            var definition = _definitions.FirstOrDefault(t =>
                                                         t.Key.Equals(key, StringComparison.OrdinalIgnoreCase) &&
                                                         t.Tags.NullToEmpty().Intersect(tags.NullToEmpty()).Count().Equals(tags.NullToEmpty().Count()));

            if (definition == null)
            {
                throw new Exception($"no template found for name={key} and tags={tags}");
            }
            var instance = (Template)Activator.CreateInstance(definition.TemplateType, new object[] { });

            if (instance == null)
            {
                throw new Exception("template should be of type 'MailTemplate'");
            }
            return(instance);
        }
Example #28
0
 IEnumerable <ISymbol> GetAllPluginUnmappedAbstractPropsAndMethods()
 {
     return(PluginInfos.NullToEmpty().SelectMany(plugin => plugin.GetUnmappedAbstractMethodsAndProps()).ToList());
 }
Example #29
0
 public virtual IEnumerable <string> GetPrefixes()
 {
     return(items
            .NullToEmpty());
 }
Example #30
0
 public static string JoinString <T>(this IEnumerable <T> values, string separator)
 {
     return(string.Join(separator, values.NullToEmpty()));
 }
 public static string Format <T>(this IEnumerable <T> enumerable, Func <T, string> generator = null)
 {
     return($"[{string.Join(", ", enumerable.NullToEmpty().Select(e => generator?.Invoke(e) ?? e?.ToString()))}]");
 }
Example #32
0
 GetNamespaces(this IEnumerable <Type> types)
 {
     return(types
            .NullToEmpty()
            .Select(type => type.Namespace).Distinct().ToList());
 }