{"id":24757701,"url":"https://github.com/iharyakimush/specification","last_synced_at":"2026-04-30T06:34:50.093Z","repository":{"id":92323356,"uuid":"152221222","full_name":"IharYakimush/Specification","owner":"IharYakimush","description":"Specification pattern implementation for filtering objects","archived":false,"fork":false,"pushed_at":"2018-11-27T11:42:03.000Z","size":223,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-01T00:37:46.906Z","etag":null,"topics":["expression-tree","filter","specification-pattern"],"latest_commit_sha":null,"homepage":"","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/IharYakimush.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":"2018-10-09T09:07:39.000Z","updated_at":"2018-11-27T12:15:10.000Z","dependencies_parsed_at":"2023-06-03T03:30:22.393Z","dependency_job_id":null,"html_url":"https://github.com/IharYakimush/Specification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2FSpecification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2FSpecification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2FSpecification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2FSpecification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IharYakimush","download_url":"https://codeload.github.com/IharYakimush/Specification/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078188,"owners_count":20557281,"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":["expression-tree","filter","specification-pattern"],"created_at":"2025-01-28T15:34:43.900Z","updated_at":"2026-04-30T06:34:45.269Z","avatar_url":"https://github.com/IharYakimush.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Specification\nFilter data using specification expressions tree with following advantages:\n- ability to load specification from xml. json format support comming soon.\n- concept of \"specification reference\" and \"value reference\" to reuse already defined expressions in more complex ones.\n- comparison between single and multiple values\n- base visitors for efficien work with specification expressions tree\n\n## Getting started\nDefine specification expression\n```\nSpecification specification = new AndSpecification(\n    new EqualSpecification(\"key1\", SpecificationValue.Single(\"value1\")),\n    new OrSpecification(\n        new HasValueSpecification(\"key2\"),\n\t\tnew EqualSpecification(\"key5\", SpecificationValue.Single(new DateTime(2018, 10, 10, 1, 2, 3))),\n\n        // value of key3 should be equal to any of values 1,2,3\n        new EqualSpecification(\"key3\", SpecificationValue.AnyOf(1, 2, 3))),\n\n    // key4 should be equal to value with name \"currentDateTime\" which will be resolved at specification evaluation\n    new EqualSpecification(\"key4\", SpecificationValue.Ref(\"currentDateTime\")));\n```\nEvaluate specification expression\n```\nDictionary\u003cstring, object\u003e values = new Dictionary\u003cstring, object\u003e\n    {\n        { \"key1\", \"value1\" },\n        { \"key3\", 1 },\n        { \"key4\", DateTime.Now.AddMinutes(1) },\n    \n        // value referenced from specification\n        { \"currentDateTime\", DateTime.UtcNow }                                                        \n    };\n    \nSpecificationResult result = specification.Evaluate(values);\nAssert.True(result.IsSatisfied);\n```\nSerialize specification expression to xml `string xml = specification.ToXml();`. DateTime values will be converted to UTC for serialization and comparison.\n```\n\u003cand\u003e\n  \u003ceq key=\"key1\" value=\"value1\" /\u003e\n  \u003cor\u003e\n    \u003chasvalue key=\"key2\" /\u003e\n\t\u003ceq key=\"key5\" t=\"datetime\" value=\"2018-10-09 22:02:03Z\" /\u003e\n    \u003ceq key=\"key3\" t=\"int\"\u003e\n      \u003cvalue\u003e1\u003c/value\u003e\n      \u003cvalue\u003e2\u003c/value\u003e\n      \u003cvalue\u003e3\u003c/value\u003e\n    \u003c/eq\u003e\n  \u003c/or\u003e\n  \u003cge key=\"key4\" valueRef=\"currentDateTime\" /\u003e\n\u003c/and\u003e\n```\nParse specification from xml `Specification sp2 = Specification.Parse.FromXml(XElement.Parse(xml));`. Parse operation assume DateTime to be UTC values.\n\n## NuGet\nhttps://www.nuget.org/packages/Specification.Expressions\n\n## Contribution\nPlease feel free to create issues and pool requests to develop branch","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharyakimush%2Fspecification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiharyakimush%2Fspecification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharyakimush%2Fspecification/lists"}