{"id":25501009,"url":"https://github.com/ignatandrei/RSCG_CompositeProvider","last_synced_at":"2025-11-11T22:30:20.312Z","repository":{"id":277888502,"uuid":"933695119","full_name":"ignatandrei/RSCG_CompositeProvider","owner":"ignatandrei","description":"Composite provider from interface . Given multiple implementation of an interface , return data from each / one ","archived":false,"fork":false,"pushed_at":"2025-02-16T19:17:24.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T20:25:06.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ignatandrei.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":"2025-02-16T13:39:51.000Z","updated_at":"2025-02-16T19:17:28.000Z","dependencies_parsed_at":"2025-02-16T20:35:36.755Z","dependency_job_id":null,"html_url":"https://github.com/ignatandrei/RSCG_CompositeProvider","commit_stats":null,"previous_names":["ignatandrei/rscg_compositeprovider"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_CompositeProvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_CompositeProvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_CompositeProvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_CompositeProvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignatandrei","download_url":"https://codeload.github.com/ignatandrei/RSCG_CompositeProvider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239508485,"owners_count":19650582,"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":[],"created_at":"2025-02-19T04:01:56.795Z","updated_at":"2025-11-11T22:30:20.239Z","avatar_url":"https://github.com/ignatandrei.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["186. [RSCG_CompositeProvider](https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_CompositeProvider) , in the [Interface](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#interface) category"],"readme":"# RSCG_CompositeProvider\n\n\nComposite provider from interface . Given multiple implementation of an interface , return data from each / one \n\n\n## Usage\n\nAdd the nuget package to your project\n\n```\ndotnet add package RSCG_CompositeProvider\ndotnet add package RSCG_CompositeProviderCommon\n```\n\nor put in your csproj file\n```xml\n  \u003cItemGroup\u003e\n    \u003cPackageReference Include=\"RSCG_CompositeProvider\" Version=\"2025.218.2100\" OutputItemType=\"Analyzer\" ReferenceOutputAssembly=\"false\" /\u003e\n    \u003cPackageReference Include=\"RSCG_CompositeProvider_Common\" Version=\"2025.218.2100\" /\u003e\n  \u003c/ItemGroup\u003e\n```\n\nThen if you have an interface like this\n\n```csharp\npublic interface IDataFrom\n{\n    string Name { get; }\n    Task\u003cstring\u003e KeyFromValue(string value, bool isKey);\n}\n```\n\nand multiple implementation of the interface like this\n\n```csharp\nclass DataFromHttp : IDataValue\n{\n    public string Name { get { return \"DataFromHttp\"; } set { } }\n\n    public async Task\u003cstring\u003e KeyFromValue(string key, bool defaultValue)\n    {\n        var http=new HttpClient();\n        var result = await http.GetStringAsync(\"https://www.\"+ Guid.NewGuid().ToString()+\".com/\" + key);\n        return result;\n    }\n}\n\n\nclass DataFromMemory : IDataValue\n{\n    public string Name { get { return \"DataFromMemory\"; } set { } }\n\n    public async Task\u003cstring\u003e KeyFromValue(string key, bool defaultValue)\n    {\n        await Task.Delay(1000);\n        return $\"this is value for {key} from memory\";\n    }\n}\n```\n\nthen you can call the composite provider to get data from all the implementation of the interface like this\n\n```csharp\n\nIDataValue provider = new DataValue_CP(new DataFromHttp(), new DataFromMemory());\nvar result = await provider.KeyFromValue(\"test\", false);\nConsole.WriteLine(result);\nDataValue_CP realClass = (DataValue_CP)provider ;\nvar lastInterface = realClass.lastUsedInterface ?? -1;\nConsole.WriteLine(\"value was obtained from \" + realClass.Get(lastInterface).Name);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2FRSCG_CompositeProvider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignatandrei%2FRSCG_CompositeProvider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2FRSCG_CompositeProvider/lists"}