The foundational core of the PowerCSharp ecosystem, providing centralized interfaces, models, and base functionality for all PowerCSharp packages. This package has been refactored to provide a clean, dependency-free foundation with improved architectural separation.
- Package ID:
PowerCSharp.Core - Version: 0.3.0
- Target Frameworks: .NET 8.0, .NET Standard 2.0
- Dependencies: None (dependency-free)
PowerCSharp.Core serves as the architectural foundation for the entire PowerCSharp ecosystem:
All interfaces are centralized in PowerCSharp.Core to maintain proper architectural separation:
- PowerCSharp.Core.Interfaces.Extensions.Configuration - Configuration-related interfaces
- PowerCSharp.Core.Interfaces.Extensions.Linq - LINQ and dynamic query interfaces
- PowerCSharp.Core.Interfaces.Models - Model classes (reserved for future use)
- Single source of truth for contracts and abstractions
- Consistent namespace organization across packages
- Easy dependency management across the ecosystem
- Clear architectural boundaries between packages
dotnet add package PowerCSharp.CoreNamespace: PowerCSharp.Core.Interfaces.Extensions.Configuration
Represents the interface for application options.
public interface IAppOptions
{
string ConfigSectionPath { get; }
}Usage Example:
using PowerCSharp.Core.Interfaces.Extensions.Configuration;
public class MyAppOptions : IAppOptions
{
public string ConfigSectionPath => "MyApp";
public string ApiKey { get; set; }
public int Timeout { get; set; }
}Namespace: PowerCSharp.Core.Interfaces.Extensions.Linq
Implement a Service Provider for dynamically filtering of the type T using Dynamic Expressions.
public interface IDynamicFilterProvider<T>
{
void SetFilter(Func<T, bool> filter);
Func<T, bool> GetFilter();
}Namespace: PowerCSharp.Core.Interfaces.Extensions.Linq
Implement a Service Provider for dynamically ordering of the type T using Dynamic Expressions.
public interface IDynamicOrderProvider<T>
{
void SetOrderDelegates(List<(Func<T, object>, bool)> delegates);
List<(Func<T, object>, bool)> GetOrderDelegates();
}Usage Example:
using PowerCSharp.Core.Interfaces.Extensions.Linq;
// Create a dynamic filter provider
var filterProvider = new DynamicFilterProvider<Person>();
filterProvider.SetFilter(person => person.Age > 18 && person.Name.Contains("John"));
// Create a dynamic order provider
var orderProvider = new DynamicOrderProvider<Person>();
orderProvider.SetOrderDelegates(new List<(Func<Person, object>, bool)>
{
(person => person.Name, false), // Ascending by Name
(person => person.Age, true) // Descending by Age
});PowerCSharp.Core has no external dependencies, making it lightweight and ideal for inclusion in any project.
Other PowerCSharp packages reference PowerCSharp.Core for:
- Shared interfaces and contracts
- Common base types
- Architectural consistency
- Building custom PowerCSharp extensions that need to implement standard interfaces
- Creating applications that use multiple PowerCSharp packages
- Developing libraries that need to integrate with PowerCSharp ecosystem
- Ensuring type safety across PowerCSharp packages
using PowerCSharp.Extensions;
using PowerCSharp.Core.Interfaces.Extensions.Linq;
// Your custom filter implementation
public class PersonFilterProvider : IDynamicFilterProvider<Person>
{
private Func<Person, bool> _filter;
public void SetFilter(Func<Person, bool> filter) => _filter = filter;
public Func<Person, bool> GetFilter() => _filter ?? (p => true);
}
// Use with PowerCSharp.Extensions
var people = new List<Person>();
var filtered = people.Filter(new PersonFilterProvider());using Microsoft.Extensions.Configuration;
using PowerCSharp.Extensions;
using PowerCSharp.Core.Interfaces.Extensions.Configuration;
public class DatabaseOptions : IAppOptions
{
public string ConfigSectionPath => "Database";
public string ConnectionString { get; set; }
public int Timeout { get; set; }
}
// Usage in application
var config = new ConfigurationBuilder().Build();
var dbOptions = config.GetOptions<DatabaseOptions>("Database");PowerCSharp.Core includes comprehensive unit tests. Run tests with:
dotnet test src/PowerCSharp.Core.Tests- Main PowerCSharp Documentation - Complete ecosystem overview
- PowerCSharp.Extensions API Documentation - Detailed API reference
- Contributing Guide - How to contribute
- Workflow Documentation - Development workflow
Contributions are welcome! Please read our Contributing Guidelines for details.
- Clone the repository
- Navigate to PowerCSharp.Core project
- Run tests to ensure everything works
- Make your changes
- Add tests for new functionality
- Submit a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- PowerCSharp.Extensions - Comprehensive extension methods
- PowerCSharp.Utilities - Utility classes and helpers
- PowerCSharp.Helpers - Specialized helper classes
PowerCSharp.Core - The foundation of powerful C# development! 🚀
