From 6a641f9fa1c1ee6cd7a0ae636b8d8c38522c8a5c Mon Sep 17 00:00:00 2001 From: eiffel-org Date: Mon, 2 Oct 2023 10:26:30 +0000 Subject: [PATCH] Updated wikipage Eiffel for .NET Integration. (Signed-off-by:jocelyn). git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2430 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../eiffel-net-integration/index.wiki | 61 +------------------ 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/index.wiki b/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/index.wiki index 28b4bf9b..d6a1957b 100644 --- a/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/index.wiki +++ b/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/index.wiki @@ -1,4 +1,4 @@ -[[Property:modification_date|Mon, 02 Oct 2023 10:20:43 GMT]] +[[Property:modification_date|Mon, 02 Oct 2023 10:26:30 GMT]] [[Property:publication_date|Wed, 27 Sep 2023 19:33:07 GMT]] [[Property:title|Eiffel for .NET Integration]] [[Property:weight|3]] @@ -59,64 +59,7 @@ As noted above, Eiffel for .NET fully supports the powerful genericity mechanism * If you want to use a generic .NET class (for example in C#), you have to use special techniques as described next. -===Using generic .NET classes through a facade=== -Currently, Eiffel does not support consuming generics from C# classes. This tutorial demonstrates a workaround for this limitation by creating a Facade for a `List` in C# - -====Creating a facade for the List type==== -A Facade simplifies access to complex components. In this case, we will create a Facade to manage a list of strings. The Facade will encapsulate the list's functionality and expose a more straightforward interface. Here's how you can do it: - - -using System.Collections; -namespace ListOfString; - -/// -/// Facade for a List that encapsulates the list's functionality and exposes a few methods -/// -public class ListOfString -{ - private List _list; - - public ListOfString() - { - _list = new List(); - } - - public void Add(string item) - { - _list.Add(item); - } - - public bool Contains(string item) - { - return _list.Contains(item); - } - - public void Remove(string item) - { - _list.Remove(item); - } - - public IList GetList() - { - return _list.ToList(); - } -} - - -====Creating a C# library==== -To consume the Facade in Eiffel, we need to create a C# library. I recommend following the tutorial on creating a class library with C# and .NET on Microsoft’s official site. You can access it [https://learn.microsoft.com/en-us/dotnet/core/tutorials/library-with-visual-studio?pivots=dotnet-7-0 here]. This tutorial guides you through the process of creating a class library using C# and .NET. - -====Consuming the C# library from Eiffel==== -Finally, we need to consume the C# library from Eiffel. - -Open the Eiffel configuration file (.ecf) of your project and add the following entry - - - - -====Conclusion==== -By creating a Facade for a `List` in C#, we can effectively consume C# generic features in Eiffel. -This approach can be extended to other generic types as well. +{{info: Read the [[Workaround Eiffel .NET limitations]] page to learn how to workaround such limitation. }} ===Enum types=== Eiffel for .NET supports .NET enum types implicitly. From the point of view of Eiffel, they are just considered as expanded classes. The only difference is in the code generation. Eiffel for .NET cannot declare new enum types yet.