{"id":15785172,"url":"https://github.com/awaescher/fluentstructures","last_synced_at":"2025-08-03T17:35:52.854Z","repository":{"id":165625874,"uuid":"641014961","full_name":"awaescher/FluentStructures","owner":"awaescher","description":"Fluent APIs to simplify the handling of structs in .NET","archived":false,"fork":false,"pushed_at":"2024-05-21T12:28:45.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T20:34:55.657Z","etag":null,"topics":["fluent","fluent-api","intent","structs","structures"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/FluentStructures","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awaescher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-15T15:41:26.000Z","updated_at":"2024-07-01T15:08:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"36378fa8-deea-4939-9fad-2660436d6b14","html_url":"https://github.com/awaescher/FluentStructures","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2FFluentStructures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2FFluentStructures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2FFluentStructures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2FFluentStructures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awaescher","download_url":"https://codeload.github.com/awaescher/FluentStructures/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246507544,"owners_count":20788846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fluent","fluent-api","intent","structs","structures"],"created_at":"2024-10-04T20:21:22.560Z","updated_at":"2025-03-31T17:27:01.114Z","avatar_url":"https://github.com/awaescher.png","language":"C#","readme":"# FluentStructures\n\nThis project provides a set of fluent APIs to simplify the handling of structs in .NET.\n\nYou spent too much time centering stuff with `X1 + ((Width1 - Width2) / 2)`.\n\n## Use cases\n\n### Setting properties with `With...`\n\nThe extensions methods `With...` and `WithAdditional...` provide expressive ways to get a copy of a struct with absolute values or relative value additions.\n\n```csharp\n//   (p1)───────────────────────────────(p2)\n//                                       │\n//                                       │\n//                                       │   +50px\n//                                       │\n//                                       │\n//                         (p4)─────────(p3)\n//                               -33px\n\n// traditional\nvar p1 = new Point(10, 10);\nvar p2 = new Point(100, p1.Y);\nvar p3 = new Point(p2.X, p2.Y + 50);\nvar p4 = new Point(p3.X - 33, p3.Y);\n\n// fluent\np1 = new Point(10, 10);\np2 = p1.WithX(100);             // absolute\np3 = p2.WithAdditionalY(50);    // relative\np4 = p3.WithAdditionalX(-33);\n```\n\n### Emphasizing the intent over simple calculations\n\nThis project does not only add fluent extensions to set properties, it also comes with tailored extension methods to emphasize the intent when working with structs. Simple and expressive code instead of calculations that have to be thought through every time they get rediscovered.\n\nThe `Rectangle` (and `RectangleF`) gets an extension method to find its landmarks (corner stones or the center point) easily ...\n\n```csharp\n//    ┌──────────────────────────────────┐\n//    │                                  │\n//    │                                  │\n//    │              (p1)                │\n//    │                                  │\n//    │                                  │\n//    └──────────────(p2)────────────────┘\n\n\n// traditional\nvar p1 = new Point(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));\nvar p2 = new Point(rect.Left + (rect.Width / 2), rect.Bottom);\n\n// fluent\np1 = rect.GetLandmark(ContentAlignment.MiddleCenter);\np2 = rect.GetLandmark(ContentAlignment.BottomCenter);\n```\n\n... while `Embed()` takes another rectangle or size to be embedded and returns the corresponding bounds depending on the defined alignment.\n\n```csharp\n//    ┌──────────────────────────────────┐\n//    │                                  │\n//    │                         ┌────┐   │\n//    │                         │    │   │   \u003c-- 10px padding\n//    │                         └────┘   │\n//    │                                  │\n//    └──────────────────────────────────┘\n\nvar cellBounds = new Rectangle(100, 100, 300, 150);\nvar userImage = new Bitmap(30, 30);\n\n// traditional\nvar userImageBounds = new Rectangle(\n    cellBounds.Right - userImage.Width - 10,\n    cellBounds.Y + ((cellBounds.Height - userImage.Height) / 2),\n    userImage.Width,\n    userImage.Height);\n\n// fluent\nuserImageBounds = cellBounds\n    .Embed(userImage.Size, ContentAlignment.MiddleRight)\n    .WithAdditionalLeft(-10);\n```\n\n## Scope\n\nThis project currently adds extension methods to structs of the `System.Drawing` namespace like `Color`, `Point`, `Rectangle` and so on. More structs might be added over time, pull requests always welcome.\n\n--- \n[Model icons created by Flowicon on Flaticon](https://www.flaticon.com/free-icons/model)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaescher%2Ffluentstructures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawaescher%2Ffluentstructures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaescher%2Ffluentstructures/lists"}