Пример #1
0
        static void Main(string[] args)
        {
            var serviceProvider = new ApplicationServiceProvider();
            var commandParser   = serviceProvider.GetService <ICommandParser>();
            var commands        = commandParser.Parse(args);

            commands.ForEach(command => command.Execute());
        }
Пример #2
0
        protected Sample(string name, ApplicationServiceProvider serviceProvider)
        {
            var entryAssembly = Assembly.GetEntryAssembly() !;

            _assemblyPath = Path.GetDirectoryName(entryAssembly.Location) !;

            _name            = name;
            _serviceProvider = serviceProvider;
        }
Пример #3
0
 /// <summary>
 /// Localizes all properties on each <see cref="ILocalizable"/> item in a collection with current language and depth=<see cref="LocalizationDepth.Shallow"/> and getOriginalValueIfNotFound=true
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="entities"></param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized entitis</returns>
 public static async Task <IEnumerable <TEntity> > LocalizeAsync <TEntity>(this IEnumerable <TEntity> entities,
                                                                           CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
                .LocalizeAsync(entities, cancellationToken));
     }
 }
Пример #4
0
 /// <summary>
 /// Find localized value with getOriginalValueIfNotFound=true
 /// </summary>
 /// <typeparam name="TEntity">Type</typeparam>
 /// <typeparam name="TPropType">TPropType</typeparam>
 /// <param name="entity">Entity</param>
 /// <param name="keySelector">Key selector</param>
 /// <returns>return localized value as TPropType</returns>
 public static async Task <TPropType> GetLocalizedValueAsync <TEntity, TPropType>(this TEntity entity,
                                                                                  Expression <Func <TEntity, TPropType> > keySelector,
                                                                                  CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
                .GetLocalizedValueAsync(entity, keySelector, cancellationToken));
     }
 }
Пример #5
0
 /// <summary>
 /// Localizes all properties on an <see cref="ILocalizable"/> item with current language and depth=<see cref="LocalizationDepth.Shallow"/>
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="entity"></param>
 /// <param name="getOriginalValueIfNotFound">A value indicating whether to return default value (if localized is not found)</param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized entity</returns>
 public static async Task <TEntity> LocalizeAsync <TEntity>(this TEntity entity,
                                                            bool getOriginalValueIfNotFound,
                                                            CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
                .LocalizeAsync(entity, getOriginalValueIfNotFound, cancellationToken));
     }
 }
 /// <summary>
 /// Localizes all properties on an <see cref="ILocalizedModel{TModel, TEntity}"/> item with current language
 /// and depth=<see cref="LocalizationDepth.Shallow"/> and getOriginalValueIfNotFound=true
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="model"></param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized model</returns>
 public static async Task <TModel> LocalizeAsync <TModel, TEntity>(this ILocalizedModel <TModel, TEntity> model,
                                                                   CancellationToken cancellationToken = default)
     where TModel : class, ILocalizedModel <TModel, TEntity>
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IModelLocalizer>()
                .LocalizeAsync(model, cancellationToken));
     }
 }
Пример #7
0
 /// <summary>
 /// Save localized entity with depth=<see cref="LocalizationDepth.Shallow"/>
 /// </summary>
 /// <typeparam name="TEntity">Type</typeparam>
 /// <param name="entity">Entity</param>
 /// <param name="languageId">Language identifier</param>
 public static async Task SaveLocalizedAsync <TEntity>(this TEntity entity,
                                                       int languageId,
                                                       CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
         .SaveLocalizedAsync(entity, languageId, cancellationToken);
     }
 }
Пример #8
0
 /// <summary>
 /// Localizes all properties on an <see cref="ILocalizable"/> item with specified language id and with getOriginalValueIfNotFound=true
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="entity"></param>
 /// <param name="languageId">Language identifier</param>
 /// <param name="depth">Depth of localization</param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized entity</returns>
 public static async Task <TEntity> LocalizeAsync <TEntity>(this TEntity entity,
                                                            int languageId,
                                                            LocalizationDepth depth,
                                                            CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
                .LocalizeAsync(entity, languageId, depth, cancellationToken));
     }
 }
 /// <summary>
 /// Localizes all properties on each <see cref="ILocalizedModel{TModel, TEntity}"/> item in a collection with current language
 /// and depth=<see cref="LocalizationDepth.Shallow"/>
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="models"></param>
 /// <param name="getOriginalValueIfNotFound">A value indicating whether to return default value (if localized is not found)</param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized models</returns>
 public static async Task <IEnumerable <TModel> > LocalizeAsync <TModel, TEntity>(IEnumerable <ILocalizedModel <TModel, TEntity> > models,
                                                                                  bool getOriginalValueIfNotFound,
                                                                                  CancellationToken cancellationToken = default)
     where TModel : class, ILocalizedModel <TModel, TEntity>
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IModelLocalizer>()
                .LocalizeAsync(models, getOriginalValueIfNotFound, cancellationToken));
     }
 }
Пример #10
0
 /// <summary>
 /// Save localized value
 /// </summary>
 /// <typeparam name="TEntity">Type</typeparam>
 /// <typeparam name="TPropType">TPropType</typeparam>
 /// <param name="entity">Entity</param>
 /// <param name="keySelector">Key selector</param>
 /// <param name="localeValue">Locale value</param>
 /// <param name="languageId">Language ID</param>
 public static async Task SaveLocalizedValueAsync <TEntity, TPropType>(this TEntity entity,
                                                                       Expression <Func <TEntity, TPropType> > keySelector,
                                                                       TPropType localeValue,
                                                                       int languageId,
                                                                       CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
         .SaveLocalizedValueAsync(entity, keySelector, localeValue, languageId, cancellationToken);
     }
 }
Пример #11
0
 /// <summary>
 /// Localizes all properties on each <see cref="ILocalizable"/> item in a collection with specified language id
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="entities"></param>
 /// <param name="languageId">Language identifier</param>
 /// <param name="getOriginalValueIfNotFound">A value indicating whether to return default value (if localized is not found)</param>
 /// <param name="depth">Depth of localization</param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized entitis</returns>
 public static async Task <IEnumerable <TEntity> > LocalizeAsync <TEntity>(this IEnumerable <TEntity> entities,
                                                                           int languageId,
                                                                           bool getOriginalValueIfNotFound,
                                                                           LocalizationDepth depth,
                                                                           CancellationToken cancellationToken = default)
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IEntityLocalizer>()
                .LocalizeAsync(entities, languageId, getOriginalValueIfNotFound, depth, cancellationToken));
     }
 }
 /// <summary>
 /// Save all localized properties of each LocalizedModel item in Locales collection property of model
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <typeparam name="TEntity"></typeparam>
 /// <typeparam name="TLocalizedModel"></typeparam>
 /// <param name="entity"></param>
 /// <param name="model"></param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns></returns>
 public static async Task SaveLocalesAsync <TModel, TEntity, TLocalizedModel>(this TEntity entity,
                                                                              ILocalizedModelForEdit <TModel, TEntity, TLocalizedModel> model,
                                                                              CancellationToken cancellationToken = default)
     where TModel : class, ILocalizedModelForEdit <TModel, TEntity, TLocalizedModel>
     where TEntity : class, ILocalizable
     where TLocalizedModel : class, ILocalizedLocaleModel
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         await serviceScope.ServiceProvider.GetRequiredService <IModelLocalizer>()
         .SaveLocalesAsync(entity, model, cancellationToken);
     }
 }
 /// <summary>
 /// Localizes all properties on each <see cref="ILocalizedModel{TModel, TEntity}"/> item in a collection with specified language id and
 /// getOriginalValueIfNotFound=true
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="models"></param>
 /// <param name="languageId">Language identifier</param>
 /// <param name="depth">Depth of localization</param>
 /// <param name="cancellationToken">A System.Threading.CancellationToken to observe while waiting for the task to complete.</param>
 /// <returns>Return localized models</returns>
 public static async Task <IEnumerable <TModel> > LocalizeAsync <TModel, TEntity>(this IEnumerable <ILocalizedModel <TModel, TEntity> > models,
                                                                                  int languageId,
                                                                                  LocalizationDepth depth,
                                                                                  CancellationToken cancellationToken = default)
     where TModel : class, ILocalizedModel <TModel, TEntity>
     where TEntity : class, ILocalizable
 {
     using (var serviceScope = ApplicationServiceProvider.CreateServiceScope())
     {
         return(await serviceScope.ServiceProvider.GetRequiredService <IModelLocalizer>()
                .LocalizeAsync(models, languageId, depth, cancellationToken));
     }
 }
Пример #14
0
 public HelloSierpinskiPyramid(string name, int recursionDepth, ApplicationServiceProvider serviceProvider)
     : base(name, recursionDepth, SierpinskiShape.Pyramid, serviceProvider)
 {
 }
Пример #15
0
 public HelloWindow(string name, ApplicationServiceProvider serviceProvider)
     : base(name, serviceProvider)
 {
 }
Пример #16
0
 public HelloSmoke(string name, bool isQuickAndDirty, ApplicationServiceProvider serviceProvider)
     : base(name, serviceProvider)
 {
     _isQuickAndDirty = isQuickAndDirty;
 }
Пример #17
0
 public PlaySampleAudio(string name, ApplicationServiceProvider serviceProvider)
     : base(name, serviceProvider)
 {
     _service = null;
 }
Пример #18
0
 public HelloTransform(string name, ApplicationServiceProvider serviceProvider)
     : base(name, serviceProvider)
 {
 }