├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── Images ├── Icon.png ├── Icon128x128.png └── Logo.xcf ├── LICENSE ├── MakeSourcePackages.ps1 ├── README.md ├── appveyor.yml └── src ├── .nuget └── NuGet.exe ├── Examples ├── Simplify.FluentNHibernate.Examples.Database │ ├── Accounts │ │ └── User.cs │ ├── ExampleSessionFactoryBuilder.cs │ ├── ExampleUnitOfWork.cs │ ├── Location │ │ ├── City.cs │ │ └── CityName.cs │ ├── Mappings │ │ ├── CityMap.cs │ │ ├── CityNameMap.cs │ │ └── UserMap.cs │ └── Simplify.FluentNHibernate.Examples.Database.csproj └── Simplify.FluentNHibernate.Examples.Domain │ ├── Accounts │ ├── IUser.cs │ ├── IUsersService.cs │ ├── TransactUsersService.cs │ └── UsersService.cs │ ├── IExampleUnitOfWork.cs │ ├── Location │ ├── CitiesService.cs │ ├── ICItiesService.cs │ ├── ICity.cs │ ├── ICityName.cs │ └── TransactCitiesService.cs │ └── Simplify.FluentNHibernate.Examples.Domain.csproj ├── Simplify.Cryptography.Tests ├── MD5Tests.cs └── Simplify.Cryptography.Tests.csproj ├── Simplify.Cryptography ├── MD5.cs └── Simplify.Cryptography.csproj ├── Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester ├── Dependency.cs ├── Dependency2.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Setup │ ├── IocRegistrations.cs │ └── ServiceCollectionIocRegistrations.cs ├── Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester.csproj ├── Startup.cs ├── appsettings.Development.json └── appsettings.json ├── Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection ├── DIContainerProviderExtensions.cs ├── DIRegistratorExtensions.cs ├── DIServiceProvider.cs ├── DIServiceScope.cs ├── DIServiceScopeFactory.cs └── Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.csproj ├── Simplify.DI.Provider.CastleWindsor.Tests ├── CastleWindsorDIContainerProviderTests.cs └── Simplify.DI.Provider.CastleWindsor.Tests.csproj ├── Simplify.DI.Provider.CastleWindsor ├── CastleWindsorDIProvider.cs ├── CastleWindsorLifetimeScope.cs ├── MisconfiguredComponentException.cs ├── Simplify.DI.Provider.CastleWindsor.csproj └── WindsorContainerExtensions.cs ├── Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection.Tests ├── MicrosoftDependencyInjectionDIProviderTests.cs └── Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection.Tests.csproj ├── Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection ├── MicrosoftDependencyInjectionDIProvider.cs ├── MicrosoftDependencyInjectionDIResolver.cs ├── MicrosoftDependencyInjectionILifetimeScope.cs └── Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection.csproj ├── Simplify.DI.Provider.SimpleInjector.Tests ├── SimpleInjectorDIContainerProviderTests.cs └── Simplify.DI.Provider.SimpleInjector.Tests.csproj ├── Simplify.DI.Provider.SimpleInjector ├── SimpleInjectorDIProvider.cs ├── SimpleInjectorLifetimeScope.cs └── Simplify.DI.Provider.SimpleInjector.csproj ├── Simplify.DI.Tests ├── DIContainerProviderTests.cs └── Simplify.DI.Tests.csproj ├── Simplify.DI.TestsTypes ├── Bar.cs ├── Foo.cs ├── IBar.cs ├── IFoo.cs ├── NonDepFoo.cs └── Simplify.DI.TestsTypes.csproj ├── Simplify.DI.Wcf ├── Simplify.DI.Wcf.csproj ├── SimplifyInstanceContextExtensions.cs ├── SimplifyInstanceProvider.cs ├── SimplifyServiceBehavior.cs ├── SimplifyServiceHost.cs ├── SimplifyServiceHostFactory.cs └── readme.txt ├── Simplify.DI ├── DIContainer.cs ├── DIRegistratorExtensions.cs ├── DIResolverExtensions.cs ├── IDIContainerProvider.cs ├── IDIContextHandler.cs ├── IDIRegistrator.cs ├── IDIResolver.cs ├── IDIVerifier.cs ├── ILifetimeScope.cs ├── LifetimeTypes.cs ├── Provider.DryIoc │ ├── DryIocDIProvider.cs │ ├── DryIocDIResolver.cs │ └── DryIocLifetimeScope.cs └── Simplify.DI.csproj ├── Simplify.Extensions.Tests ├── BytesExtensionsTests.cs ├── DateTimeExtensionsTests.cs ├── DoubleExtensionsTests.cs ├── Simplify.Extensions.Tests.csproj └── StringExtensionsTests.cs ├── Simplify.Extensions ├── BytesExtensions.cs ├── DateTimeExtensions.cs ├── DoubleExtensions.cs ├── Simplify.Extensions.Sources.nuspec ├── Simplify.Extensions.csproj └── StringExtensions.cs ├── Simplify.FluentNHibernate.Tests ├── App.config ├── ConfigurationExtensionsTests.cs ├── Entities │ └── Accounts │ │ └── User.cs ├── Mappings │ └── Accounts │ │ └── UserMap.cs ├── SessionExtensionsTests.cs ├── Simplify.FluentNHibernate.Tests.csproj ├── StatelessSessionExtensionsTests.cs └── appsettings.json ├── Simplify.FluentNHibernate ├── ConfigurationExtensions.cs ├── ConnectionConfigurationException.cs ├── Drivers │ └── OracleDataClientDriverFix.cs ├── SchemaExporter.cs ├── SessionExtensions.cs ├── Settings │ ├── DbConnectionSettings.cs │ └── Impl │ │ ├── ConfigurationBasedDbConnectionSettings.cs │ │ └── ConfigurationManagerBasedDbConnectionSettings.cs ├── Simplify.FluentNHibernate.csproj ├── SimplifyFluentNHibernateException.cs ├── SqlStatementInterceptor.cs └── StatelessSessionExtensions.cs ├── Simplify.IO.Tests ├── FileHelperTester.cs └── Simplify.IO.Tests.csproj ├── Simplify.IO ├── FileHelper.cs └── Simplify.IO.csproj ├── Simplify.Log ├── ILogger.cs ├── Logger.cs ├── LoggerException.cs ├── LoggerPathType.cs ├── Settings │ ├── ILoggerSettings.cs │ ├── Impl │ │ ├── ConfigurationBasedLoggerSettings.cs │ │ └── ConfigurationManagerBasedLoggerSettings.cs │ └── LoggerSettings.cs └── Simplify.Log.csproj ├── Simplify.Mail.IntegrationTests ├── App.config ├── MailSenderTests.cs └── Simplify.Mail.IntegrationTests.csproj ├── Simplify.Mail.TestConsoleApp ├── Program.cs ├── Setup │ └── IocRegistrations.cs ├── Simplify.Mail.TestConsoleApp.csproj └── appsettings.json ├── Simplify.Mail ├── IMailSender.cs ├── MailSender.cs ├── MailSenderAsyncExtensions.cs ├── MailSenderException.cs ├── Settings │ ├── IMailSenderSettings.cs │ ├── Impl │ │ ├── ConfigurationBasedMailSenderSettings.cs │ │ └── ConfigurationManagedBasedMailSenderSettings.cs │ └── MailSenderSettings.cs └── Simplify.Mail.csproj ├── Simplify.Pipelines ├── ChainHandler{T}.cs ├── IDataPreparer{T}.cs ├── Processing │ ├── IPipelineProcessor.cs │ ├── IPipelineStage{T}.cs │ ├── IPipeline{T}.cs │ ├── IResultingPipelineStage{T}.cs │ ├── IResultingPipeline{T}.cs │ ├── PipelineProcessor{T}.cs │ ├── Pipeline{T}.cs │ └── ResultingPipeline{T}.cs ├── Simplify.Pipelines.csproj └── Validation │ ├── DataRule.cs │ ├── IDataRule{T}.cs │ ├── IRule{T}.cs │ ├── IValidationPipelineProcessor{T}.cs │ ├── IValidationPipeline{T}.cs │ ├── Rule.cs │ ├── ValidationPipelineProcessor{T}.cs │ └── ValidationPipeline{T}.cs ├── Simplify.Repository.FluentNHibernate ├── AutoStatelessUnitOfWork.cs ├── AutoUnitOfWork.cs ├── FactoryManagerBase.cs ├── GenericRepository.cs ├── IdentityObject.cs ├── Mappings │ ├── IdentityObjectMap.cs │ └── NamedObjectMap.cs ├── NamedObject.cs ├── Simplify.Repository.FluentNHibernate.csproj ├── StatelessGenericRepository.cs ├── StatelessUnitOfWork.cs ├── TransactStatelessUnitOfWork.cs ├── TransactUnitOfWork.cs └── UnitOfWork.cs ├── Simplify.Repository ├── CommonEqualityComparer.cs ├── IAutoUnitOfWork.cs ├── IGenericRepository.cs ├── IIdentityObject.cs ├── INamedObject.cs ├── ITransactUnitOfWork.cs ├── IUnitOfWork.cs └── Simplify.Repository.csproj ├── Simplify.Resources.Tests ├── EnumStringTableBinderExtensionsTests.cs ├── ProgramResources.resx ├── ResourcesStringTableTests.cs ├── Simplify.Resources.Tests.csproj └── TestType.cs ├── Simplify.Resources ├── EnumStringTableBinderExtensions.cs ├── IResourcesStringTable.cs ├── ResourcesStringTable.cs ├── Simplify.Resources.csproj └── StringTable.cs ├── Simplify.Scheduler.IntegrationTester ├── BasicTaskProcessor.cs ├── DisposableDependency.cs ├── OneMinuteStepCrontabProcessor.cs ├── OneSecondStepProcessor.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Setup │ └── IocRegistrations.cs ├── Simplify.Scheduler.IntegrationTester.csproj ├── SimplifySchedulerException.cs ├── TwoParallelTasksProcessor.cs ├── TwoSecondStepProcessor.cs └── appsettings.json ├── Simplify.Scheduler ├── BasicScheduler.cs ├── CommandLine │ ├── CommandLineAction.cs │ ├── CommandLineProcessor.cs │ ├── ICommandLineProcessor.cs │ └── ProcessCommandLineResult.cs ├── Jobs │ ├── Crontab │ │ ├── CrontabProcessor.cs │ │ ├── CrontabProcessorFactory.cs │ │ ├── CrontabSchedulerJob.cs │ │ ├── CrontabSchedulerJobTask.cs │ │ ├── ICrontabProcessor.cs │ │ ├── ICrontabProcessorFactory.cs │ │ ├── ICrontabSchedulerJob.cs │ │ └── ICrontabSchedulerJobTask.cs │ ├── IJobArgs.cs │ ├── ISchedulerJob.cs │ ├── ISchedulerJobFactory.cs │ ├── InvokeMethodParameterType.cs │ ├── JobArgs.cs │ ├── SchedulerJob.cs │ ├── SchedulerJobFactory.cs │ └── Settings │ │ ├── ISchedulerJobSettings.cs │ │ ├── Impl │ │ └── ConfigurationBasedSchedulerJobSetting.cs │ │ └── SchedulerJobSettings.cs ├── MultitaskScheduler.cs ├── SchedulerExceptionArgs.cs ├── SchedulerInitializationException.cs ├── SchedulerJobsHandler.cs ├── Simplify.Scheduler.csproj └── SingleTaskScheduler.cs ├── Simplify.String.Tests ├── Simplify.String.Tests.csproj └── StringHelperTests.cs ├── Simplify.String ├── Simplify.String.Sources.nuspec ├── Simplify.String.csproj └── StringHelper.cs ├── Simplify.System.Tests ├── AssemblyInfoTests.cs └── Simplify.System.Tests.csproj ├── Simplify.System ├── ApplicationEnvironment.cs ├── AssemblyInfo.cs ├── IAssemblyInfo.cs ├── ITimeProvider.cs ├── Simplify.System.Sources.nuspec ├── Simplify.System.csproj ├── SystemTimeProvider.cs └── TimeProvider.cs ├── Simplify.Templates.Tests ├── IntegrationTemplateTests.cs ├── Models │ ├── BaseTestModel.cs │ ├── ChildTestModel.cs │ └── TestModel.cs ├── Simplify.Templates.Tests.csproj ├── TemplateModelExtensionsTests.cs ├── TemplateTests.cs └── TestData │ ├── Embedded │ ├── MasterTemplate.tpl │ ├── MasterTemplateResult.tpl │ ├── TemplateTest.tpl │ ├── TemplateTest.tpl-en.xml │ ├── TemplateTest.tpl-ru.xml │ └── TemplateTestResult.tpl │ └── Local │ ├── MasterTemplate.tpl │ ├── MasterTemplateResult.tpl │ ├── TemplateTest.tpl │ ├── TemplateTest.tpl.en.xml │ ├── TemplateTest.tpl.ru.xml │ └── TemplateTestResult.tpl ├── Simplify.Templates ├── IHideObjectMembers.cs ├── IModelSetter.cs ├── ITemplate.cs ├── ModelSetter.cs ├── ModelSetterBase.cs ├── Simplify.Templates.csproj ├── Template.cs ├── TemplateException.cs └── TemplateModelExtensions.cs ├── Simplify.Windows.Forms ├── Controls │ ├── NullableDateTimePicker.cs │ ├── TopmostProgressBar.Designer.cs │ ├── TopmostProgressBar.cs │ └── TopmostProgressBar.resx ├── ControlsValidator.cs ├── ListViewColumnSorter.cs ├── LocalResources.Designer.cs ├── LocalResources.resx ├── MessageBox.cs ├── Simplify.Windows.Forms.csproj └── TextBoxesValidator.cs ├── Simplify.WindowsServices.IntegrationTester ├── App.config ├── BasicTaskProcessor.cs ├── DisposableDependency.cs ├── OneMinuteStepCrontabProcessor.cs ├── OneSecondStepProcessor.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── ServiceInstaller.cs ├── Setup │ └── IocRegistrations.cs ├── Simplify.WindowsServices.IntegrationTester.csproj ├── SimplifyWindowsServicesException.cs ├── TwoParallelTasksProcessor.cs ├── TwoSecondStepProcessor.cs └── appsettings.json ├── Simplify.WindowsServices ├── BasicServiceHandler.cs ├── CommandLine │ ├── CommandLineAction.cs │ ├── CommandLineProcessor.cs │ ├── ICommandLineProcessor.cs │ ├── IInstallationController.cs │ ├── InstallationController.cs │ └── ProcessCommandLineResult.cs ├── Jobs │ ├── Crontab │ │ ├── CrontabProcessor.cs │ │ ├── CrontabProcessorFactory.cs │ │ ├── CrontabServiceJob.cs │ │ ├── CrontabServiceJobTask.cs │ │ ├── ICrontabProcessor.cs │ │ ├── ICrontabProcessorFactory.cs │ │ ├── ICrontabServiceJob.cs │ │ └── ICrontabServiceJobTask.cs │ ├── IJobArgs.cs │ ├── IServiceJob.cs │ ├── IServiceJobFactory.cs │ ├── InvokeMethodParameterType.cs │ ├── JobArgs.cs │ ├── ServiceJob.cs │ ├── ServiceJobFactory.cs │ └── Settings │ │ ├── IServiceJobSettings.cs │ │ ├── Impl │ │ ├── ConfigurationBasedServiceJobSetting.cs │ │ └── ConfigurationManagerBasedServiceJobSettings.cs │ │ └── ServiceJobSettings.cs ├── MultitaskServiceHandler.cs ├── ServiceExceptionArgs.cs ├── ServiceInitializationException.cs ├── ServiceInstallerBase.cs ├── Simplify.WindowsServices.csproj └── SingleTaskServiceHandler.cs ├── Simplify.Xml.Tests ├── Simplify.Xml.Tests.csproj ├── TestData │ ├── XmlWithNamespaces.xml │ └── XmlWithoutNamespaces..xml └── XmlExtensionsTests.cs ├── Simplify.Xml ├── Simplify.Xml.Sources.nuspec ├── Simplify.Xml.csproj ├── XmlExtensions.cs └── XmlSerializer.cs ├── Simplify.sln └── Simplify.sln.DotSettings /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Attach", 9 | "type": "coreclr", 10 | "request": "attach", 11 | "processId": "${command:pickProcess}" 12 | }, ] 13 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "dotnet-test-explorer.testProjectPath": "src/**/*Tests.csproj" 3 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/src/Simplify.sln" 11 | ], 12 | "problemMatcher": "$msCompile", 13 | "group": 14 | { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | }] 19 | } -------------------------------------------------------------------------------- /Images/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i4004/Simplify/7f0d0e400ee24d567570fbf27db3da049f331a19/Images/Icon.png -------------------------------------------------------------------------------- /Images/Icon128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i4004/Simplify/7f0d0e400ee24d567570fbf27db3da049f331a19/Images/Icon128x128.png -------------------------------------------------------------------------------- /Images/Logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i4004/Simplify/7f0d0e400ee24d567570fbf27db3da049f331a19/Images/Logo.xcf -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | 3 | image: Visual Studio 2017 4 | 5 | skip_tags: true 6 | clone_depth: 1 7 | 8 | configuration: Release 9 | platform: Any CPU 10 | 11 | before_build: 12 | - nuget restore src/Simplify.sln 13 | 14 | build: 15 | project: src/Simplify.sln 16 | publish_nuget: true 17 | parallel: true 18 | verbosity: minimal 19 | 20 | test: 21 | categories: 22 | except: 23 | - Integration 24 | 25 | deploy_script: 26 | - ps: .\MakeSourcePackages.ps1 27 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i4004/Simplify/7f0d0e400ee24d567570fbf27db3da049f331a19/src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Accounts/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Simplify.FluentNHibernate.Examples.Domain.Accounts; 3 | using Simplify.FluentNHibernate.Examples.Domain.Location; 4 | using Simplify.Repository.FluentNHibernate; 5 | 6 | namespace Simplify.FluentNHibernate.Examples.Database.Accounts 7 | { 8 | public class User : NamedObject, IUser 9 | { 10 | public virtual string Password { get; set; } 11 | 12 | public virtual string EMail { get; set; } 13 | 14 | public virtual ICity City { get; set; } 15 | 16 | public virtual DateTime LastActivityTime { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/ExampleSessionFactoryBuilder.cs: -------------------------------------------------------------------------------- 1 | using FluentNHibernate.Cfg; 2 | using NHibernate; 3 | using Simplify.FluentNHibernate.Examples.Database.Mappings; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Database 6 | { 7 | public class ExampleSessionFactoryBuilder 8 | { 9 | public ExampleSessionFactoryBuilder(string configSectionName = "ExampleDatabaseConnectionSettings") 10 | { 11 | var configuration = Fluently.Configure(); 12 | configuration.InitializeFromConfigMsSql(configSectionName); 13 | configuration.AddMappingsFromAssemblyOf(); 14 | Instance = configuration.BuildSessionFactory(); 15 | } 16 | 17 | public ISessionFactory Instance { get; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/ExampleUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using NHibernate; 2 | using Simplify.FluentNHibernate.Examples.Domain; 3 | using Simplify.Repository.FluentNHibernate; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Database 6 | { 7 | public class ExampleUnitOfWork : TransactUnitOfWork, IExampleUnitOfWork 8 | { 9 | public ExampleUnitOfWork(ISessionFactory sessionFactory) : base(sessionFactory) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Location/City.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using Simplify.FluentNHibernate.Examples.Domain.Location; 5 | using Simplify.Repository.FluentNHibernate; 6 | 7 | namespace Simplify.FluentNHibernate.Examples.Database.Location 8 | { 9 | public class City : IdentityObject, ICity 10 | { 11 | public virtual IList CityNames { get; set; } = new List(); 12 | 13 | public virtual string LocalizableName 14 | { 15 | get 16 | { 17 | if (CityNames.Count == 0) return ""; 18 | 19 | var cityName = CityNames.FirstOrDefault(p => p.Language == Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName); 20 | 21 | return cityName != null ? cityName.Name : ""; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Location/CityName.cs: -------------------------------------------------------------------------------- 1 | using Simplify.FluentNHibernate.Examples.Domain.Location; 2 | using Simplify.Repository.FluentNHibernate; 3 | 4 | namespace Simplify.FluentNHibernate.Examples.Database.Location 5 | { 6 | public class CityName : NamedObject, ICityName 7 | { 8 | public virtual ICity City { get; set; } 9 | 10 | public virtual string Language { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Mappings/CityMap.cs: -------------------------------------------------------------------------------- 1 | using Simplify.FluentNHibernate.Examples.Database.Location; 2 | using Simplify.Repository.FluentNHibernate.Mappings; 3 | 4 | namespace Simplify.FluentNHibernate.Examples.Database.Mappings 5 | { 6 | public class CityMap : IdentityObjectMap 7 | { 8 | public CityMap() 9 | { 10 | Table("Cities"); 11 | 12 | HasMany(x => x.CityNames) 13 | .KeyColumn("CityID") 14 | .Inverse() 15 | .Cascade.All() 16 | .Cascade.AllDeleteOrphan(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Mappings/CityNameMap.cs: -------------------------------------------------------------------------------- 1 | using Simplify.FluentNHibernate.Examples.Database.Location; 2 | using Simplify.Repository.FluentNHibernate.Mappings; 3 | 4 | namespace Simplify.FluentNHibernate.Examples.Database.Mappings 5 | { 6 | public class CityNameMap : NamedObjectMap 7 | { 8 | public CityNameMap() 9 | { 10 | Table("CitiesNames"); 11 | 12 | References(x => x.City, "CityID"); 13 | Map(x => x.Language); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Mappings/UserMap.cs: -------------------------------------------------------------------------------- 1 | using Simplify.FluentNHibernate.Examples.Database.Accounts; 2 | using Simplify.FluentNHibernate.Examples.Database.Location; 3 | using Simplify.Repository.FluentNHibernate.Mappings; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Database.Mappings 6 | { 7 | public class UserMap : NamedObjectMap 8 | { 9 | public UserMap() 10 | { 11 | Table("Users"); 12 | 13 | Map(x => x.Password); 14 | 15 | Map(x => x.EMail); 16 | 17 | References(x => x.City); 18 | 19 | Map(x => x.LastActivityTime); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Database/Simplify.FluentNHibernate.Examples.Database.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.FluentNHibernate database mappings examples 7 | Licensed under LGPL 8 | 1.0.4 9 | false 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Accounts/IUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Simplify.FluentNHibernate.Examples.Domain.Location; 3 | using Simplify.Repository; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Domain.Accounts 6 | { 7 | public interface IUser : INamedObject 8 | { 9 | string Password { get; set; } 10 | 11 | string EMail { get; set; } 12 | 13 | ICity City { get; set; } 14 | 15 | DateTime LastActivityTime { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Accounts/IUsersService.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.FluentNHibernate.Examples.Domain.Accounts 2 | { 3 | public interface IUsersService 4 | { 5 | IUser GetUser(string userName); 6 | 7 | void SetUserCity(int userID, int cityID); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Accounts/TransactUsersService.cs: -------------------------------------------------------------------------------- 1 | using System.Data; 2 | 3 | namespace Simplify.FluentNHibernate.Examples.Domain.Accounts 4 | { 5 | public class TransactUsersService : IUsersService 6 | { 7 | private readonly IUsersService _baseService; 8 | private readonly IExampleUnitOfWork _unitOfWork; 9 | 10 | public TransactUsersService(IUsersService baseService, IExampleUnitOfWork unitOfWork) 11 | { 12 | _baseService = baseService; 13 | _unitOfWork = unitOfWork; 14 | } 15 | 16 | public IUser GetUser(string userName) 17 | { 18 | _unitOfWork.BeginTransaction(IsolationLevel.ReadUncommitted); 19 | 20 | var item = _baseService.GetUser(userName); 21 | 22 | _unitOfWork.Commit(); 23 | 24 | return item; 25 | } 26 | 27 | public void SetUserCity(int userID, int cityID) 28 | { 29 | _unitOfWork.BeginTransaction(); 30 | 31 | _baseService.SetUserCity(userID, cityID); 32 | 33 | _unitOfWork.Commit(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Accounts/UsersService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Simplify.FluentNHibernate.Examples.Domain.Location; 3 | using Simplify.Repository; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Domain.Accounts 6 | { 7 | public class UsersService : IUsersService 8 | { 9 | private readonly IGenericRepository _repository; 10 | private readonly IGenericRepository _citiesRepository; 11 | 12 | public UsersService(IGenericRepository repository, IGenericRepository citiesRepository) 13 | { 14 | _repository = repository; 15 | _citiesRepository = citiesRepository; 16 | } 17 | 18 | public IUser GetUser(string userName) 19 | { 20 | if (userName == null) throw new ArgumentNullException(nameof(userName)); 21 | 22 | return _repository.GetSingleByQuery(x => x.Name == userName); 23 | } 24 | 25 | public void SetUserCity(int userID, int cityID) 26 | { 27 | var user = _repository.GetSingleByID(userID); 28 | var city = _citiesRepository.GetSingleByID(cityID); 29 | 30 | if (user == null) 31 | throw new Exception($"User with ID: {userID} is not found"); 32 | 33 | if (city == null) 34 | throw new Exception($"City with ID: {userID} is not found"); 35 | 36 | user.City = city; 37 | 38 | _repository.Update(user); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/IExampleUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using Simplify.Repository; 2 | 3 | namespace Simplify.FluentNHibernate.Examples.Domain 4 | { 5 | public interface IExampleUnitOfWork : ITransactUnitOfWork 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Location/CitiesService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Simplify.Repository; 4 | 5 | namespace Simplify.FluentNHibernate.Examples.Domain.Location 6 | { 7 | public class CitiesService : ICitiesService 8 | { 9 | private readonly IGenericRepository _repository; 10 | 11 | public CitiesService(IGenericRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public ICity GetCity(string cityName) 17 | { 18 | if (cityName == null) throw new ArgumentNullException(nameof(cityName)); 19 | 20 | return _repository.GetSingleByQuery(x => x.CityNames.Any(n => n.Name == cityName)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Location/ICItiesService.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.FluentNHibernate.Examples.Domain.Location 2 | { 3 | public interface ICitiesService 4 | { 5 | ICity GetCity(string cityName); 6 | } 7 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Location/ICity.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Simplify.Repository; 3 | 4 | namespace Simplify.FluentNHibernate.Examples.Domain.Location 5 | { 6 | public interface ICity : IIdentityObject 7 | { 8 | IList CityNames { get; set; } 9 | 10 | string LocalizableName { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Location/ICityName.cs: -------------------------------------------------------------------------------- 1 | using Simplify.Repository; 2 | 3 | namespace Simplify.FluentNHibernate.Examples.Domain.Location 4 | { 5 | public interface ICityName : INamedObject 6 | { 7 | ICity City { get; set; } 8 | 9 | string Language { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Location/TransactCitiesService.cs: -------------------------------------------------------------------------------- 1 | using System.Data; 2 | 3 | namespace Simplify.FluentNHibernate.Examples.Domain.Location 4 | { 5 | public class TransactCitiesService : ICitiesService 6 | { 7 | private readonly ICitiesService _baseService; 8 | private readonly IExampleUnitOfWork _unitOfWork; 9 | 10 | public TransactCitiesService(ICitiesService baseService, IExampleUnitOfWork unitOfWork) 11 | { 12 | _baseService = baseService; 13 | _unitOfWork = unitOfWork; 14 | } 15 | 16 | public ICity GetCity(string cityName) 17 | { 18 | _unitOfWork.BeginTransaction(IsolationLevel.ReadUncommitted); 19 | 20 | var item = _baseService.GetCity(cityName); 21 | 22 | _unitOfWork.Commit(); 23 | 24 | return item; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Examples/Simplify.FluentNHibernate.Examples.Domain/Simplify.FluentNHibernate.Examples.Domain.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.2 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.FluentNHibernate domain classes examples 7 | Licensed under LGPL 8 | 1.0.2 9 | false 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Simplify.Cryptography.Tests/MD5Tests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Cryptography.Tests 4 | { 5 | [TestFixture] 6 | public class MD5Tester 7 | { 8 | [Test] 9 | public void IsGetHashGettingCorrectly() 10 | { 11 | Assert.AreEqual("c4ca4238a0b923820dcc509a6f75849b", MD5.GetHash("1")); 12 | } 13 | 14 | [Test] 15 | public void IsVerifyHashCorrectly() 16 | { 17 | Assert.IsTrue(MD5.VerifyHash("1", "c4ca4238a0b923820dcc509a6f75849b")); 18 | Assert.IsFalse(MD5.VerifyHash("1", "c4ca4238a0b923820dcc509a6f75849c")); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Simplify.Cryptography.Tests/Simplify.Cryptography.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net452 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Cryptography unit tests 7 | Licensed under LGPL 8 | 1.0.0 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Simplify.Cryptography/Simplify.Cryptography.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net452 4 | Alexander Krylkov 5 | Simplify 6 | "Cryptography classes 7 | Licensed under LGPL 8 | 1.0.0 9 | https://github.com/i4004/Simplify/wiki/Simplify.Cryptography 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Cryptography 12 | GIT 13 | .NET cryptography md5 14 | 15 | * Upgrade to .NET Framework 4.5.2 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Cryptography.xml 19 | 20 | -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Dependency.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester 2 | { 3 | public class Dependency 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Dependency2.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester 2 | { 3 | public class Dependency2 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateWebHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 14 | WebHost.CreateDefaultBuilder(args) 15 | .UseStartup(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": 3 | { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": 7 | { 8 | "applicationUrl": "http://localhost:14062", 9 | "sslPort": 44361 10 | } 11 | }, 12 | "profiles": 13 | { 14 | "IIS Express": 15 | { 16 | "commandName": "IISExpress", 17 | "launchBrowser": true, 18 | "environmentVariables": 19 | { 20 | "ASPNETCORE_ENVIRONMENT": "Development" 21 | } 22 | }, 23 | "Simplify.DI.AspNetCore.Tester": 24 | { 25 | "commandName": "Project", 26 | "launchBrowser": true, 27 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 28 | "environmentVariables": 29 | { 30 | "ASPNETCORE_ENVIRONMENT": "Development" 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Setup/IocRegistrations.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester.Setup 2 | { 3 | public static class IocRegistrations 4 | { 5 | public static void Register() 6 | { 7 | DIContainer.Current.Register(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Setup/ServiceCollectionIocRegistrations.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester.Setup 4 | { 5 | public static class ServiceCollectionIocRegistrations 6 | { 7 | public static void Register(this IServiceCollection services) 8 | { 9 | services.AddScoped(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.2 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/Startup.cs: -------------------------------------------------------------------------------- 1 | using DryIoc; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester.Setup; 7 | using Simplify.DI.Provider.DryIoc; 8 | using System; 9 | 10 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester 11 | { 12 | public class Startup 13 | { 14 | public IServiceProvider ConfigureServices(IServiceCollection services) 15 | { 16 | // DryIoc specific workaround 17 | 18 | var container = new DryIocDIProvider 19 | { 20 | Container = new Container() 21 | .With(rules => rules.With(FactoryMethod.ConstructorWithResolvableArguments)) 22 | }; 23 | 24 | DIContainer.Current = container; 25 | 26 | // Registrations using `services` 27 | services.Register(); 28 | 29 | // Registrations using `DIContainer.Current` 30 | IocRegistrations.Register(); 31 | 32 | return DIContainer.Current.IntegrateWithMicrosoftDependencyInjectionAndVerify(services); 33 | } 34 | 35 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 36 | { 37 | if (env.IsDevelopment()) 38 | app.UseDeveloperExceptionPage(); 39 | 40 | app.Run(x => x.Response.WriteAsync("Hello World!")); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": 3 | { 4 | "LogLevel": 5 | { 6 | "Default": "Debug", 7 | "System": "Information", 8 | "Microsoft": "Information" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.Tester/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AllowedHosts": "*" 3 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection/DIServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection 4 | { 5 | /// 6 | /// Simplify.DI based service provider for Microsoft.Extensions.DependencyInjection 7 | /// 8 | /// 9 | public class DIServiceProvider : IServiceProvider 10 | { 11 | private readonly IDIResolver _resolver; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The registrator. 17 | public DIServiceProvider(IDIResolver resolver) 18 | { 19 | _resolver = resolver; 20 | } 21 | 22 | /// 23 | /// Gets the service object of the specified type. 24 | /// 25 | /// An object that specifies the type of service object to get. 26 | /// 27 | /// A service object of type serviceType. -or- null if there is no service object of type serviceType. 28 | /// 29 | public object GetService(Type serviceType) 30 | { 31 | return _resolver.Resolve(serviceType); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection/DIServiceScope.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection 5 | { 6 | /// 7 | /// Simplify.DI based service scope for Microsoft.Extensions.DependencyInjection 8 | /// 9 | /// 10 | public class DIServiceScope : IServiceScope 11 | { 12 | private readonly ILifetimeScope _scope; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The context handler. 18 | public DIServiceScope(IDIContextHandler contextHandler) 19 | { 20 | _scope = contextHandler.BeginLifetimeScope(); 21 | ServiceProvider = new DIServiceProvider(_scope.Resolver); 22 | } 23 | 24 | /// 25 | /// The used to resolve dependencies from the scope. 26 | /// 27 | public IServiceProvider ServiceProvider { get; set; } 28 | 29 | /// 30 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 31 | /// 32 | public void Dispose() 33 | { 34 | _scope.Dispose(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection/Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | Alexander Krylkov 5 | Simplify 6 | Provides ability to use Simplify.DI as IOC container instead of Microsoft.Extensions.DependencyInjection 7 | Licensed under LGPL 8 | 1.0-pre01 9 | https://github.com/i4004/Simplify/wiki/Simplify.DI.Wcf 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.DI.Wcf 12 | GIT 13 | .NET DI IOC-container Microsoft.Extensions.DependencyInjection 14 | 15 | 16 | bin\Any CPU\$(Configuration)\ 17 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.DI.Integration.Microsoft.Extensions.DependencyInjection.xml 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.CastleWindsor.Tests/Simplify.DI.Provider.CastleWindsor.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI.Provider.CastleWindsor unit tests 7 | Licensed under LGPL 8 | 1.3 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.CastleWindsor/CastleWindsorLifetimeScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Castle.MicroKernel.Lifestyle; 3 | 4 | namespace Simplify.DI.Provider.CastleWindsor 5 | { 6 | /// 7 | /// Castle Windsor DI provider lifetime scope implementation 8 | /// 9 | public class CastleWindsorLifetimeScope : ILifetimeScope 10 | { 11 | private readonly IDisposable _scope; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The provider. 17 | public CastleWindsorLifetimeScope(CastleWindsorDIProvider provider) 18 | { 19 | Resolver = provider; 20 | 21 | _scope = provider.Container.BeginScope(); 22 | } 23 | 24 | /// 25 | /// Gets the DI container resolver (should be used to resolve types when using scoping). 26 | /// 27 | /// 28 | /// The DI container resolver (should be used to resolve types when using scoping). 29 | /// 30 | public IDIResolver Resolver { get; } 31 | 32 | /// 33 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 34 | /// 35 | public void Dispose() 36 | { 37 | _scope.Dispose(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.CastleWindsor/MisconfiguredComponentException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI.Provider.CastleWindsor 4 | { 5 | /// 6 | /// Provides Castle.Windsor container verification exception 7 | /// 8 | /// 9 | public class MisconfiguredComponentException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message. 15 | public MisconfiguredComponentException(string message) : base(message) 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.CastleWindsor/Simplify.DI.Provider.CastleWindsor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.6;net452 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI CastleWindsor provider 7 | Licensed under LGPL 8 | 1.5 9 | https://github.com/i4004/Simplify/wiki/Simplify.DI 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.DI.Provider.CastleWindsor 12 | GIT 13 | .NET DI IOC-container-provider 14 | 15 | * Upgrade to Simplify.DI 3.0 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.DI.Provider.CastleWindsor.xml 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection.Tests/Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection unit tests 7 | Licensed under LGPL 8 | 1.0 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyInjectionDIResolver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Simplify.DI.Provider.DryIoc; 3 | using System; 4 | 5 | namespace Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection 6 | { 7 | /// 8 | /// Providers Microsoft.DependencyInjection resolver 9 | /// 10 | /// 11 | public class MicrosoftDependencyInjectionDIResolver : IDIResolver 12 | { 13 | private readonly IServiceProvider _serviceProvider; 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The resolver service provider. 19 | public MicrosoftDependencyInjectionDIResolver(IServiceProvider serviceProvider) 20 | { 21 | _serviceProvider = serviceProvider; 22 | } 23 | 24 | /// 25 | /// Resolves the specified type. 26 | /// 27 | /// The type. 28 | /// 29 | public object Resolve(Type type) 30 | { 31 | return _serviceProvider.GetRequiredService(type); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.SimpleInjector.Tests/Simplify.DI.Provider.SimpleInjector.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI.Provider.SimpleInjector unit tests 7 | Licensed under LGPL 8 | 1.3 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.SimpleInjector/SimpleInjectorLifetimeScope.cs: -------------------------------------------------------------------------------- 1 | using SimpleInjector; 2 | using SimpleInjector.Lifestyles; 3 | 4 | namespace Simplify.DI.Provider.SimpleInjector 5 | { 6 | /// 7 | /// Simple Injector DI provider lifetime scope implementation 8 | /// 9 | public class SimpleInjectorLifetimeScope : ILifetimeScope 10 | { 11 | private readonly Scope _scope; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The provider. 17 | public SimpleInjectorLifetimeScope(SimpleInjectorDIProvider provider) 18 | { 19 | Resolver = provider; 20 | 21 | _scope = AsyncScopedLifestyle.BeginScope(provider.Container); 22 | } 23 | 24 | /// 25 | /// Gets the DI container resolver (should be used to resolve types when using scoping). 26 | /// 27 | /// 28 | /// The DI container resolver (should be used to resolve types when using scoping). 29 | /// 30 | public IDIResolver Resolver { get; } 31 | 32 | /// 33 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 34 | /// 35 | public void Dispose() 36 | { 37 | _scope.Dispose(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Provider.SimpleInjector/Simplify.DI.Provider.SimpleInjector.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.3;net452 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI SimpleInjector provider 7 | Licensed under LGPL 8 | 1.7 9 | https://github.com/i4004/Simplify/wiki/Simplify.DI 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.DI.Provider.SimpleInjector 12 | GIT 13 | .NET DI IOC-container-provider 14 | 15 | * Upgrade to Simplify.DI 3.0 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.DI.Provider.SimpleInjector.xml 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Simplify.DI.Tests/Simplify.DI.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI unit tests 7 | Licensed under LGPL 8 | 1.2 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/Bar.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.TestsTypes 2 | { 3 | public class Bar : IBar 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/Foo.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.TestsTypes 2 | { 3 | public class Foo : IFoo 4 | { 5 | public Foo(IBar bar) 6 | { 7 | Bar = bar; 8 | } 9 | 10 | public IBar Bar { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/IBar.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.TestsTypes 2 | { 3 | public interface IBar 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/IFoo.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.TestsTypes 2 | { 3 | public interface IFoo 4 | { 5 | IBar Bar { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/NonDepFoo.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI.TestsTypes 2 | { 3 | public class NonDepFoo 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Simplify.DI.TestsTypes/Simplify.DI.TestsTypes.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.DI unit tests types 7 | Licensed under LGPL 8 | false 9 | 10 | -------------------------------------------------------------------------------- /src/Simplify.DI.Wcf/Simplify.DI.Wcf.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net452 4 | Alexander Krylkov 5 | Simplify 6 | Provides ability to use Simplify.DI as IOC container in WCF services 7 | Licensed under LGPL 8 | 1.3 9 | https://github.com/i4004/Simplify/wiki/Simplify.DI.Wcf 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.DI.Wcf 12 | GIT 13 | .NET DI IOC-container 14 | 15 | * Upgrade to Simplify.DI 3.0 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.DI.Wcf.xml 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Simplify.DI.Wcf/SimplifyInstanceContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.ServiceModel; 2 | 3 | namespace Simplify.DI.Wcf 4 | { 5 | internal static class SimplifyInstanceContextExtensions 6 | { 7 | public static ILifetimeScope BeginScope(this InstanceContext instanceContext) 8 | { 9 | var extension = instanceContext.Extensions.Find(); 10 | 11 | if (extension == null) 12 | instanceContext.Extensions.Add(extension = new SimplifyInstanceContextExtension()); 13 | 14 | return extension.Scope ?? (extension.Scope = DIContainer.Current.BeginLifetimeScope()); 15 | } 16 | 17 | public static ILifetimeScope GetScope(this InstanceContext instanceContext) 18 | { 19 | return instanceContext?.Extensions.Find()?.Scope; 20 | } 21 | 22 | private sealed class SimplifyInstanceContextExtension : IExtension 23 | { 24 | public ILifetimeScope Scope { get; set; } 25 | 26 | public void Attach(InstanceContext owner) 27 | { 28 | } 29 | 30 | public void Detach(InstanceContext owner) 31 | { 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Wcf/SimplifyServiceHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ServiceModel; 3 | 4 | namespace Simplify.DI.Wcf 5 | { 6 | /// 7 | /// Provides Simplify.DI WCF service host 8 | /// 9 | public class SimplifyServiceHost : ServiceHost 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public SimplifyServiceHost() 15 | { 16 | } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The type of hosted service. 22 | /// An array of type that contains the base addresses for the hosted service. 23 | public SimplifyServiceHost(Type serviceType, params Uri[] baseAddresses) 24 | : base(serviceType, baseAddresses) 25 | { 26 | } 27 | 28 | /// 29 | /// Invoked during the transition of a communication object into the opening state. 30 | /// 31 | protected override void OnOpening() 32 | { 33 | Description.Behaviors.Add(new SimplifyServiceBehavior()); 34 | 35 | base.OnOpening(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Wcf/SimplifyServiceHostFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ServiceModel; 3 | using System.ServiceModel.Activation; 4 | 5 | namespace Simplify.DI.Wcf 6 | { 7 | /// 8 | /// Provides Simplify.DI WCF service host factory 9 | /// 10 | public class SimplifyServiceHostFactory : ServiceHostFactory 11 | { 12 | /// 13 | /// Creates a for a specified type of service with a specific base address. 14 | /// 15 | /// Specifies the type of service to host. 16 | /// The of type that contains the base addresses for the service hosted. 17 | /// 18 | /// A for the type of service specified with a specific base address. 19 | /// 20 | protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) 21 | { 22 | return new SimplifyServiceHost(serviceType, baseAddresses); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.DI.Wcf/readme.txt: -------------------------------------------------------------------------------- 1 | To use Simplify.DI.Wcf please add Factory="Simplify.DI.Wcf.SimplifyServiceHostFactory" to your WCF service *.svc file. 2 | 3 | svc file example: 4 | <%@ ServiceHost Language="C#" Debug="true" Service="MyNamespace.Service" CodeBehind="Service.svc.cs" Factory="Simplify.DI.Wcf.SimplifyServiceHostFactory" %> 5 | 6 | 7 | Simplify.DI.Wcf documentation: https://github.com/i4004/Simplify/wiki/Simplify.DI.Wcf -------------------------------------------------------------------------------- /src/Simplify.DI/DIContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Simplify.DI.Provider.DryIoc; 3 | 4 | namespace Simplify.DI 5 | { 6 | /// 7 | /// IOC ambient context container to register/resolve objects for DI 8 | /// 9 | public class DIContainer 10 | { 11 | private static IDIContainerProvider _current; 12 | 13 | /// 14 | /// The IOC container 15 | /// 16 | public static IDIContainerProvider Current 17 | { 18 | get => _current ?? (_current = new DryIocDIProvider()); 19 | set => _current = value ?? throw new ArgumentNullException(nameof(value)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Simplify.DI/DIResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI 2 | { 3 | /// 4 | /// Provides DI resolver extensions 5 | /// 6 | public static class DIResolverExtensions 7 | { 8 | /// 9 | /// Resolves the specified type. 10 | /// 11 | /// 12 | /// The DI resolver. 13 | /// 14 | public static T Resolve(this IDIResolver resolver) 15 | { 16 | return (T)resolver.Resolve(typeof(T)); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Simplify.DI/IDIContainerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI 4 | { 5 | /// 6 | /// Represents DI container provider 7 | /// 8 | public interface IDIContainerProvider : IDIRegistrator, IDIResolver, IDIContextHandler, IDIVerifier, IDisposable 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Simplify.DI/IDIContextHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI 2 | { 3 | /// 4 | /// Represents DI container scoped context handler 5 | /// 6 | public interface IDIContextHandler 7 | { 8 | /// 9 | /// Begins the lifetime scope. 10 | /// 11 | /// 12 | ILifetimeScope BeginLifetimeScope(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/Simplify.DI/IDIRegistrator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI 4 | { 5 | /// 6 | /// Represents DI container registrator 7 | /// 8 | public interface IDIRegistrator 9 | { 10 | /// 11 | /// Registers the specified service type with corresponding implementation type. 12 | /// 13 | /// Service type. 14 | /// Implementation type. 15 | /// Lifetime type of the registering service type. 16 | void Register(Type serviceType, Type implementationType, LifetimeType lifetimeType = LifetimeType.PerLifetimeScope); 17 | 18 | /// 19 | /// Registers the specified service type for resolve with delegate for service implementation instance creation. 20 | /// 21 | /// Type of the service. 22 | /// The instance creator. 23 | /// Lifetime type of the registering concrete type. 24 | void Register(Type serviceType, Func instanceCreator, 25 | LifetimeType lifetimeType = LifetimeType.PerLifetimeScope); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Simplify.DI/IDIResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI 4 | { 5 | /// 6 | /// Represents DI container resolver 7 | /// 8 | public interface IDIResolver 9 | { 10 | /// 11 | /// Resolves the specified type. 12 | /// 13 | /// The type. 14 | /// 15 | object Resolve(Type type); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.DI/IDIVerifier.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI 2 | { 3 | /// 4 | /// Represents DI container verifier 5 | /// 6 | public interface IDIVerifier 7 | { 8 | /// 9 | /// Performs container objects graph verification 10 | /// 11 | void Verify(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/Simplify.DI/ILifetimeScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.DI 4 | { 5 | /// 6 | /// Represents DI container provider lifetime scope 7 | /// 8 | public interface ILifetimeScope : IDisposable 9 | { 10 | /// 11 | /// Gets the DI container resolver (should be used to resolve types when using scoping). 12 | /// 13 | /// 14 | /// The DI container resolver (should be used to resolve types when using scoping). 15 | /// 16 | IDIResolver Resolver { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.DI/LifetimeTypes.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.DI 2 | { 3 | /// 4 | /// Represents life time types of the registered service. 5 | /// 6 | public enum LifetimeType 7 | { 8 | /// 9 | /// The same object will be resolved for the same scope. 10 | /// 11 | PerLifetimeScope, 12 | 13 | /// 14 | /// This object will be created only once and the same object will be returned each time it is resolved. 15 | /// 16 | Singleton, 17 | 18 | /// 19 | /// The object will be created every time it is resolved. 20 | /// 21 | Transient 22 | } 23 | } -------------------------------------------------------------------------------- /src/Simplify.DI/Provider.DryIoc/DryIocDIResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DryIoc; 3 | 4 | namespace Simplify.DI.Provider.DryIoc 5 | { 6 | /// 7 | /// Providers DryIoc resolver 8 | /// 9 | /// 10 | public class DryIocDIResolver : IDIResolver 11 | { 12 | private readonly IResolverContext _resolverContext; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The resolver context. 18 | public DryIocDIResolver(IResolverContext resolverContext) 19 | { 20 | _resolverContext = resolverContext; 21 | } 22 | 23 | /// 24 | /// Resolves the specified type. 25 | /// 26 | /// The type. 27 | /// 28 | public object Resolve(Type type) 29 | { 30 | return _resolverContext.Resolve(type); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Simplify.DI/Provider.DryIoc/DryIocLifetimeScope.cs: -------------------------------------------------------------------------------- 1 | using DryIoc; 2 | 3 | namespace Simplify.DI.Provider.DryIoc 4 | { 5 | /// 6 | /// DryIoc DI provider lifetime scope implementation 7 | /// 8 | public class DryIocLifetimeScope : ILifetimeScope 9 | { 10 | private readonly IResolverContext _context; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The provider. 16 | public DryIocLifetimeScope(DryIocDIProvider provider) 17 | { 18 | _context = provider.Container.OpenScope(); 19 | Resolver = new DryIocDIResolver(_context); 20 | } 21 | 22 | /// 23 | /// Gets the DI container resolver (should be used to resolve types when using scoping). 24 | /// 25 | /// 26 | /// The DI container resolver (should be used to resolve types when using scoping). 27 | /// 28 | public IDIResolver Resolver { get; } 29 | 30 | /// 31 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 32 | /// 33 | public void Dispose() 34 | { 35 | _context.Dispose(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Simplify.DI/Simplify.DI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Simplify DI common interface for IOC containers 7 | Licensed under LGPL 8 | 3.0 9 | https://github.com/i4004/Simplify/wiki/Simplify.DI 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.DI 12 | GIT 13 | .NET DI IOC-container 14 | 15 | * `Type serviceType` with delegate registration method added 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.DI.xml 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Simplify.Extensions.Tests/BytesExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Extensions.Tests 4 | { 5 | [TestFixture] 6 | public class BytesExtensionsTests 7 | { 8 | [Test] 9 | public void BytesArray_GetString_GettingCorrectly() 10 | { 11 | // Assign 12 | var bytes = new byte[] { 116, 0, 101, 0, 115, 0, 116, 0 }; 13 | 14 | // Act & Assert 15 | Assert.AreEqual("test", bytes.GetString()); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions.Tests/DateTimeExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Extensions.Tests 4 | { 5 | [TestFixture] 6 | public class DateTimeExtensionsTests 7 | { 8 | [Test] 9 | public void TrimMilliseconds_DateTime_MillisecondsTrimmed() 10 | { 11 | // Act 12 | var result = new System.DateTime(2015, 02, 03, 14, 22, 13, 456).TrimMilliseconds(); 13 | 14 | // Assert 15 | Assert.AreEqual(0, result.Millisecond); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions.Tests/DoubleExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Extensions.Tests 4 | { 5 | [TestFixture] 6 | public class DoubleExtensionsTests 7 | { 8 | [Test] 9 | public void Double_CompareTwoDoubles_ComparedCorrectly() 10 | { 11 | Assert.IsTrue(15.27.AreSameAs(15.27)); 12 | Assert.IsTrue(155656564.272323231123.AreSameAs(155656564.272323231123)); 13 | Assert.IsFalse(155656564.2723232311.AreSameAs(155656564.2723232)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions.Tests/Simplify.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Extensions unit tests 7 | Licensed under LGPL 8 | 1.1.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Simplify.Extensions.Tests/StringExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Extensions.Tests 4 | { 5 | [TestFixture] 6 | public class StringExtensionsTests 7 | { 8 | [Test] 9 | public void String_ToBytesArray_ConvertedCorrectly() 10 | { 11 | Assert.AreEqual(new byte[] { 116, 0, 101, 0, 115, 0, 116, 0 }, "test".ToBytesArray()); 12 | } 13 | 14 | [Test] 15 | public void TryToDateTimeExact_WrongValue_COnvertedCorrectly() 16 | { 17 | // Assign 18 | const string str = "test"; 19 | 20 | // Act & Assert 21 | Assert.IsNull(str.TryToDateTimeExact("dd.MM.yy")); 22 | } 23 | 24 | [Test] 25 | public void TryToDateTimeExact_CorrectValue_COnvertedCorrectly() 26 | { 27 | // Assign 28 | const string str = "12.03.13"; 29 | 30 | // Act 31 | var time = str.TryToDateTimeExact("dd.MM.yy"); 32 | 33 | // Assert 34 | 35 | Assert.IsNotNull(time); 36 | Assert.AreEqual(12, time.Value.Day); 37 | Assert.AreEqual(3, time.Value.Month); 38 | Assert.AreEqual(2013, time.Value.Year); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions/BytesExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Extensions 4 | { 5 | /// 6 | /// Provides extensions fo the bytes[] arrays 7 | /// 8 | public static class BytesExtensions 9 | { 10 | /// 11 | /// Converts bytes array to a string. 12 | /// 13 | /// The bytes array. 14 | /// 15 | public static string GetString(this byte[] bytes) 16 | { 17 | var chars = new char[bytes.Length / sizeof(char)]; 18 | Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length); 19 | return new string(chars); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions/DateTimeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Extensions 4 | { 5 | /// 6 | /// Provides extensions for the DateTime struct 7 | /// 8 | public static class DateTimeExtensions 9 | { 10 | /// 11 | /// Removes milliseconds from DateTime 12 | /// 13 | /// Date and time. 14 | /// 15 | public static DateTime TrimMilliseconds(this DateTime dt) 16 | { 17 | return new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, 0); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions/DoubleExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Extensions 4 | { 5 | /// 6 | /// Provides extensions for the double class 7 | /// 8 | public static class DoubleExtensions 9 | { 10 | /// 11 | /// The epsilon value for double variables comparison 12 | /// 13 | public const double Epsilon = 0.000000000000000000001; 14 | 15 | /// 16 | /// Checking what two double values most likely the same ( the difference between values is less than Epsilon) 17 | /// 18 | /// First value to compare 19 | /// Second value to compare 20 | /// 21 | public static bool AreSameAs(this double a, double b) 22 | { 23 | return Math.Abs(a - b) < Epsilon; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Simplify.Extensions/Simplify.Extensions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Extensions for system classes 7 | Licensed under LGPL 8 | 1.1.1 9 | https://github.com/i4004/Simplify/wiki/Simplify.Extensions 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Extensions 12 | GIT 13 | .NET system-extensions 14 | 15 | * Added .NET Standard 1.0 support 16 | * Upgrade to .NET Framework 4.5.2 17 | 18 | bin\Any CPU\$(Configuration)\ 19 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Extensions.xml 20 | 21 | -------------------------------------------------------------------------------- /src/Simplify.Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Simplify.Extensions 5 | { 6 | /// 7 | /// Provides extensions for the string class 8 | /// 9 | public static class StringExtensions 10 | { 11 | /// 12 | /// Convert string to the bytes array. 13 | /// 14 | /// The string. 15 | /// 16 | public static byte[] ToBytesArray(this string str) 17 | { 18 | var bytes = new byte[str.Length * sizeof(char)]; 19 | Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); 20 | return bytes; 21 | } 22 | 23 | /// 24 | /// Converts the specified string representation of a date and time to its DateTime? equivalent using the specified format, invariant culture format information. The format of the string representation must match at least one of the specified formats exactly. The method returns a value if the conversion succeeded otherwise null 25 | /// 26 | /// A string containing one or more dates and times to convert. 27 | /// The required format of 28 | /// 29 | public static DateTime? TryToDateTimeExact(this string s, string format) 30 | { 31 | return DateTime.TryParseExact(s, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) ? date : (DateTime?)null; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate.Tests/Entities/Accounts/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.FluentNHibernate.Tests.Entities.Accounts 4 | { 5 | public class User 6 | { 7 | public virtual int ID { get; set; } 8 | 9 | public virtual string Name { get; set; } 10 | 11 | public virtual string Password { get; set; } 12 | 13 | public virtual string EMail { get; set; } 14 | 15 | public virtual DateTime LastActivityTime { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate.Tests/Mappings/Accounts/UserMap.cs: -------------------------------------------------------------------------------- 1 | using FluentNHibernate.Mapping; 2 | using Simplify.FluentNHibernate.Tests.Entities.Accounts; 3 | 4 | namespace Simplify.FluentNHibernate.Tests.Mappings.Accounts 5 | { 6 | public class UserMap : ClassMap 7 | { 8 | public UserMap() 9 | { 10 | Table("Users"); 11 | 12 | Id(x => x.ID); 13 | 14 | Map(x => x.Name); 15 | 16 | Map(x => x.Password); 17 | Map(x => x.EMail); 18 | Map(x => x.LastActivityTime); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate.Tests/Simplify.FluentNHibernate.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.FluentNHibernate unit tests 7 | Licensed under LGPL 8 | 1.4.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | PreserveNewest 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate.Tests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DatabaseConnectionSettings": 3 | { 4 | "ServerName": "localhost", 5 | "DataBaseName": "foodatabase", 6 | "UserName": "foouser", 7 | "UserPassword": "foopassword", 8 | "ShowSql": true 9 | } 10 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate/ConnectionConfigurationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.FluentNHibernate 4 | { 5 | /// 6 | /// The exception class using for Database connection configuration exceptions 7 | /// 8 | [Serializable] 9 | public sealed class DatabaseConnectionConfigurationException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public DatabaseConnectionConfigurationException(string message) : base(message) { } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate/SchemaExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using FluentNHibernate.Cfg; 4 | 5 | using NHibernate.Cfg; 6 | using NHibernate.Tool.hbm2ddl; 7 | 8 | namespace Simplify.FluentNHibernate 9 | { 10 | /// 11 | /// Entities to database exporter 12 | /// 13 | public static class SchemaExporter 14 | { 15 | /// 16 | /// Create database structure from entities 17 | /// 18 | /// The configuration. 19 | public static void Export(FluentConfiguration configuration) 20 | { 21 | if (configuration == null) throw new ArgumentNullException(nameof(configuration)); 22 | 23 | Configuration config = null; 24 | configuration.ExposeConfiguration(c => config = c); 25 | var factory = configuration.BuildSessionFactory(); 26 | 27 | var export = new SchemaExport(config); 28 | export.Execute(false, true, false, factory.OpenSession().Connection, null); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate/SimplifyFluentNHibernateException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.FluentNHibernate 4 | { 5 | /// 6 | /// Provides Simplify.FluentNHibernate related exception 7 | /// 8 | /// 9 | public class SimplifyFluentNHibernateException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public SimplifyFluentNHibernateException() 15 | { 16 | } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The message that describes the error. 22 | public SimplifyFluentNHibernateException(string message) : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The error message that explains the reason for the exception. 30 | /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. 31 | public SimplifyFluentNHibernateException(string message, Exception innerException) : base(message, innerException) 32 | { 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.FluentNHibernate/SqlStatementInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using NHibernate; 3 | using NHibernate.SqlCommand; 4 | 5 | namespace Simplify.FluentNHibernate 6 | { 7 | /// 8 | /// Executed SQL code tracer 9 | /// 10 | public class SqlStatementInterceptor : EmptyInterceptor 11 | { 12 | /// 13 | /// Called on sql statement prepare. 14 | /// 15 | /// The SQL. 16 | /// 17 | public override SqlString OnPrepareStatement(SqlString sql) 18 | { 19 | Trace.WriteLine($"SQL executed: '{sql}'"); 20 | return sql; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Simplify.IO.Tests/FileHelperTester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using NUnit.Framework; 4 | 5 | namespace Simplify.IO.Tests 6 | { 7 | [TestFixture] 8 | public class FileHelperTester 9 | { 10 | //[Test] 11 | //public void IsGetLastLineOfFileGettingCorrectly() 12 | //{ 13 | // Assert.AreEqual("", FileHelper.GetLastLineOfFile("TestData/Local/MasterTemplate.tpl")); 14 | // Assert.AreEqual(null, FileHelper.GetLastLineOfFile("TestData/EmptyFile.txt")); 15 | // Assert.Catch(() => FileHelper.GetLastLineOfFile(null)); 16 | // Assert.Catch(() => FileHelper.GetLastLineOfFile("NotFound")); 17 | //} 18 | 19 | [Test] 20 | public void IsFileLockedForRead() 21 | { 22 | Assert.Catch(() => FileHelper.IsFileLockedForRead(null)); 23 | Assert.Catch(() => FileHelper.IsFileLockedForRead("NotFound")); 24 | } 25 | 26 | [Test] 27 | [Category("Windows")] 28 | public void IsFileNameMadeValidCorrectly() 29 | { 30 | Assert.AreEqual("thisIsValid.txt", FileHelper.MakeValidFileName(@"thisIsValid.txt")); 31 | 32 | Assert.AreEqual("thisIsNotValid_3___3.txt", FileHelper.MakeValidFileName(@"thisIsNotValid\3\\_3.txt")); 33 | Assert.AreEqual("thisIsNotValid.t_xt", FileHelper.MakeValidFileName(@"thisIsNotValid.t\xt")); 34 | Assert.AreEqual("testfile_ do_.txt", FileHelper.MakeValidFileName(@"testfile: do?.txt")); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Simplify.IO.Tests/Simplify.IO.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net452 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.IO unit tests 7 | Licensed under LGPL 8 | 1.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.IO/Simplify.IO.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net452 4 | Alexander Krylkov 5 | Simplify 6 | IO helper functions 7 | Licensed under LGPL 8 | 1.0.7 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.IO 12 | GIT 13 | .NET IO 14 | 15 | * Upgrade to System.IO.Abstractions 2.1.0.178 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.IO.xml 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Simplify.Log/LoggerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Log 4 | { 5 | /// 6 | /// The exception class using for Logger exceptions 7 | /// 8 | [Serializable] 9 | public sealed class LoggerException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public LoggerException(string message) : base(message) { } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Log/LoggerPathType.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Log 2 | { 3 | /// 4 | /// Represent logger path type 5 | /// 6 | public enum LoggerPathType 7 | { 8 | /// 9 | /// The relative path type 10 | /// 11 | Relative, 12 | 13 | /// 14 | /// The full path type 15 | /// 16 | FullPath 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Log/Settings/ILoggerSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Log.Settings 2 | { 3 | /// 4 | /// Represent Simplify.Log settings 5 | /// 6 | public interface ILoggerSettings 7 | { 8 | /// 9 | /// Log file name 10 | /// 11 | string FileName { get; } 12 | 13 | /// 14 | /// Maximum file size (kb) 15 | /// 16 | int MaxFileSize { get; } 17 | 18 | /// 19 | /// File name path type 20 | /// 21 | LoggerPathType PathType { get; } 22 | 23 | /// 24 | /// Gets a value indicating whether logger messages should be shown in trace window. 25 | /// 26 | bool ShowTraceOutput { get; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Simplify.Log/Simplify.Log.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462 4 | Alexander Krylkov 5 | Simplify 6 | Simple logger 7 | Licensed under LGPL 8 | 1.4.2 9 | https://github.com/i4004/Simplify/wiki/Simplify.Log 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Log 12 | GIT 13 | .NET logger 14 | 15 | * Upgrade to System.IO.Abstractions 6.0.11 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Log.xml 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Simplify.Mail.IntegrationTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Simplify.Mail.IntegrationTests/MailSenderTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Mail.IntegrationTests 4 | { 5 | // For test SMTP server you can use https://github.com/rnwood/smtp4dev 6 | [TestFixture] 7 | [Category("Integration")] 8 | public class MailSenderTests 9 | { 10 | [Test] 11 | public void SendSimpleTestEmail() 12 | { 13 | MailSender.Default.Send("somesender@somedomain.com", "somereceiver@somedomain.com", "Hello subject", "Hello World!!!"); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Mail.IntegrationTests/Simplify.Mail.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Mail integration tests 7 | Licensed under LGPL 8 | 0.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Simplify.Mail.TestConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using Simplify.DI; 2 | using Simplify.Mail.TestConsoleApp.Setup; 3 | 4 | namespace Simplify.Mail.TestConsoleApp 5 | { 6 | internal class Program 7 | { 8 | private static void Main() 9 | { 10 | IocRegistrations.Register(); 11 | DIContainer.Current.Verify(); 12 | 13 | using (var scope = DIContainer.Current.BeginLifetimeScope()) 14 | { 15 | var sender = scope.Resolver.Resolve(); 16 | 17 | sender.Send("somesender@somedomain.com", "somereceiver@somedomain.com", "Hello subject", 18 | "Hello World!!!"); 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Simplify.Mail.TestConsoleApp/Setup/IocRegistrations.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Simplify.DI; 3 | 4 | namespace Simplify.Mail.TestConsoleApp.Setup 5 | { 6 | public static class IocRegistrations 7 | { 8 | public static void Register() 9 | { 10 | DIContainer.Current.Register(r => new ConfigurationBuilder() 11 | .AddJsonFile("appsettings.json", false) 12 | .Build()); 13 | 14 | DIContainer.Current.Register(r => new MailSender(r.Resolve())); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Mail.TestConsoleApp/Simplify.Mail.TestConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.1 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Mail .NET Core test app 7 | Licensed under LGPL 8 | 0.1 9 | bin\Any CPU\$(Configuration)\ 10 | Exe 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | PreserveNewest 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Simplify.Mail.TestConsoleApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MailSenderSettings": 3 | { 4 | "SmtpServerAddress": "localhost", 5 | "SmtpUserName": "test", 6 | "SmtpUserPassword": "test" 7 | } 8 | } -------------------------------------------------------------------------------- /src/Simplify.Mail/MailSenderException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Mail 4 | { 5 | /// 6 | /// The exception class using for MailSender exceptions 7 | /// 8 | [Serializable] 9 | public sealed class MailSenderException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public MailSenderException(string message) : base(message) { } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Simplify.Mail/Settings/IMailSenderSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Mail.Settings 2 | { 3 | /// 4 | /// Represent MailSender settings 5 | /// 6 | public interface IMailSenderSettings 7 | { 8 | /// 9 | /// The SMTP server address 10 | /// 11 | string SmtpServerAddress { get; } 12 | 13 | /// 14 | /// The SMTP server port number 15 | /// 16 | int SmtpServerPortNumber { get; } 17 | 18 | /// 19 | /// The mail sender SMTP user name 20 | /// 21 | string SmtpUserName { get; } 22 | 23 | /// 24 | /// The mail sender SMTP user password 25 | /// 26 | string SmtpUserPassword { get; } 27 | 28 | /// 29 | /// Anti-spam pool message life time (min.) 30 | /// 31 | int AntiSpamPoolMessageLifeTime { get; } 32 | 33 | /// 34 | /// Anti-spam messages pool on 35 | /// 36 | bool AntiSpamMessagesPoolOn { get; } 37 | 38 | /// 39 | /// Gets a value indicating whether SSL is enabled for connection. 40 | /// 41 | /// 42 | /// true if SSL is enabled for connection; otherwise, false. 43 | /// 44 | bool EnableSsl { get; } 45 | } 46 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/ChainHandler{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines 2 | { 3 | /// 4 | /// Provides chain of responsibility handler base class 5 | /// 6 | /// 7 | public abstract class ChainHandler 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | /// The successor handler. 13 | protected ChainHandler(ChainHandler successor = null) 14 | { 15 | Successor = successor; 16 | } 17 | 18 | /// 19 | /// Gets the successor handler. 20 | /// 21 | /// 22 | /// The successor. 23 | /// 24 | public ChainHandler Successor { get; } 25 | 26 | /// 27 | /// Executes the handler. 28 | /// 29 | /// The arguments. 30 | public virtual void Execute(T args) 31 | { 32 | Successor?.Execute(args); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/IDataPreparer{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Simplify.Pipelines 4 | { 5 | /// 6 | /// Represent data preparer (retriever) for pipeline processing 7 | /// 8 | /// 9 | public interface IDataPreparer 10 | { 11 | /// 12 | /// Gets the data for pipeline processing. 13 | /// 14 | /// 15 | IEnumerable GetData(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/IPipelineProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | /// Represent pipeline processor 5 | /// 6 | public interface IPipelineProcessor 7 | { 8 | /// 9 | /// Executes pipeline. 10 | /// 11 | void Execute(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/IPipelineStage{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | /// Represent pipeline stage 5 | /// 6 | /// 7 | public interface IPipelineStage 8 | { 9 | /// 10 | /// Executes the stage. 11 | /// 12 | /// The arguments. 13 | /// 14 | bool Execute(T args); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/IPipeline{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | /// Represent pipeline 5 | /// 6 | /// 7 | public interface IPipeline 8 | { 9 | /// 10 | /// Process args through pipeline. 11 | /// 12 | /// The arguments. 13 | /// 14 | bool Execute(T args); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/IResultingPipelineStage{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | /// Represent pipeline stage with processing error result information 5 | /// 6 | /// 7 | /// The type of the result. 8 | /// 9 | public interface IResultingPipelineStage : IPipelineStage 10 | { 11 | /// 12 | /// Gets the error result. 13 | /// 14 | /// 15 | /// The error result. 16 | /// 17 | TResult ErrorResult { get; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/IResultingPipeline{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | /// Represent pipeline with processing error result informatioo 5 | /// 6 | /// 7 | /// The type of the result. 8 | public interface IResultingPipeline 9 | { 10 | /// 11 | /// Process args through pipeline. 12 | /// 13 | /// The arguments. 14 | /// 15 | bool Execute(T args); 16 | 17 | /// 18 | /// Gets the error result. 19 | /// 20 | /// 21 | /// The error result. 22 | /// 23 | TResult ErrorResult { get; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/PipelineProcessor{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Processing 2 | { 3 | /// 4 | ///Provides default pipeline processor 5 | /// 6 | /// 7 | /// 8 | public class PipelineProcessor : IPipelineProcessor 9 | { 10 | private readonly IPipeline _pipeline; 11 | private readonly IDataPreparer _dataPreparer; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The pipeline. 17 | /// The data preparer. 18 | public PipelineProcessor(IPipeline pipeline, IDataPreparer dataPreparer) 19 | { 20 | _pipeline = pipeline; 21 | _dataPreparer = dataPreparer; 22 | } 23 | 24 | /// 25 | /// Retrieve data from preparer and process it through pipeline. 26 | /// 27 | public virtual void Execute() 28 | { 29 | var data = _dataPreparer.GetData(); 30 | 31 | foreach (var item in data) 32 | _pipeline.Execute(item); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Processing/Pipeline{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Simplify.Pipelines.Processing 4 | { 5 | /// 6 | /// Provides default pipeline 7 | /// 8 | /// 9 | /// 10 | public class Pipeline : IPipeline 11 | { 12 | private readonly IList> _stages; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The pipeline stages. 18 | public Pipeline(IList> stages) 19 | { 20 | _stages = stages; 21 | } 22 | 23 | /// 24 | /// Process pipeline stages. 25 | /// 26 | /// The arguments. 27 | /// 28 | 29 | public virtual bool Execute(T args) 30 | { 31 | // ReSharper disable once LoopCanBeConvertedToQuery 32 | foreach (var stage in _stages) 33 | if (!stage.Execute(args)) 34 | return false; 35 | 36 | return true; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Simplify.Pipelines.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Pipelines processing, validation patterns 7 | Licensed under LGPL 8 | 0.3.1 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Pipelines 12 | GIT 13 | .NET pipelines 14 | 15 | Added .NET Standard 1.0 support 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Pipelines.xml 19 | 20 | -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/DataRule.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Validation 2 | { 3 | /// 4 | /// Provides validation rule which can retrieve and hold data used by other rules 5 | /// 6 | /// The type of the data. 7 | /// 8 | /// The type of the result. 9 | /// 10 | /// 11 | public abstract class DataRule : Rule, IDataRule 12 | { 13 | /// 14 | /// Gets the rule data. 15 | /// 16 | /// 17 | /// The rule data. 18 | /// 19 | public abstract TData Data { get; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/IDataRule{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Validation 2 | { 3 | /// 4 | /// Represent validation rule which can retrieve and hold data used by other rules 5 | /// 6 | /// The type of the data. 7 | /// 8 | /// The type of the result. 9 | /// 10 | public interface IDataRule : IRule 11 | { 12 | /// 13 | /// Gets the data. 14 | /// 15 | /// 16 | /// The data. 17 | /// 18 | TData Data { get; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/IRule{T}.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Validation 2 | { 3 | /// 4 | /// Represent validation rule 5 | /// 6 | /// 7 | /// The type of the result. 8 | public interface IRule 9 | { 10 | /// 11 | /// Gets the result representing invalid result of rule validation. 12 | /// 13 | /// 14 | /// The invalid validation result. 15 | /// 16 | TResult InvalidValidationResult { get; } 17 | 18 | /// 19 | /// Validates the specified item through this rule. 20 | /// 21 | /// The item. 22 | /// 23 | bool Check(T item); 24 | 25 | /// 26 | /// Perfrom some action in case of invalid rule status. 27 | /// 28 | void GenerateInvalidAction(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/IValidationPipelineProcessor{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Simplify.Pipelines.Validation 4 | { 5 | /// 6 | /// Represent validation pipeline 7 | /// 8 | /// 9 | /// The type of the result. 10 | public interface IValidationPipelineProcessor 11 | { 12 | /// 13 | /// Executes the validation pipeline. 14 | /// 15 | /// 16 | IDictionary> Check(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/IValidationPipeline{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Simplify.Pipelines.Validation 4 | { 5 | /// 6 | /// Represent validation pipeline 7 | /// 8 | /// 9 | /// The type of the result. 10 | public interface IValidationPipeline 11 | { 12 | /// 13 | /// Validation the specified item through pipeline rules. 14 | /// 15 | /// The item. 16 | /// 17 | IList Check(T item); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/Rule.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Pipelines.Validation 2 | { 3 | /// 4 | /// Provides base validation rule 5 | /// 6 | /// 7 | /// The type of the result. 8 | /// 9 | public abstract class Rule : IRule 10 | { 11 | /// 12 | /// Gets the validation result in case of rule is invalid. 13 | /// 14 | /// 15 | /// The invalid validation result. 16 | /// 17 | public abstract TResult InvalidValidationResult { get; } 18 | 19 | /// 20 | /// Validates the specified item through this rule. 21 | /// 22 | /// The item. 23 | /// 24 | public abstract bool Check(T item); 25 | 26 | /// 27 | /// Generates the action for invalid rule. 28 | /// 29 | public virtual void GenerateInvalidAction() 30 | { 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/ValidationPipelineProcessor{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Simplify.Pipelines.Validation 5 | { 6 | /// 7 | /// Provides default validation pipeline processor 8 | /// 9 | /// 10 | /// The type of the result. 11 | /// 12 | public class ValidationPipelineProcessor : IValidationPipelineProcessor 13 | { 14 | private readonly IValidationPipeline _pipeline; 15 | private readonly IDataPreparer _dataPreparer; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The pipeline. 21 | /// The data preparer. 22 | public ValidationPipelineProcessor(IValidationPipeline pipeline, IDataPreparer dataPreparer) 23 | { 24 | _pipeline = pipeline; 25 | _dataPreparer = dataPreparer; 26 | } 27 | 28 | /// 29 | /// Executes the validation pipeline. 30 | /// 31 | /// 32 | public virtual IDictionary> Check() 33 | { 34 | var data = _dataPreparer.GetData(); 35 | 36 | return data.ToDictionary(item => item, item => _pipeline.Check(item)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Simplify.Pipelines/Validation/ValidationPipeline{T}.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Simplify.Pipelines.Validation 5 | { 6 | /// 7 | /// Provides default validation pipeline 8 | /// 9 | /// 10 | /// The type of the result. 11 | /// 12 | public class ValidationPipeline : IValidationPipeline 13 | { 14 | private readonly IList> _rules; 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The rules. 20 | public ValidationPipeline(IList> rules) 21 | { 22 | _rules = rules; 23 | } 24 | 25 | /// 26 | /// Validation the specified item through pipeline rules. 27 | /// 28 | /// The item. 29 | /// 30 | public virtual IList Check(T item) 31 | { 32 | return _rules.Where(x => !x.Check(item)).Select(x => x.InvalidValidationResult).ToList(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/AutoUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NHibernate; 3 | 4 | namespace Simplify.Repository.FluentNHibernate 5 | { 6 | /// 7 | /// Provides unit of work with auto-open transaction 8 | /// 9 | public class AutoUnitOfWork : UnitOfWork, IAutoUnitOfWork 10 | { 11 | private readonly ITransaction _transaction; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The session factory. 17 | public AutoUnitOfWork(ISessionFactory sessionFactory) : base(sessionFactory) 18 | { 19 | _transaction = Session.BeginTransaction(); 20 | } 21 | 22 | /// 23 | /// Commits transaction. 24 | /// 25 | /// Oops! We don't have an active transaction 26 | public virtual void Commit() 27 | { 28 | if (!_transaction.IsActive) 29 | throw new InvalidOperationException("Oops! We don't have an active transaction"); 30 | 31 | _transaction.Commit(); 32 | } 33 | 34 | /// 35 | /// Rollbacks transaction. 36 | /// 37 | public virtual void Rollback() 38 | { 39 | if (_transaction.IsActive) 40 | _transaction.Rollback(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/FactoryManagerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NHibernate; 3 | 4 | namespace Simplify.Repository.FluentNHibernate 5 | { 6 | /// 7 | /// Base class for session factory managers 8 | /// 9 | public abstract class FactoryManagerBase : IDisposable 10 | { 11 | /// 12 | /// Gets or sets the instance. 13 | /// 14 | /// 15 | /// The instance. 16 | /// 17 | public ISessionFactory Instance { get; protected set; } 18 | 19 | /// 20 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 21 | /// 22 | public void Dispose() 23 | { 24 | Instance?.Dispose(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/IdentityObject.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository.FluentNHibernate 2 | { 3 | /// 4 | /// Provides object with identifier 5 | /// 6 | public class IdentityObject : IIdentityObject 7 | { 8 | /// 9 | /// Gets or sets the identifier. 10 | /// 11 | /// 12 | /// The identifier. 13 | /// 14 | public virtual int ID { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/Mappings/IdentityObjectMap.cs: -------------------------------------------------------------------------------- 1 | using FluentNHibernate.Mapping; 2 | 3 | namespace Simplify.Repository.FluentNHibernate.Mappings 4 | { 5 | /// 6 | /// Identity object mapping 7 | /// 8 | /// 9 | public class IdentityObjectMap : ClassMap 10 | where T : IIdentityObject 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public IdentityObjectMap() 16 | { 17 | Id(x => x.ID); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/Mappings/NamedObjectMap.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository.FluentNHibernate.Mappings 2 | { 3 | /// 4 | /// Named object mapping 5 | /// 6 | /// 7 | public class NamedObjectMap : IdentityObjectMap 8 | where T : INamedObject 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public NamedObjectMap() 14 | { 15 | Map(x => x.Name).Not.Nullable(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/NamedObject.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository.FluentNHibernate 2 | { 3 | /// 4 | /// Provides object with name 5 | /// 6 | public class NamedObject : IdentityObject, INamedObject 7 | { 8 | /// 9 | /// Gets or sets the name. 10 | /// 11 | /// 12 | /// The name. 13 | /// 14 | public virtual string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/Simplify.Repository.FluentNHibernate.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net462 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Repository FluentNHibernate implementation 7 | Licensed under LGPL 8 | 1.0.2 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Repository.FluentNHibernate 12 | GIT 13 | .NET Repository UoW Model 14 | 15 | Updates 16 | * Upgrade to Simplify.Repository 1.1.0 17 | Fixes 18 | * StatelessUnitOfWork dispose fix 19 | 20 | bin\Any CPU\$(Configuration)\ 21 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Repository.FluentNHibernate.xml 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Simplify.Repository.FluentNHibernate/UnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NHibernate; 3 | 4 | namespace Simplify.Repository.FluentNHibernate 5 | { 6 | /// 7 | /// Provides unit of work 8 | /// 9 | public class UnitOfWork : IUnitOfWork 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The session factory. 15 | public UnitOfWork(ISessionFactory sessionFactory) 16 | { 17 | Session = sessionFactory.OpenSession(); 18 | } 19 | 20 | /// 21 | /// Gets the session. 22 | /// 23 | /// 24 | /// The session. 25 | /// 26 | public ISession Session { get; private set; } 27 | 28 | /// 29 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 30 | /// 31 | public void Dispose() 32 | { 33 | Dispose(true); 34 | GC.SuppressFinalize(this); 35 | } 36 | 37 | /// 38 | /// Releases unmanaged and - optionally - managed resources. 39 | /// 40 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 41 | protected virtual void Dispose(bool disposing) 42 | { 43 | if (!disposing) 44 | return; 45 | 46 | Session?.Dispose(); 47 | Session = null; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/CommonEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Simplify.Repository 4 | { 5 | /// 6 | /// Provides objects comparer based on IIdentityObject 7 | /// 8 | /// 9 | public class CommonEqualityComparer : IEqualityComparer 10 | { 11 | /// 12 | /// Determines whether the specified , is equal to this instance. 13 | /// 14 | /// The to compare with this instance. 15 | /// The y. 16 | /// 17 | /// true if the specified is equal to this instance; otherwise, false. 18 | /// 19 | public new virtual bool Equals(object x, object y) 20 | { 21 | if (x == null || y == null) 22 | return false; 23 | 24 | if (x is IIdentityObject identityObjectA && y is IIdentityObject identityObjectB) 25 | return identityObjectA.ID == identityObjectB.ID; 26 | 27 | return x.Equals(y); 28 | } 29 | 30 | /// 31 | /// Returns a hash code for this instance. 32 | /// 33 | /// The object. 34 | /// 35 | /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 36 | /// 37 | public int GetHashCode(object obj) 38 | { 39 | return obj.GetHashCode(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/IAutoUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository 2 | { 3 | /// 4 | /// Represent unit of work with auto-open transaction 5 | /// 6 | public interface IAutoUnitOfWork : IUnitOfWork 7 | { 8 | /// 9 | /// Commits transaction. 10 | /// 11 | void Commit(); 12 | 13 | /// 14 | /// Rollbacks transaction. 15 | /// 16 | void Rollback(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/IIdentityObject.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository 2 | { 3 | /// 4 | /// Represent object with identifier 5 | /// 6 | public interface IIdentityObject 7 | { 8 | /// 9 | /// Gets the identifier. 10 | /// 11 | /// 12 | /// The identifier. 13 | /// 14 | int ID { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/INamedObject.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Repository 2 | { 3 | /// 4 | /// Represent object with name 5 | /// 6 | public interface INamedObject : IIdentityObject 7 | { 8 | /// 9 | /// Gets or sets the name. 10 | /// 11 | /// 12 | /// The name. 13 | /// 14 | string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/ITransactUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System.Data; 2 | 3 | namespace Simplify.Repository 4 | { 5 | /// 6 | /// Represent unit of work with manual open transaction 7 | /// 8 | public interface ITransactUnitOfWork : IUnitOfWork 9 | { 10 | /// 11 | /// Begins the transaction. 12 | /// 13 | /// The isolation level. 14 | void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted); 15 | 16 | /// 17 | /// Commits transaction. 18 | /// 19 | void Commit(); 20 | 21 | /// 22 | /// Rollbacks transaction. 23 | /// 24 | void Rollback(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Repository 4 | { 5 | /// 6 | /// Represent unit of work without explicit transaction 7 | /// 8 | public interface IUnitOfWork : IDisposable 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Simplify.Repository/Simplify.Repository.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.2;net452 4 | Alexander Krylkov 5 | Simplify 6 | Repository, unit of work and related patterns interfaces 7 | Licensed under LGPL 8 | 1.1 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Repository 12 | GIT 13 | .NET Repository UoW Model 14 | 15 | * CommonEqualityComparer added (useful for mappings integration tests) 16 | - IHideObjectMembers removed 17 | 18 | bin\Any CPU\$(Configuration)\ 19 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Repository.xml 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Simplify.Resources.Tests/EnumStringTableBinderExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Simplify.Resources.Tests 4 | { 5 | [TestFixture] 6 | public class EnumStringTableBinderExtensionsTests 7 | { 8 | private IResourcesStringTable _uow; 9 | 10 | [SetUp] 11 | public void Initialize() 12 | { 13 | _uow = new ResourcesStringTable(true, "ProgramResources"); 14 | } 15 | 16 | [Test] 17 | public void GetAssociatedValue_ExistingString_Found() 18 | { 19 | // Act 20 | var testString = _uow.GetAssociatedValue(TestType.Value1); 21 | 22 | // Assert 23 | Assert.AreEqual("Enum value 1", testString); 24 | } 25 | 26 | [Test] 27 | public void GetAssociatedValue_NoExistingString_Null() 28 | { 29 | // Act 30 | var testString = _uow.GetAssociatedValue(TestType.Value2); 31 | 32 | // Assert 33 | Assert.IsNull(testString); 34 | } 35 | 36 | [Test] 37 | public void GetKeyValuePairList_NoExistingString_Null() 38 | { 39 | // Act 40 | var valuesList = _uow.GetKeyValuePairList(); 41 | 42 | // Assert 43 | 44 | Assert.AreEqual(2, valuesList.Count); 45 | Assert.AreEqual(TestType.Value1, valuesList[0].Key); 46 | Assert.AreEqual("Enum value 1", valuesList[0].Value); 47 | Assert.AreEqual(TestType.Value2, valuesList[1].Key); 48 | Assert.IsNull(valuesList[1].Value); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/Simplify.Resources.Tests/ResourcesStringTableTests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using NUnit.Framework; 3 | 4 | namespace Simplify.Resources.Tests 5 | { 6 | [TestFixture] 7 | public class ResourcesStringTableTests 8 | { 9 | private IResourcesStringTable _uow; 10 | 11 | [SetUp] 12 | public void Initialize() 13 | { 14 | } 15 | 16 | [Test] 17 | public void ResourcesStringTableIndexer_ExistingString_Found() 18 | { 19 | //Assign 20 | 21 | _uow = new ResourcesStringTable(true, "ProgramResources"); 22 | 23 | // Act 24 | var testString = _uow["TestString"]; 25 | 26 | // Assert 27 | Assert.AreEqual("Hello World!", testString); 28 | } 29 | 30 | [Test] 31 | public void ResourcesStringTableIndexer_CustomAssemblyExistingString_Found() 32 | { 33 | //Assign 34 | 35 | _uow = new ResourcesStringTable(Assembly.GetAssembly(typeof(ResourcesStringTableTests)), "ProgramResources"); 36 | 37 | // Act 38 | var testString = _uow["TestString"]; 39 | 40 | // Assert 41 | Assert.AreEqual("Hello World!", testString); 42 | } 43 | 44 | [Test] 45 | public void ResourcesStringTableIndexer_NoExistingString_Null() 46 | { 47 | // Act 48 | var testString = _uow["TestString2"]; 49 | 50 | // Assert 51 | Assert.IsNull(testString); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/Simplify.Resources.Tests/Simplify.Resources.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.System unit tests 7 | Licensed under LGPL 8 | 0.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Simplify.Resources.Tests/TestType.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Resources.Tests 2 | { 3 | public enum TestType 4 | { 5 | Value1, 6 | Value2 7 | } 8 | } -------------------------------------------------------------------------------- /src/Simplify.Resources/IResourcesStringTable.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Resources 2 | { 3 | /// 4 | /// Interface for getting assembly resource file string 5 | /// 6 | public interface IResourcesStringTable 7 | { 8 | /// 9 | /// Get string table record by name 10 | /// 11 | string this[string name] { get; } 12 | 13 | /// 14 | /// Get string table record by name 15 | /// 16 | string GetString(string name); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Resources/Simplify.Resources.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Classes for working with assembly resource files (localizable string table) 7 | Licensed under LGPL 8 | 1.0.1 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Resources 12 | GIT 13 | .NET assembly-resources 14 | 15 | + .NET Standard 2.0 Support 16 | * Upgrade to .NET Framework 4.5.2 17 | - CustomComponentResourceManager removed 18 | 19 | bin\Any CPU\$(Configuration)\ 20 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Resources.xml 21 | 22 | -------------------------------------------------------------------------------- /src/Simplify.Resources/StringTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Resources 4 | { 5 | /// 6 | /// Provides application string tables access 7 | /// 8 | public static class StringTable 9 | { 10 | private static IResourcesStringTable _entryStringTable; 11 | 12 | /// 13 | /// Entry assembly string table (ProgramResources.resx) 14 | /// 15 | public static IResourcesStringTable Entry 16 | { 17 | get => _entryStringTable ?? (_entryStringTable = new ResourcesStringTable(false, "ProgramResources")); 18 | set => _entryStringTable = value ?? throw new ArgumentNullException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/BasicTaskProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester 5 | { 6 | public class BasicTaskProcessor : IDisposable 7 | { 8 | private static bool _isRunning; 9 | 10 | private readonly DisposableDependency _dependency; 11 | 12 | public BasicTaskProcessor(DisposableDependency dependency) 13 | { 14 | _dependency = dependency; 15 | } 16 | 17 | public void Run() 18 | { 19 | if (_isRunning) 20 | throw new SimplifySchedulerException("BasicTaskProcessor is running a duplicate!"); 21 | 22 | _isRunning = true; 23 | 24 | Trace.WriteLine("BasicTaskProcessor launched"); 25 | } 26 | 27 | public void Dispose() 28 | { 29 | Trace.WriteLine("BasicTaskProcessor disposed"); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/DisposableDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester 5 | { 6 | public class DisposableDependency : IDisposable 7 | { 8 | public void Dispose() 9 | { 10 | Trace.WriteLine("Disposable dependency disposed"); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/OneMinuteStepCrontabProcessor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester 5 | { 6 | public class OneMinuteStepCrontabProcessor 7 | { 8 | private static bool _isRunning; 9 | 10 | public void Run() 11 | { 12 | if (_isRunning) 13 | throw new SimplifySchedulerException("OneMinuteStepCrontabProcessor is running a duplicate!"); 14 | 15 | _isRunning = true; 16 | 17 | Trace.WriteLine("--- OneMinuteStepCrontabProcessor launched"); 18 | 19 | Thread.Sleep(3218); 20 | 21 | _isRunning = false; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/OneSecondStepProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace Simplify.Scheduler.IntegrationTester 6 | { 7 | public class OneSecondStepProcessor : IDisposable 8 | { 9 | private static bool _isRunning; 10 | 11 | public OneSecondStepProcessor(DisposableDependency dependency) 12 | { 13 | } 14 | 15 | public void Run() 16 | { 17 | if (_isRunning) 18 | throw new SimplifySchedulerException("EverySecondProcessor is running a duplicate!"); 19 | 20 | _isRunning = true; 21 | 22 | Trace.WriteLine("EverySecondProcessor launched"); 23 | 24 | Thread.Sleep(5120); 25 | 26 | _isRunning = false; 27 | } 28 | 29 | public void Dispose() 30 | { 31 | Trace.WriteLine("EverySecondProcessor disposed"); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/Program.cs: -------------------------------------------------------------------------------- 1 | using Simplify.DI; 2 | using Simplify.Scheduler.IntegrationTester.Setup; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester 5 | { 6 | internal class Program 7 | { 8 | private static void Main(string[] args) 9 | { 10 | // IOC container setup 11 | 12 | IocRegistrations.Register(); 13 | DIContainer.Current.Verify(); 14 | 15 | // Using scheduler 16 | 17 | using (var scheduler = new MultitaskScheduler()) 18 | { 19 | scheduler.AddJob(IocRegistrations.Configuration); 20 | scheduler.AddJob(IocRegistrations.Configuration, startupArgs: "Hello world!!!"); 21 | scheduler.AddJob(IocRegistrations.Configuration); 22 | scheduler.AddJob(IocRegistrations.Configuration, invokeMethodName: "Execute"); 23 | scheduler.AddBasicJob(); 24 | 25 | if (scheduler.Start(args)) 26 | return; 27 | } 28 | 29 | // Testing some processors without scheduler 30 | using (var scope = DIContainer.Current.BeginLifetimeScope()) 31 | scope.Resolver.Resolve().Run(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": 3 | { 4 | "Simplify.WindowsServices.IntegrationTests": 5 | { 6 | "commandName": "Project", 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/Setup/IocRegistrations.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Simplify.DI; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester.Setup 5 | { 6 | public static class IocRegistrations 7 | { 8 | public static IConfiguration Configuration { get; private set; } 9 | 10 | public static void Register() 11 | { 12 | RegisterConfiguration(); 13 | 14 | DIContainer.Current.Register(); 15 | 16 | DIContainer.Current.Register(); 17 | DIContainer.Current.Register(); 18 | DIContainer.Current.Register(); 19 | DIContainer.Current.Register(); 20 | DIContainer.Current.Register(); 21 | } 22 | 23 | private static void RegisterConfiguration() 24 | { 25 | Configuration = new ConfigurationBuilder() 26 | .AddJsonFile("appsettings.json", false) 27 | .Build(); 28 | 29 | DIContainer.Current.Register(p => Configuration, LifetimeType.Singleton); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/Simplify.Scheduler.IntegrationTester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.2 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Scheduler integration tester 7 | Licensed under LGPL 8 | 1.0 9 | Exe 10 | bin\Any CPU\$(Configuration)\ 11 | false 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | PreserveNewest 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/SimplifySchedulerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Scheduler.IntegrationTester 4 | { 5 | public class SimplifySchedulerException : Exception 6 | { 7 | public SimplifySchedulerException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/TwoParallelTasksProcessor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | 4 | namespace Simplify.Scheduler.IntegrationTester 5 | { 6 | public class TwoParallelTasksProcessor 7 | { 8 | public void Execute() 9 | { 10 | Trace.WriteLine("--- TwoParallelTasksProcessor launched"); 11 | 12 | Thread.Sleep(5000); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/TwoSecondStepProcessor.cs: -------------------------------------------------------------------------------- 1 | using Simplify.Scheduler.Jobs; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace Simplify.Scheduler.IntegrationTester 6 | { 7 | public class TwoSecondStepProcessor 8 | { 9 | private static bool _isRunning; 10 | 11 | public void Run(IJobArgs args) 12 | { 13 | if (_isRunning) 14 | throw new SimplifySchedulerException("TwoSecondStepProcessor is running a duplicate!"); 15 | 16 | _isRunning = true; 17 | 18 | Trace.WriteLine("TwoSecondStepProcessor launched"); 19 | Trace.WriteLine($"TwoSecondStepProcessor args startup args is: {args.StartupArgs}"); 20 | Trace.WriteLine($"TwoSecondStepProcessor args app name is: {args.AppName}"); 21 | 22 | Thread.Sleep(3670); 23 | 24 | _isRunning = false; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler.IntegrationTester/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "OneSecondStepProcessorSettings": 3 | { 4 | "ProcessingInterval": 1 5 | }, 6 | "TwoSecondStepProcessorSettings": 7 | { 8 | "ProcessingInterval": 2 9 | }, 10 | "OneMinuteStepCrontabProcessorSettings": 11 | { 12 | "CrontabExpression": "* * * * *" 13 | }, 14 | "TwoParallelTasksProcessorSettings": 15 | { 16 | "MaximumParallelTasksCount": 2 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/BasicScheduler.cs: -------------------------------------------------------------------------------- 1 | using Simplify.System; 2 | using System.Reflection; 3 | 4 | namespace Simplify.Scheduler 5 | { 6 | /// 7 | /// Provides scheduler which runs a non-timer job (for constant async operations, like TCP/IP server) and launches specified type instance once 8 | /// 9 | public class BasicScheduler : MultitaskScheduler 10 | where T : class 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// Name of the invoke method. 16 | /// The startup arguments. 17 | public BasicScheduler(string invokeMethodName = "Run", object startupArgs = null) 18 | { 19 | var assemblyInfo = new AssemblyInfo(Assembly.GetCallingAssembly()); 20 | AppName = assemblyInfo.Title; 21 | 22 | AddBasicJob(invokeMethodName, startupArgs); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/CommandLine/CommandLineAction.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.CommandLine 2 | { 3 | /// 4 | /// List of possible action from command line 5 | /// 6 | public enum CommandLineAction 7 | { 8 | /// 9 | /// The undefined action in command line 10 | /// 11 | UndefinedAction, 12 | 13 | /// 14 | /// The skip scheduler launch action from command line 15 | /// 16 | SkipScheduler 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/CommandLine/CommandLineProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Scheduler.CommandLine 4 | { 5 | /// 6 | /// Provides scheduler command line processor 7 | /// 8 | /// 9 | public class CommandLineProcessor : ICommandLineProcessor 10 | { 11 | /// 12 | /// Processes the command line arguments. 13 | /// 14 | /// The arguments. 15 | /// 16 | public virtual ProcessCommandLineResult ProcessCommandLineArguments(string[] args) 17 | { 18 | if (args == null || args.Length == 0) 19 | return ProcessCommandLineResult.NoArguments; 20 | 21 | var action = ParseCommandLineArguments(args); 22 | 23 | switch (action) 24 | { 25 | case CommandLineAction.SkipScheduler: 26 | return ProcessCommandLineResult.SkipSchedulerStart; 27 | } 28 | 29 | Console.WriteLine($"Undefined scheduler parameters: '{string.Concat(args)}'"); 30 | 31 | return ProcessCommandLineResult.UndefinedParameters; 32 | } 33 | 34 | /// 35 | /// Parses the command line arguments. 36 | /// 37 | /// The arguments. 38 | /// 39 | public virtual CommandLineAction ParseCommandLineArguments(string[] args) 40 | { 41 | if (args[0] == "skip") 42 | return CommandLineAction.SkipScheduler; 43 | 44 | return CommandLineAction.UndefinedAction; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/CommandLine/ICommandLineProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.CommandLine 2 | { 3 | /// 4 | /// Represent scheduler command line processor 5 | /// 6 | public interface ICommandLineProcessor 7 | { 8 | /// 9 | /// Processes the command line arguments. 10 | /// 11 | /// The arguments. 12 | /// 13 | ProcessCommandLineResult ProcessCommandLineArguments(string[] args); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/CommandLine/ProcessCommandLineResult.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.CommandLine 2 | { 3 | /// 4 | /// Result of command line process 5 | /// 6 | public enum ProcessCommandLineResult 7 | { 8 | /// 9 | /// The command line contains no arguments 10 | /// 11 | NoArguments, 12 | 13 | /// 14 | /// The command line contains undefined parameters 15 | /// 16 | UndefinedParameters, 17 | 18 | /// 19 | /// The command line action executed 20 | /// 21 | CommandLineActionExecuted, 22 | 23 | /// 24 | /// The skip scheduler start 25 | /// 26 | SkipSchedulerStart 27 | } 28 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/CrontabProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs.Crontab 2 | { 3 | /// 4 | /// Provides crontab processor factory 5 | /// 6 | public class CrontabProcessorFactory : ICrontabProcessorFactory 7 | { 8 | /// 9 | /// Creates a crontab processor. 10 | /// 11 | /// The crontab expression. 12 | /// 13 | public ICrontabProcessor Create(string crontabExpression) 14 | { 15 | return new CrontabProcessor(crontabExpression); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/CrontabSchedulerJobTask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Simplify.Scheduler.Jobs.Crontab 5 | { 6 | /// 7 | /// Provides crontab scheduler job task 8 | /// 9 | /// 10 | public class CrontabSchedulerJobTask : ICrontabSchedulerJobTask 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The identifier. 16 | /// The job. 17 | /// The task. 18 | public CrontabSchedulerJobTask(long id, ICrontabSchedulerJob job, Task task) 19 | { 20 | ID = id; 21 | 22 | Job = job ?? throw new ArgumentNullException(nameof(job)); 23 | Task = task ?? throw new ArgumentNullException(nameof(task)); 24 | } 25 | 26 | /// 27 | /// Gets the task identifier. 28 | /// 29 | public long ID { get; } 30 | 31 | /// 32 | /// Gets the job. 33 | /// 34 | public ICrontabSchedulerJob Job { get; } 35 | 36 | /// 37 | /// Gets the task. 38 | /// 39 | public Task Task { get; } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/ICrontabProcessor.cs: -------------------------------------------------------------------------------- 1 | using NCrontab; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Simplify.Scheduler.Jobs.Crontab 6 | { 7 | /// 8 | /// Represent multiple crontab schedules processor 9 | /// 10 | public interface ICrontabProcessor 11 | { 12 | /// 13 | /// Gets the schedules. 14 | /// 15 | /// 16 | /// The schedules. 17 | /// 18 | IList Schedules { get; } 19 | 20 | /// 21 | /// Gets the next occurrences. 22 | /// 23 | /// 24 | /// The next occurrences. 25 | /// 26 | IList NextOccurrences { get; } 27 | 28 | /// 29 | /// Calculates the next occurrences using current time as base time. 30 | /// 31 | void CalculateNextOccurrences(); 32 | 33 | /// 34 | /// Calculates the next occurrences. 35 | /// 36 | /// The base time. 37 | void CalculateNextOccurrences(DateTime baseTime); 38 | 39 | /// 40 | /// Determines whether the specified time is matching next occurrence. 41 | /// 42 | /// The time. 43 | /// 44 | bool IsMatching(DateTime time); 45 | 46 | /// 47 | /// Determines whether current time is matching next occurrence. 48 | /// 49 | /// 50 | bool IsMatching(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/ICrontabProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs.Crontab 2 | { 3 | /// 4 | /// Represent crontab processor factory 5 | /// 6 | public interface ICrontabProcessorFactory 7 | { 8 | /// 9 | /// Creates a crontab processor. 10 | /// 11 | /// The crontab expression. 12 | /// 13 | ICrontabProcessor Create(string crontabExpression); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/ICrontabSchedulerJob.cs: -------------------------------------------------------------------------------- 1 | using Simplify.Scheduler.Jobs.Settings; 2 | using System; 3 | using System.Threading; 4 | 5 | namespace Simplify.Scheduler.Jobs.Crontab 6 | { 7 | /// 8 | /// Represent crontab based scheduler job 9 | /// 10 | public interface ICrontabSchedulerJob : ISchedulerJob, IDisposable 11 | { 12 | /// 13 | /// Occurs on cron timer tick. 14 | /// 15 | event TimerCallback OnCronTimerTick; 16 | 17 | /// 18 | /// Occurs on interval timer tick. 19 | /// 20 | event TimerCallback OnStartWork; 21 | 22 | /// 23 | /// Gets the settings. 24 | /// 25 | /// 26 | /// The settings. 27 | /// 28 | ISchedulerJobSettings Settings { get; } 29 | 30 | /// 31 | /// Gets the crontab processor. 32 | /// 33 | /// 34 | /// The crontab processor. 35 | /// 36 | ICrontabProcessor CrontabProcessor { get; } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Crontab/ICrontabSchedulerJobTask.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Simplify.Scheduler.Jobs.Crontab 4 | { 5 | /// 6 | /// Represent crontab scheduler job task 7 | /// 8 | public interface ICrontabSchedulerJobTask 9 | { 10 | /// 11 | /// Gets the task identifier. 12 | /// 13 | long ID { get; } 14 | 15 | /// 16 | /// Gets the job. 17 | /// 18 | ICrontabSchedulerJob Job { get; } 19 | 20 | /// 21 | /// Gets the task. 22 | /// 23 | Task Task { get; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/IJobArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs 2 | { 3 | /// 4 | /// Represents an executing job args 5 | /// 6 | public interface IJobArgs 7 | { 8 | /// 9 | /// Gets the name of the current application. 10 | /// 11 | /// 12 | /// The name of the current application. 13 | /// 14 | string AppName { get; } 15 | 16 | /// 17 | /// Gets the job startup arguments. 18 | /// 19 | /// 20 | /// The job startup arguments. 21 | /// 22 | object StartupArgs { get; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/ISchedulerJob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Simplify.Scheduler.Jobs 5 | { 6 | /// 7 | /// Represent basic scheduler job 8 | /// 9 | public interface ISchedulerJob 10 | { 11 | /// 12 | /// Gets the type of the job class. 13 | /// 14 | /// 15 | /// The type of the job class. 16 | /// 17 | Type JobClassType { get; } 18 | 19 | /// 20 | /// Gets the invoke method information. 21 | /// 22 | /// 23 | /// The invoke method information. 24 | /// 25 | MethodInfo InvokeMethodInfo { get; } 26 | 27 | /// 28 | /// Gets the type of the invoke method parameter. 29 | /// 30 | /// 31 | /// The type of the invoke method parameter. 32 | /// 33 | InvokeMethodParameterType InvokeMethodParameterType { get; } 34 | 35 | /// 36 | /// Gets the job arguments. 37 | /// 38 | /// 39 | /// The job arguments. 40 | /// 41 | IJobArgs JobArgs { get; } 42 | 43 | /// 44 | /// Starts this job timer. 45 | /// 46 | void Start(); 47 | 48 | /// 49 | /// Stops and disposes job timer. 50 | /// 51 | void Stop(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/ISchedulerJobFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Simplify.Scheduler.Jobs.Crontab; 3 | 4 | namespace Simplify.Scheduler.Jobs 5 | { 6 | /// 7 | /// Represent scheduler jobs factory 8 | /// 9 | public interface ISchedulerJobFactory 10 | { 11 | /// 12 | /// Creates the basic scheduler job. 13 | /// 14 | /// 15 | /// Name of the invoke method. 16 | /// The startup arguments. 17 | /// 18 | ISchedulerJob CreateJob(string invokeMethodName, object startupArgs); 19 | 20 | /// 21 | /// Creates the crontab based scheduler job. 22 | /// 23 | /// 24 | /// The configuration. 25 | /// Name of the configuration section. 26 | /// Name of the invoke method. 27 | /// The startup arguments. 28 | /// 29 | ICrontabSchedulerJob CreateCrontabJob(IConfiguration configuration, 30 | string configurationSectionName, 31 | string invokeMethodName, 32 | object startupArgs); 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/InvokeMethodParameterType.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs 2 | { 3 | /// 4 | /// Provides job invoke method parameter type 5 | /// 6 | public enum InvokeMethodParameterType 7 | { 8 | /// 9 | /// The parameterless invoke method 10 | /// 11 | Parameterless, 12 | 13 | /// 14 | /// The invoke method with application name parameter 15 | /// 16 | AppName, 17 | 18 | /// 19 | /// The invoke method with job args parameter 20 | /// 21 | Args 22 | } 23 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/JobArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Scheduler.Jobs 4 | { 5 | /// 6 | /// Provides an executing job arguments 7 | /// 8 | public class JobArgs : IJobArgs 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// Name of the application. 14 | /// The startup arguments. 15 | public JobArgs(string appName, object startupArgs) 16 | { 17 | if (string.IsNullOrEmpty(appName)) throw new ArgumentException("Value cannot be null or empty.", nameof(appName)); 18 | 19 | AppName = appName; 20 | StartupArgs = startupArgs; 21 | } 22 | 23 | /// 24 | /// Gets the name of the current application. 25 | /// 26 | /// 27 | /// The name of the current application. 28 | /// 29 | public string AppName { get; } 30 | 31 | /// 32 | /// Gets the job startup arguments. 33 | /// 34 | /// 35 | /// The job startup arguments. 36 | /// 37 | public object StartupArgs { get; } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Settings/ISchedulerJobSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs.Settings 2 | { 3 | /// 4 | /// Represent scheduler job settings 5 | /// 6 | public interface ISchedulerJobSettings 7 | { 8 | /// 9 | /// Gets the crontab expression. 10 | /// 11 | /// 12 | /// The crontab expression. 13 | /// 14 | string CrontabExpression { get; } 15 | 16 | /// 17 | /// Gets the jobs processing interval (sec). 18 | /// 19 | /// 20 | /// The job processing interval (sec). 21 | /// 22 | int ProcessingInterval { get; } 23 | 24 | /// 25 | /// Gets a value indicating whether GC.Collect will be executed on on task finish. 26 | /// 27 | bool CleanupOnTaskFinish { get; } 28 | 29 | /// 30 | /// Gets the maximum allowed parallel tasks of this job. 31 | /// 32 | int MaximumParallelTasksCount { get; } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Jobs/Settings/SchedulerJobSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Scheduler.Jobs.Settings 2 | { 3 | /// 4 | /// Provides scheduler job settings 5 | /// 6 | public class SchedulerJobSettings : ISchedulerJobSettings 7 | { 8 | /// 9 | /// Initializes a new instance of the class. 10 | /// 11 | protected SchedulerJobSettings() 12 | { 13 | } 14 | 15 | /// 16 | /// Gets the crontab expression. 17 | /// 18 | /// 19 | /// The crontab expression. 20 | /// 21 | public string CrontabExpression { get; protected set; } 22 | 23 | /// 24 | /// Gets the scheduler processing interval (sec). 25 | /// 26 | /// 27 | /// The scheduler processing interval (sec). 28 | /// 29 | public int ProcessingInterval { get; protected set; } = 60; 30 | 31 | /// 32 | /// Gets a value indicating whether GC.Collect will be executed on on task finish. 33 | /// 34 | public bool CleanupOnTaskFinish { get; protected set; } = true; 35 | 36 | /// 37 | /// Gets the maximum allowed parallel tasks of this job. 38 | /// 39 | public int MaximumParallelTasksCount { get; protected set; } = 1; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/SchedulerExceptionArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Scheduler 4 | { 5 | /// 6 | /// Scheduler exception delegate 7 | /// 8 | /// The arguments. 9 | public delegate void SchedulerExceptionEventHandler(SchedulerExceptionArgs args); 10 | 11 | /// 12 | /// Provides scheduler exception event args 13 | /// 14 | public class SchedulerExceptionArgs 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// Name of the scheduling application. 20 | /// The exception. 21 | public SchedulerExceptionArgs(string appName, Exception exception) 22 | { 23 | AppName = appName; 24 | Exception = exception; 25 | } 26 | 27 | /// 28 | /// Gets the name of the application. 29 | /// 30 | /// 31 | /// The name of the application. 32 | /// 33 | public string AppName { get; } 34 | 35 | /// 36 | /// Gets the exception. 37 | /// 38 | /// 39 | /// The exception. 40 | /// 41 | public Exception Exception { get; } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/SchedulerInitializationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Scheduler 4 | { 5 | /// 6 | /// The exception class using for scheduler initialization exceptions 7 | /// 8 | [Serializable] 9 | public sealed class SchedulerInitializationException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public SchedulerInitializationException(string message) : base(message) { } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Scheduler/Simplify.Scheduler.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | Alexander Krylkov 5 | Simplify 6 | Scheduler framework with DI 7 | Licensed under LGPL 8 | 1.0-pre02 9 | https://github.com/i4004/Simplify/wiki/Simplify.Scheduler 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Scheduler 12 | GIT 13 | .NET Scheduler DI 14 | 15 | * Upgrade to Simplify.DI 3.0 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Scheduler.xml 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Simplify.Scheduler/SingleTaskScheduler.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Simplify.System; 3 | using System.Reflection; 4 | 5 | namespace Simplify.Scheduler 6 | { 7 | /// 8 | /// Provides class which periodically creates a class instance of specified type and launches it in separated thread 9 | /// 10 | /// 11 | public class SingleTaskScheduler : MultitaskScheduler 12 | where T : class 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The configuration. 18 | /// Name of the configuration section. 19 | /// Name of the invoke method. 20 | /// The startup arguments. 21 | public SingleTaskScheduler(IConfiguration configuration, 22 | string configurationSectionName = "JobSettings", 23 | string invokeMethodName = "Run", 24 | object startupArgs = null) 25 | { 26 | var assemblyInfo = new AssemblyInfo(Assembly.GetCallingAssembly()); 27 | AppName = assemblyInfo.Title; 28 | 29 | AddJob(configuration, configurationSectionName, invokeMethodName, startupArgs); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Simplify.String.Tests/Simplify.String.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.String unit tests 7 | Licensed under LGPL 8 | 1.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Simplify.String/Simplify.String.Sources.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Simplify.String.Sources 5 | $version$ 6 | Simplify.String.Sources 7 | Alexander Krylkov 8 | Alexander Krylkov 9 | https://github.com/i4004/Simplify/tree/master/src/Simplify.String 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | false 12 | String operations/validation functions 13 | String operations/validation functions 14 | 15 | + .NET Standard 2.0 support 16 | * ValidateEMail reimplemented via System.Net.Mail.MailAddress internal validator 17 | 18 | Licensed under LGPL 19 | en-US 20 | .NET 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Simplify.String/Simplify.String.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | String operations/validation functions 7 | Licensed under LGPL 8 | 1.2 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.String 12 | GIT 13 | .NET 14 | 15 | + .NET Standard 2.0 support 16 | * ValidateEMail reimplemented via System.Net.Mail.MailAddress internal validator 17 | 18 | bin\Any CPU\$(Configuration)\ 19 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.String.xml 20 | 21 | -------------------------------------------------------------------------------- /src/Simplify.System.Tests/AssemblyInfoTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Reflection; 3 | 4 | namespace Simplify.System.Tests 5 | { 6 | [TestFixture] 7 | public class AssemblyInfoTests 8 | { 9 | [Test] 10 | public void AssemblyInfo_GetCurrentAssemblyInfo_InformationIsCorrect() 11 | { 12 | var assemblyInfo = new AssemblyInfo(Assembly.GetAssembly((typeof(AssemblyInfoTests)))); 13 | 14 | Assert.AreEqual("Alexander Krylkov", assemblyInfo.CompanyName); 15 | Assert.AreEqual("Licensed under LGPL", assemblyInfo.Copyright); 16 | Assert.AreEqual("Simplify.System unit tests", assemblyInfo.Description); 17 | Assert.AreEqual("Simplify", assemblyInfo.ProductName); 18 | Assert.AreEqual("Simplify.System.Tests", assemblyInfo.Title); 19 | Assert.AreEqual("1.1.0.0", assemblyInfo.Version.ToString()); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Simplify.System.Tests/Simplify.System.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.System unit tests 7 | Licensed under LGPL 8 | 1.1 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Simplify.System/ApplicationEnvironment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.System 4 | { 5 | /// 6 | /// Provides application environment information 7 | /// 8 | public static class ApplicationEnvironment 9 | { 10 | /// 11 | /// The environment variable name 12 | /// 13 | public const string EnvironmentVariableName = "ASPNETCORE_ENVIRONMENT"; 14 | 15 | /// 16 | /// The default environment name 17 | /// 18 | public const string DefaultEnvironmentName = "Production"; 19 | 20 | private static string _name; 21 | 22 | /// 23 | /// Gets or sets the current environment name. 24 | /// 25 | /// 26 | /// The current environment name. 27 | /// 28 | public static string Name 29 | { 30 | get 31 | { 32 | if (!string.IsNullOrEmpty(_name)) 33 | return _name; 34 | 35 | _name = Environment.GetEnvironmentVariable(EnvironmentVariableName) ?? DefaultEnvironmentName; 36 | 37 | return _name; 38 | } 39 | set => _name = value; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Simplify.System/IAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.System 4 | { 5 | /// 6 | /// Assembly information interface 7 | /// 8 | public interface IAssemblyInfo 9 | { 10 | /// 11 | /// Gets the assembly version. 12 | /// 13 | Version Version { get; } 14 | 15 | /// 16 | /// Gets the assembly title. 17 | /// 18 | string Title { get; } 19 | 20 | /// 21 | /// Gets the product name of the assembly. 22 | /// 23 | string ProductName { get; } 24 | 25 | /// 26 | /// Gets the description of the assembly. 27 | /// 28 | string Description { get; } 29 | 30 | /// 31 | /// Gets the copyright information of the assembly. 32 | /// 33 | string Copyright { get; } 34 | 35 | /// 36 | /// Gets the company name of the assembly. 37 | /// 38 | string CompanyName { get; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Simplify.System/ITimeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.System 4 | { 5 | /// 6 | /// Represent time provider 7 | /// 8 | public interface ITimeProvider 9 | { 10 | /// 11 | /// Gets the current UTC time. 12 | /// 13 | /// 14 | /// The current UTC time. 15 | /// 16 | DateTime UtcNow { get; } 17 | 18 | /// 19 | /// Gets the current time. 20 | /// 21 | /// 22 | /// The current time. 23 | /// 24 | DateTime Now { get; } 25 | 26 | /// 27 | /// Gets the today date without time. 28 | /// 29 | /// 30 | /// The today date without time. 31 | /// 32 | DateTime Today { get; } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.System/Simplify.System.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Core classes for applications and libraries 7 | Licensed under LGPL 8 | 1.1 9 | https://github.com/i4004/Simplify/wiki/Simplify.System 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.System 12 | GIT 13 | .NET 14 | 15 | + ApplicationEnvironment class with environment name added 16 | - IHideObjectMembers removed 17 | 18 | bin\Any CPU\$(Configuration)\ 19 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.System.xml 20 | 21 | -------------------------------------------------------------------------------- /src/Simplify.System/SystemTimeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.System 4 | { 5 | /// 6 | /// System time provider, returns the actual DateTime.Now, DateTime.UtcNow, DateTime.Today data 7 | /// 8 | public sealed class SystemTimeProvider : ITimeProvider 9 | { 10 | /// 11 | /// Gets the current UTC time. 12 | /// 13 | /// 14 | /// The current UTC time. 15 | /// 16 | public DateTime UtcNow => DateTime.UtcNow; 17 | 18 | /// 19 | /// Gets the current time. 20 | /// 21 | /// 22 | /// The current time. 23 | /// 24 | public DateTime Now => DateTime.Now; 25 | 26 | /// 27 | /// Gets the today date without time. 28 | /// 29 | /// 30 | /// The today date without time. 31 | /// 32 | public DateTime Today => DateTime.Today; 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.System/TimeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.System 4 | { 5 | /// 6 | /// Provides Time ambient context 7 | /// 8 | public static class TimeProvider 9 | { 10 | private static ITimeProvider _currentInstance; 11 | 12 | /// 13 | /// Gets or sets the current time provider. 14 | /// 15 | /// 16 | /// The current time provider. 17 | /// 18 | /// value 19 | public static ITimeProvider Current 20 | { 21 | get => _currentInstance ?? (_currentInstance = new SystemTimeProvider()); 22 | set => _currentInstance = value ?? throw new ArgumentNullException(nameof(value)); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/Models/BaseTestModel.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Templates.Tests.Models 2 | { 3 | public class BaseTestModel 4 | { 5 | public int ID { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/Models/ChildTestModel.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Templates.Tests.Models 2 | { 3 | public class ChildTestModel : BaseTestModel 4 | { 5 | public string Name { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/Models/TestModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Templates.Tests.Models 4 | { 5 | public class TestModel 6 | { 7 | public int? ID { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string EMail { get; set; } 12 | 13 | public DateTime CreationTime { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TemplateTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.IO.Abstractions.TestingHelpers; 4 | 5 | using NUnit.Framework; 6 | 7 | namespace Simplify.Templates.Tests 8 | { 9 | [TestFixture] 10 | public class TemplateTests 11 | { 12 | [Test] 13 | public void Load_FromString_LoadedCorrectly() 14 | { 15 | var tpl = Template.FromString("test"); 16 | 17 | Assert.AreEqual("test", tpl.Get()); 18 | Assert.AreEqual("en", tpl.Language); 19 | } 20 | 21 | [Test] 22 | public void Load_FromFileSystem_LoadedCorrectly() 23 | { 24 | var file = Path.Combine("Templates", "Foo.en.tpl"); 25 | 26 | var files = new Dictionary { { file, "test" } }; 27 | 28 | var fs = new MockFileSystem(files); 29 | 30 | Template.FileSystem = fs; 31 | 32 | Assert.AreEqual("test", new Template(file).Get()); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/MasterTemplate.tpl: -------------------------------------------------------------------------------- 1 | 

{Title}

2 | 3 |
4 | {Items} 5 |
6 | {FromTemplateNull} 7 | {FromTemplateNotNull} -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/MasterTemplateResult.tpl: -------------------------------------------------------------------------------- 1 | 

Hello world!!!

2 | 3 |
4 |

Item1

5 | 6 |
7 | 15.5161718.16System.Object 8 | 15.5 9 | 16 10 | 17 11 | 18.16 12 | System.Object 13 | текст1 14 | test2 15 |
16 |

Item2

17 | 18 |
19 | 16.525530026.15System.Object 20 | 10.5 21 | 1 22 | 3 23 | 4.1233 24 | System.Object 25 | текст1 26 | test2 27 |
28 | 29 |
30 | 31 | test -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/TemplateTest.tpl: -------------------------------------------------------------------------------- 1 | 

{ItemTitle}

2 | 3 |
4 | {var1} 5 | {var2} 6 | {var3} 7 | {var4} 8 | {var5} 9 | {var6} 10 | {Localizable1} 11 | {Localizable2} 12 |
13 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/TemplateTest.tpl-en.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | test2 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/TemplateTest.tpl-ru.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Embedded/TemplateTestResult.tpl: -------------------------------------------------------------------------------- 1 | 

Item1

2 | 3 |
4 | 15.5161718.16System.Object 5 | 15.5 6 | 16 7 | 17 8 | 18.16 9 | System.Object 10 | текст1 11 | test2 12 |
13 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/MasterTemplate.tpl: -------------------------------------------------------------------------------- 1 | 

{Title}

2 | 3 |
4 | {Items} 5 |
6 | {FromTemplateNull} 7 | {FromTemplateNotNull} -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/MasterTemplateResult.tpl: -------------------------------------------------------------------------------- 1 | 

Hello world!!!

2 | 3 |
4 |

Item1

5 | 6 |
7 | 15.5161718.16System.Object 8 | 15.5 9 | 16 10 | 17 11 | 18.16 12 | System.Object 13 | текст1 14 | test2 15 |
16 |

Item2

17 | 18 |
19 | 16.525530026.15System.Object 20 | 10.5 21 | 1 22 | 3 23 | 4.1233 24 | System.Object 25 | текст1 26 | test2 27 |
28 | 29 |
30 | 31 | test -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/TemplateTest.tpl: -------------------------------------------------------------------------------- 1 | 

{ItemTitle}

2 | 3 |
4 | {var1} 5 | {var2} 6 | {var3} 7 | {var4} 8 | {var5} 9 | {var6} 10 | {Localizable1} 11 | {Localizable2} 12 |
13 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/TemplateTest.tpl.en.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | test2 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/TemplateTest.tpl.ru.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Simplify.Templates.Tests/TestData/Local/TemplateTestResult.tpl: -------------------------------------------------------------------------------- 1 | 

Item1

2 | 3 |
4 | 15.5161718.16System.Object 5 | 15.5 6 | 16 7 | 17 8 | 18.16 9 | System.Object 10 | текст1 11 | test2 12 |
13 | -------------------------------------------------------------------------------- /src/Simplify.Templates/IModelSetter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace Simplify.Templates 5 | { 6 | /// 7 | /// Represent model setter to template, sets all objects properties to template 8 | /// 9 | /// Model type 10 | public interface IModelSetter 11 | where T : class 12 | { 13 | /// 14 | /// Customizes specified property data set to template, for example, you can set custom expression to convert DateTime values 15 | /// 16 | /// The type of the data. 17 | /// The member expression. 18 | /// The data expression. 19 | /// 20 | IModelSetter With(Expression> memberExpression, Func dataExpression); 21 | 22 | /// 23 | /// Sets the specified object (model) properties into template (replace variables names like Model.MyPropertyName with respective object (model) properties values). 24 | /// 25 | ITemplate Set(); 26 | 27 | /// 28 | /// Adds specified object (model) properties into template (adds to variables names like Model.MyPropertyName with respective object (model) properties values), values will be replaced on template Get or GetAndRoll methods call. 29 | /// 30 | ITemplate Add(); 31 | } 32 | } -------------------------------------------------------------------------------- /src/Simplify.Templates/ModelSetterBase.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Templates 2 | { 3 | /// 4 | /// Provides ModelSetter base class 5 | /// 6 | public abstract class ModelSetterBase 7 | { 8 | /// 9 | /// The model prefix separator 10 | /// 11 | public static string ModelPrefixSeparator = "."; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The template. 17 | /// The model prefix. 18 | protected ModelSetterBase(ITemplate template, string modelPrefix = null) 19 | { 20 | ModelPrefix = modelPrefix; 21 | Template = template; 22 | } 23 | 24 | /// 25 | /// Gets the template. 26 | /// 27 | /// 28 | /// The template. 29 | /// 30 | public ITemplate Template { get; } 31 | 32 | /// 33 | /// The model prefix 34 | /// 35 | protected string ModelPrefix { get; } 36 | 37 | /// 38 | /// Formats the name of the variable to replace respecting model prefix. 39 | /// 40 | /// Name of the variable. 41 | /// 42 | protected string FormatModelVariableName(string variableName) 43 | { 44 | return ModelPrefix != null ? ModelPrefix + ModelPrefixSeparator + variableName : variableName; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Simplify.Templates/Simplify.Templates.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | Text templates engine 7 | Licensed under LGPL 8 | 1.5.1 9 | https://github.com/i4004/Simplify/wiki/Simplify.Templates 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Templates 12 | GIT 13 | .NET Templates 14 | 15 | + Upgrade to System.IO.Abstractions 6.0.11 16 | 17 | bin\Any CPU\$(Configuration)\ 18 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Templates.xml 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Simplify.Templates/TemplateException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.Templates 4 | { 5 | /// 6 | /// The exception class using for Template exceptions 7 | /// 8 | [Serializable] 9 | public sealed class TemplateException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public TemplateException(string message) : base(message) { } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Templates/TemplateModelExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.Templates 2 | { 3 | /// 4 | /// Template model extensions 5 | /// 6 | public static class TemplateModelExtensions 7 | { 8 | /// 9 | /// Selects the object (model) to get a properties values from and set them to template. 10 | /// 11 | /// The model type 12 | /// The template. 13 | /// The model. 14 | /// The model prefix (for example 'Model', it will be used like 'Model.YourVariableName'). 15 | /// 16 | public static IModelSetter Model(this ITemplate template, T model, string modelPrefix = null) 17 | where T : class 18 | { 19 | return new ModelSetter(template, model, modelPrefix); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Simplify.Windows.Forms/Controls/TopmostProgressBar.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace Simplify.Windows.Forms.Controls 4 | { 5 | /// 6 | /// Implements the topmost progress bar control 7 | /// 8 | public partial class TopmostProgressBar : Form 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public TopmostProgressBar() 14 | { 15 | InitializeComponent(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Simplify.Windows.Forms/MessageBox.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | using Simplify.Resources; 3 | 4 | namespace Simplify.Windows.Forms 5 | { 6 | /// 7 | /// Provides easy message box showing for windows desktop applications 8 | /// 9 | public class MessageBox 10 | { 11 | /// 12 | /// Shows the message box 13 | /// 14 | /// Text of the message 15 | /// Icon in message box 16 | /// Buttons in message box 17 | public static DialogResult ShowMessageBox(string text, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxButtons buttons = MessageBoxButtons.OK) 18 | { 19 | return System.Windows.Forms.MessageBox.Show(text, Application.ProductName, buttons, icon); 20 | } 21 | 22 | /// 23 | ///Shows the message box with text from string table and selected icon 24 | /// 25 | /// Text of the message 26 | /// Icon in message box 27 | /// Buttons in message box 28 | public static DialogResult ShowStMessageBox(string stringTableRecordName, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxButtons buttons = MessageBoxButtons.OK) 29 | { 30 | return ShowMessageBox(StringTable.Entry[stringTableRecordName], icon, buttons); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Simplify.Windows.Forms/Simplify.Windows.Forms.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net45 4 | Alexander Krylkov 5 | Simplify 6 | System.Windows.Forms additional controls 7 | Licensed under LGPL 8 | 1.0.1 9 | https://github.com/i4004/Simplify 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Pipelines 12 | GIT 13 | .NET pipelines 14 | 15 | 16 | bin\Any CPU\$(Configuration)\ 17 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Windows.Forms.xml 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/BasicTaskProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester 5 | { 6 | public class BasicTaskProcessor : IDisposable 7 | { 8 | private static bool _isRunning; 9 | 10 | private readonly DisposableDependency _dependency; 11 | 12 | public BasicTaskProcessor(DisposableDependency dependency) 13 | { 14 | _dependency = dependency; 15 | } 16 | 17 | public void Run() 18 | { 19 | if (_isRunning) 20 | throw new SimplifyWindowsServicesException("BasicTaskProcessor is running a duplicate!"); 21 | 22 | _isRunning = true; 23 | 24 | Trace.WriteLine("BasicTaskProcessor launched"); 25 | } 26 | 27 | public void Dispose() 28 | { 29 | Trace.WriteLine("BasicTaskProcessor disposed"); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/DisposableDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester 5 | { 6 | public class DisposableDependency : IDisposable 7 | { 8 | public void Dispose() 9 | { 10 | Trace.WriteLine("Disposable dependency disposed"); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/OneMinuteStepCrontabProcessor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester 5 | { 6 | public class OneMinuteStepCrontabProcessor 7 | { 8 | private static bool _isRunning; 9 | 10 | public void Run() 11 | { 12 | if (_isRunning) 13 | throw new SimplifyWindowsServicesException("OneMinuteStepCrontabProcessor is running a duplicate!"); 14 | 15 | _isRunning = true; 16 | 17 | Trace.WriteLine("--- OneMinuteStepCrontabProcessor launched"); 18 | 19 | Thread.Sleep(3218); 20 | 21 | _isRunning = false; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/OneSecondStepProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace Simplify.WindowsServices.IntegrationTester 6 | { 7 | public class OneSecondStepProcessor : IDisposable 8 | { 9 | private static bool _isRunning; 10 | 11 | public OneSecondStepProcessor(DisposableDependency dependency) 12 | { 13 | } 14 | 15 | public void Run() 16 | { 17 | if (_isRunning) 18 | throw new SimplifyWindowsServicesException("EverySecondProcessor is running a duplicate!"); 19 | 20 | _isRunning = true; 21 | 22 | Trace.WriteLine("EverySecondProcessor launched"); 23 | 24 | Thread.Sleep(5120); 25 | 26 | _isRunning = false; 27 | } 28 | 29 | public void Dispose() 30 | { 31 | Trace.WriteLine("EverySecondProcessor disposed"); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/Program.cs: -------------------------------------------------------------------------------- 1 | using Simplify.DI; 2 | using Simplify.WindowsServices.IntegrationTester.Setup; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester 5 | { 6 | internal class Program 7 | { 8 | private static void Main(string[] args) 9 | { 10 | #if DEBUG 11 | // Run debugger 12 | global::System.Diagnostics.Debugger.Launch(); 13 | #endif 14 | 15 | IocRegistrations.Register(); 16 | DIContainer.Current.Verify(); 17 | 18 | var handler = new MultitaskServiceHandler(); 19 | 20 | handler.AddJob("OneSecondStepProcessor"); 21 | handler.AddJob(IocRegistrations.Configuration, startupArgs: "Hello world!!!"); 22 | handler.AddJob(IocRegistrations.Configuration, "OneMinuteStepCrontabProcessor", automaticallyRegisterUserType: true); 23 | handler.AddJob(invokeMethodName: "Execute"); 24 | handler.AddBasicJob(); 25 | 26 | if (handler.Start(args)) 27 | return; 28 | 29 | using (var scope = DIContainer.Current.BeginLifetimeScope()) 30 | scope.Resolver.Resolve().Run(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Simplify.WindowsServices.IntegrationTests": { 4 | "commandName": "Project", 5 | "commandLineArgs": "console" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/ServiceInstaller.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Simplify.WindowsServices.IntegrationTester 4 | { 5 | [RunInstaller(true)] 6 | public class ServiceInstaller : ServiceInstallerBase 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/Setup/IocRegistrations.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Simplify.DI; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester.Setup 5 | { 6 | public static class IocRegistrations 7 | { 8 | public static IConfiguration Configuration { get; private set; } 9 | 10 | public static void Register() 11 | { 12 | RegisterConfiguration(); 13 | 14 | DIContainer.Current.Register(); 15 | 16 | DIContainer.Current.Register(); 17 | DIContainer.Current.Register(); 18 | DIContainer.Current.Register(); 19 | DIContainer.Current.Register(); 20 | } 21 | 22 | private static void RegisterConfiguration() 23 | { 24 | Configuration = new ConfigurationBuilder() 25 | .AddJsonFile("appsettings.json", false) 26 | .Build(); 27 | 28 | DIContainer.Current.Register(p => Configuration, LifetimeType.Singleton); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/Simplify.WindowsServices.IntegrationTester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.WindowsServices integration tester service 7 | Licensed under LGPL 8 | 0.5 9 | Exe 10 | bin\Any CPU\$(Configuration)\ 11 | false 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | PreserveNewest 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/SimplifyWindowsServicesException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.WindowsServices.IntegrationTester 4 | { 5 | public class SimplifyWindowsServicesException : Exception 6 | { 7 | public SimplifyWindowsServicesException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/TwoParallelTasksProcessor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | 4 | namespace Simplify.WindowsServices.IntegrationTester 5 | { 6 | public class TwoParallelTasksProcessor 7 | { 8 | public void Execute() 9 | { 10 | Trace.WriteLine("--- TwoParallelTasksProcessor launched"); 11 | 12 | Thread.Sleep(5000); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/TwoSecondStepProcessor.cs: -------------------------------------------------------------------------------- 1 | using Simplify.WindowsServices.Jobs; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace Simplify.WindowsServices.IntegrationTester 6 | { 7 | public class TwoSecondStepProcessor 8 | { 9 | private static bool _isRunning; 10 | 11 | public void Run(IJobArgs args) 12 | { 13 | if (_isRunning) 14 | throw new SimplifyWindowsServicesException("TwoSecondStepProcessor is running a duplicate!"); 15 | 16 | _isRunning = true; 17 | 18 | Trace.WriteLine("TwoSecondStepProcessor launched"); 19 | Trace.WriteLine($"TwoSecondStepProcessor args startup args is: {args.StartupArgs}"); 20 | Trace.WriteLine($"TwoSecondStepProcessor args service name is: {args.ServiceName}"); 21 | 22 | Thread.Sleep(3670); 23 | 24 | _isRunning = false; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices.IntegrationTester/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TwoSecondStepProcessorSettings": 3 | { 4 | "ProcessingInterval": 1 5 | }, 6 | "OneMinuteStepCrontabProcessorSettings": 7 | { 8 | "CrontabExpression": "* * * * *" 9 | } 10 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/BasicServiceHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Simplify.System; 3 | 4 | namespace Simplify.WindowsServices 5 | { 6 | // ReSharper disable once CommentTypo 7 | 8 | /// 9 | /// Provides class which runs as non-timer windows service (for constant async operations, like TCP/IP server) and launches specified type instance once 10 | /// 11 | public class BasicServiceHandler : MultitaskServiceHandler 12 | where T : class 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// if set to true then user type T will be registered in DIContainer with transient lifetime. 18 | /// Name of the invoke method. 19 | /// The startup arguments. 20 | public BasicServiceHandler(bool automaticallyRegisterUserType = false, 21 | string invokeMethodName = "Run", 22 | object startupArgs = null) 23 | { 24 | var assemblyInfo = new AssemblyInfo(Assembly.GetCallingAssembly()); 25 | ServiceName = assemblyInfo.Title; 26 | 27 | AddBasicJob(automaticallyRegisterUserType, invokeMethodName, startupArgs); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/CommandLine/CommandLineAction.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.CommandLine 2 | { 3 | /// 4 | /// List of possible action from command line 5 | /// 6 | public enum CommandLineAction 7 | { 8 | /// 9 | /// The undefined action in command line 10 | /// 11 | UndefinedAction, 12 | 13 | /// 14 | /// The install service action from command line 15 | /// 16 | InstallService, 17 | 18 | /// 19 | /// The uninstall service action from command line 20 | /// 21 | UninstallService, 22 | 23 | /// 24 | /// The run as console application action from command line 25 | /// 26 | RunAsConsole 27 | } 28 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/CommandLine/ICommandLineProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.CommandLine 2 | { 3 | /// 4 | /// Represent windows-service command line processor 5 | /// 6 | public interface ICommandLineProcessor 7 | { 8 | /// 9 | /// Processes the command line arguments. 10 | /// 11 | /// The arguments. 12 | /// 13 | ProcessCommandLineResult ProcessCommandLineArguments(string[] args); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/CommandLine/IInstallationController.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.CommandLine 2 | { 3 | /// 4 | /// Represent windows-service installation controller 5 | /// 6 | public interface IInstallationController 7 | { 8 | /// 9 | /// Installs the service. 10 | /// 11 | void InstallService(); 12 | 13 | /// 14 | /// Uninstalls the service. 15 | /// 16 | void UninstallService(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/CommandLine/InstallationController.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration.Install; 2 | using System.Reflection; 3 | 4 | namespace Simplify.WindowsServices.CommandLine 5 | { 6 | /// 7 | /// Provides windows-service installation controller 8 | /// 9 | /// 10 | public class InstallationController : IInstallationController 11 | { 12 | /// 13 | /// Installs the service. 14 | /// 15 | public virtual void InstallService() 16 | { 17 | ManagedInstallerClass.InstallHelper(new[] { "/LogFile=", "/LogToConsole=true", GetEntryAssemblyLocation() }); 18 | } 19 | 20 | /// 21 | /// Uninstalls the service. 22 | /// 23 | public virtual void UninstallService() 24 | { 25 | ManagedInstallerClass.InstallHelper(new[] { "/u", "/LogFile=", "/LogToConsole=true", GetEntryAssemblyLocation() }); 26 | } 27 | 28 | /// 29 | /// Gets the entry assembly location. 30 | /// 31 | /// 32 | protected string GetEntryAssemblyLocation() 33 | { 34 | return Assembly.GetEntryAssembly().Location; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/CommandLine/ProcessCommandLineResult.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.CommandLine 2 | { 3 | /// 4 | /// Result of command line process 5 | /// 6 | public enum ProcessCommandLineResult 7 | { 8 | /// 9 | /// The command line contains no arguments 10 | /// 11 | NoArguments, 12 | 13 | /// 14 | /// The command line contains undefined parameters 15 | /// 16 | UndefinedParameters, 17 | 18 | /// 19 | /// The command line action executed 20 | /// 21 | CommandLineActionExecuted, 22 | 23 | /// 24 | /// The skip service start 25 | /// 26 | SkipServiceStart 27 | } 28 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Crontab/CrontabProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs.Crontab 2 | { 3 | /// 4 | /// Provides crontab processor factory 5 | /// 6 | public class CrontabProcessorFactory : ICrontabProcessorFactory 7 | { 8 | /// 9 | /// Creates a crontab processor. 10 | /// 11 | /// The crontab expression. 12 | /// 13 | public ICrontabProcessor Create(string crontabExpression) 14 | { 15 | return new CrontabProcessor(crontabExpression); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Crontab/CrontabServiceJobTask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Simplify.WindowsServices.Jobs.Crontab 5 | { 6 | /// 7 | /// Provides crontab service job task 8 | /// 9 | /// 10 | public class CrontabServiceJobTask : ICrontabServiceJobTask 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The identifier. 16 | /// The job. 17 | /// The task. 18 | public CrontabServiceJobTask(long id, ICrontabServiceJob job, Task task) 19 | { 20 | ID = id; 21 | 22 | Job = job ?? throw new ArgumentNullException(nameof(job)); 23 | Task = task ?? throw new ArgumentNullException(nameof(task)); 24 | } 25 | 26 | /// 27 | /// Gets the task identifier. 28 | /// 29 | public long ID { get; } 30 | 31 | /// 32 | /// Gets the job. 33 | /// 34 | public ICrontabServiceJob Job { get; } 35 | 36 | /// 37 | /// Gets the task. 38 | /// 39 | public Task Task { get; } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Crontab/ICrontabProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs.Crontab 2 | { 3 | /// 4 | /// Represent crontab processor factory 5 | /// 6 | public interface ICrontabProcessorFactory 7 | { 8 | /// 9 | /// Creates a crontab processor. 10 | /// 11 | /// The crontab expression. 12 | /// 13 | ICrontabProcessor Create(string crontabExpression); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Crontab/ICrontabServiceJob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Simplify.WindowsServices.Jobs.Settings; 4 | 5 | namespace Simplify.WindowsServices.Jobs.Crontab 6 | { 7 | /// 8 | /// Represent crontab service job 9 | /// 10 | public interface ICrontabServiceJob : IServiceJob, IDisposable 11 | { 12 | /// 13 | /// Occurs on cron timer tick. 14 | /// 15 | event TimerCallback OnCronTimerTick; 16 | 17 | /// 18 | /// Occurs on interval timer tick. 19 | /// 20 | event TimerCallback OnStartWork; 21 | 22 | /// 23 | /// Gets the settings. 24 | /// 25 | /// 26 | /// The settings. 27 | /// 28 | IServiceJobSettings Settings { get; } 29 | 30 | /// 31 | /// Gets the crontab processor. 32 | /// 33 | /// 34 | /// The crontab processor. 35 | /// 36 | ICrontabProcessor CrontabProcessor { get; } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Crontab/ICrontabServiceJobTask.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Simplify.WindowsServices.Jobs.Crontab 4 | { 5 | /// 6 | /// Represent crontab service job task 7 | /// 8 | public interface ICrontabServiceJobTask 9 | { 10 | /// 11 | /// Gets the task identifier. 12 | /// 13 | long ID { get; } 14 | 15 | /// 16 | /// Gets the job. 17 | /// 18 | ICrontabServiceJob Job { get; } 19 | 20 | /// 21 | /// Gets the task. 22 | /// 23 | Task Task { get; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/IJobArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs 2 | { 3 | /// 4 | /// Represents an executing job args 5 | /// 6 | public interface IJobArgs 7 | { 8 | /// 9 | /// Gets the name of the current service. 10 | /// 11 | /// 12 | /// The name of the current service. 13 | /// 14 | string ServiceName { get; } 15 | 16 | /// 17 | /// Gets the job startup arguments. 18 | /// 19 | /// 20 | /// The job startup arguments. 21 | /// 22 | object StartupArgs { get; } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/IServiceJob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Simplify.WindowsServices.Jobs 5 | { 6 | /// 7 | /// Represent basic service job 8 | /// 9 | public interface IServiceJob 10 | { 11 | /// 12 | /// Gets the type of the job class. 13 | /// 14 | /// 15 | /// The type of the job class. 16 | /// 17 | Type JobClassType { get; } 18 | 19 | /// 20 | /// Gets the invoke method information. 21 | /// 22 | /// 23 | /// The invoke method information. 24 | /// 25 | MethodInfo InvokeMethodInfo { get; } 26 | 27 | /// 28 | /// Gets the type of the invoke method parameter. 29 | /// 30 | /// 31 | /// The type of the invoke method parameter. 32 | /// 33 | InvokeMethodParameterType InvokeMethodParameterType { get; } 34 | 35 | /// 36 | /// Gets the job arguments. 37 | /// 38 | /// 39 | /// The job arguments. 40 | /// 41 | IJobArgs JobArgs { get; } 42 | 43 | /// 44 | /// Starts this job timer. 45 | /// 46 | void Start(); 47 | 48 | /// 49 | /// Stops and disposes job timer. 50 | /// 51 | void Stop(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/InvokeMethodParameterType.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs 2 | { 3 | /// 4 | /// Provides a job invoke method parameter type 5 | /// 6 | public enum InvokeMethodParameterType 7 | { 8 | /// 9 | /// The parameterless invoke method 10 | /// 11 | Parameterless, 12 | 13 | /// 14 | /// The invoke method with service name parameter 15 | /// 16 | ServiceName, 17 | 18 | /// 19 | /// The invoke method with job args parameter 20 | /// 21 | Args 22 | } 23 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/JobArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.WindowsServices.Jobs 4 | { 5 | /// 6 | /// Provides an executing job arguments 7 | /// 8 | public class JobArgs : IJobArgs 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// Name of the service. 14 | /// The startup arguments. 15 | public JobArgs(string serviceName, object startupArgs) 16 | { 17 | if (string.IsNullOrEmpty(serviceName)) throw new ArgumentException("Value cannot be null or empty.", nameof(serviceName)); 18 | 19 | ServiceName = serviceName; 20 | StartupArgs = startupArgs; 21 | } 22 | 23 | /// 24 | /// Gets the name of the current service. 25 | /// 26 | /// 27 | /// The name of the current service. 28 | /// 29 | public string ServiceName { get; } 30 | 31 | /// 32 | /// Gets the job startup arguments. 33 | /// 34 | /// 35 | /// The job startup arguments. 36 | /// 37 | public object StartupArgs { get; } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Settings/IServiceJobSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs.Settings 2 | { 3 | /// 4 | /// Represent service job settings 5 | /// 6 | public interface IServiceJobSettings 7 | { 8 | /// 9 | /// Gets the crontab expression. 10 | /// 11 | /// 12 | /// The crontab expression. 13 | /// 14 | string CrontabExpression { get; } 15 | 16 | /// 17 | /// Gets the service processing interval (sec). 18 | /// 19 | /// 20 | /// The service processing interval (sec). 21 | /// 22 | int ProcessingInterval { get; } 23 | 24 | /// 25 | /// Gets a value indicating whether GC.Collect will be executed on on task finish. 26 | /// 27 | bool CleanupOnTaskFinish { get; } 28 | 29 | /// 30 | /// Gets the maximum allowed parallel tasks of this job. 31 | /// 32 | int MaximumParallelTasksCount { get; } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/Jobs/Settings/ServiceJobSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Simplify.WindowsServices.Jobs.Settings 2 | { 3 | /// 4 | /// Provides service job settings 5 | /// 6 | public class ServiceJobSettings : IServiceJobSettings 7 | { 8 | /// 9 | /// Initializes a new instance of the class. 10 | /// 11 | protected ServiceJobSettings() 12 | { 13 | } 14 | 15 | /// 16 | /// Gets the crontab expression. 17 | /// 18 | /// 19 | /// The crontab expression. 20 | /// 21 | public string CrontabExpression { get; protected set; } 22 | 23 | /// 24 | /// Gets the service processing interval (sec). 25 | /// 26 | /// 27 | /// The service processing interval (sec). 28 | /// 29 | public int ProcessingInterval { get; protected set; } = 60; 30 | 31 | /// 32 | /// Gets a value indicating whether GC.Collect will be executed on on task finish. 33 | /// 34 | public bool CleanupOnTaskFinish { get; protected set; } = true; 35 | 36 | /// 37 | /// Gets the maximum allowed parallel tasks of this job. 38 | /// 39 | public int MaximumParallelTasksCount { get; protected set; } = 1; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/ServiceExceptionArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.WindowsServices 4 | { 5 | /// 6 | /// Service exception delegate 7 | /// 8 | /// The arguments. 9 | public delegate void ServiceExceptionEventHandler(ServiceExceptionArgs args); 10 | 11 | /// 12 | /// Provides service exception event args 13 | /// 14 | public class ServiceExceptionArgs 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// Name of the service. 20 | /// The exception. 21 | public ServiceExceptionArgs(string serviceName, Exception exception) 22 | { 23 | ServiceName = serviceName; 24 | Exception = exception; 25 | } 26 | 27 | /// 28 | /// Gets the name of the service. 29 | /// 30 | /// 31 | /// The name of the service. 32 | /// 33 | public string ServiceName { get; } 34 | 35 | /// 36 | /// Gets the exception. 37 | /// 38 | /// 39 | /// The exception. 40 | /// 41 | public Exception Exception { get; } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Simplify.WindowsServices/ServiceInitializationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Simplify.WindowsServices 4 | { 5 | /// 6 | /// The exception class using for ApplicationHelper.Service services exceptions 7 | /// 8 | [Serializable] 9 | public sealed class ServiceInitializationException : Exception 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The message that describes the error. 15 | public ServiceInitializationException(string message) : base(message) { } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Simplify.Xml.Tests/Simplify.Xml.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Alexander Krylkov 5 | Simplify 6 | Simplify.Xml unit tests 7 | Licensed under LGPL 8 | 1.2 9 | bin\Any CPU\$(Configuration)\ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Simplify.Xml.Tests/TestData/XmlWithNamespaces.xml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 34.5 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Simplify.Xml.Tests/TestData/XmlWithoutNamespaces..xml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 34.5 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Simplify.Xml.Tests/XmlExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using NUnit.Framework; 3 | using Simplify.Templates; 4 | 5 | namespace Simplify.Xml.Tests 6 | { 7 | [TestFixture] 8 | public class XmlExtensionsTests 9 | { 10 | private const string InputString = "data"; 11 | private const string ExpectedOuter = "data"; 12 | private const string ExpectedInner = "data"; 13 | 14 | [Test] 15 | public void GetOuterXml_XElement_GettingCorrectly() 16 | { 17 | // Assign 18 | var element = XElement.Parse(InputString); 19 | 20 | // Act & Assert 21 | Assert.AreEqual(ExpectedOuter, element.OuterXml()); 22 | } 23 | 24 | [Test] 25 | public void GetInnerXml_XElement_GettingCorrectly() 26 | { 27 | // Assign 28 | var element = XElement.Parse(InputString); 29 | 30 | // Act & Assert 31 | Assert.AreEqual(ExpectedInner, element.InnerXml()); 32 | } 33 | 34 | [Test] 35 | public void RemoveAllXmlNamespaces_XmlStringWithBNamespaces_XmlStringWithoutNamespaces() 36 | { 37 | // Assign 38 | var str = Template.FromManifest("TestData.XmlWithNamespaces.xml").Get(); 39 | 40 | // Act & Assert 41 | Assert.AreEqual(Template.FromManifest("TestData.XmlWithoutNamespaces..xml").Get(), str.RemoveAllXmlNamespaces()); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Simplify.Xml/Simplify.Xml.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net452 4 | Alexander Krylkov 5 | Simplify 6 | XML extensions 7 | Licensed under LGPL 8 | 1.1 9 | https://github.com/i4004/Simplify/wiki/Simplify.Xml 10 | https://raw.githubusercontent.com/i4004/Simplify/master/Images/Icon.png 11 | https://github.com/i4004/Simplify/tree/master/src/Simplify.Xml 12 | GIT 13 | .NET XML 14 | 15 | * OuterXml/InnerXml for XNode elements instead of just XElements 16 | + RemoveAllXmlNamespaces added 17 | 18 | bin\Any CPU\$(Configuration)\ 19 | bin\Any CPU\$(Configuration)\$(TargetFramework)\Simplify.Xml.xml 20 | 21 | 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------