.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Generics with Interface constraint from WCF.

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :.NET Framework
Hello Not sure this is possible, but there might be a smart person out there who can answer it. Heck, maybe its simple :) I have a class that consumes an WCF service. That class contains the following generic method:   private void BuildTree<T, U>(T tree, U rootNode, ref List<U> listToBeBuilt) where T : ITreeDefinition, IEnumerable<T> where U : ITreeDefinition { ... }  Basically, it builds a tree based on generic data etc. However, it can't work without ITreeDefinition:   public interface ITreeDefinition { string GetRoot { get; set; } string GetChild { get; set; } }    This interface is contained in the WCF service, and used like so:   [DataContract] [KnownType(typeof(ITreeDefinition))] public class CaseStructureInfo : ITreeDefinition { #region OtherCode ... #endregion // Defines what properties to use to build a treetable. [DataMember] public string GetRoot { get { return SagsNr; } set { SagsNr = value; } } [DataMember] public string GetChild { get { return Hovedsag; } set { Hovedsag = value; } } }    The problem: The constraint "ITreeDefinition" is unknown to the generic method, because it is only visible in the WCF service. Can anyone help me out with this? Ps.  For the sake of understanding, here is the rest of the generic method... it is recursive, so

View Complete Post

More Related Resource Links

TreeSelector : playing with generics and type inference

create a generic way to define a selection starting from a tree of objects, the most simpler way as possible.

Let's start with the beginning...
Here is a very simple little interface defining a node of the tree, basically, a value and the references to the child nodes.

database interface design question


For handy database interface, is it good to use SqldataSources exclusively intead of EntLib functions?

Thanks for any feedback.

WCF The Security Support Provider Interface (SSPI) negotiation failed


I am using a wcf service that I created, when both hosting machine and the client machine are on the same domain everything works just fine. When I publish the client app to the webserver in the DMZ I am getting the following error:

SOAP security negotiation with '' for   
'' failed. See inner exception  
for more details.The Security Support Provider Interface (SSPI) negotiation failed.

Here is my service main where I set up the service


 Uri baseAddress = new Uri("Http://");
      ServiceHost selfHost = new ServiceHost(typeof(QBService), baseAddress);


Cutting Edge: Single-page Interface and AJAX Patterns


This month we begin a look at the Single Page Interface (SPI) model and some design patterns for designing AJAX applications.

Dino Esposito

MSDN Magazine May 2008

Advanced Basics: Reflection and Generics


This month Advanced Basics flaunts the power of generics and reflection and shows how you get more flexible and efficient development by combining the two.

Ken Getz

MSDN Magazine January 2008

Fuzz Testing: Create a Custom Test Interface Provider for Team System


Dan Griffin shows the extensibility of Visual Studio 2005 Team Edition for Software Testers by discussing the modification of the existing Test Interface Provider sample in the latest Visual Studio SDK and implements Fuzz Testing.

Dan Griffin

MSDN Magazine November 2007

Netting C++: Mapping Templates to Generics


In this installment, Stanley Lippman continues to port his ISO-C++ Text Query Language application to the Microsoft .NET Framework and C++/CLI.

Stanley Lippman

MSDN Magazine April 2007

Pure C++: How Templates and Generics Work Together


I'm closing out this series of columns on generic programming in the Microsoft® . NET Framework by showing how templates and generics do and do not work together, and pointing out a pitfall with the current implementation of templates under Visual C++® 2005.

Stanley B. Lippman

MSDN Magazine April 2006

.NET Column: Introducing Generics in the CLR


Generics are an extension of the CLR type system that allow developers to define types for which certain details are left unspecified. These details are specified when the code is referenced by consumer code, making for enhanced flexibility. Jason Clark explains how.

Jason Clark

MSDN Magazine Visual Studio 2005 Guided Tour 2006

Pure C++: CLR Generics Versus C++ Templates


Visual Studio® 2005 brings the type parameter model of generic programming to the Microsoft® . NET Framework. C++/CLI supports two type parameter mechanisms-common language runtime (CLR) generics and C++ templates.

Stanley B. Lippman

MSDN Magazine June 2005

.NET Web Services: Web Methods Make it Easy to Publish Your App's Interface over the Internet


Web Services are a great way to accept and manage contributions to a public clip art library, digital music catalog, or corporate knowledge base. Since the SOAP interface to a Web method operates over HTTP, contributors can easily publish content any time, from anywhere across the Internet. However, accepting binary content and managing content metadata through SOAP over HTTP presents Web Service developers with some interesting design decisions. This article discusses three ways to enable content publishing using Web methods.

Paula Paul

MSDN Magazine March 2002

New Graphical Interface: Enhance Your Programs with New Windows XP Shell Features


The Windows XP shell introduces many new features that both users and developers are sure to welcome. The interface supports a number of styles that will be new to users, and it also supports customization of those styles through a new concept called themes. There are more shell registry settings available to the user and developer, a facility for customizing infotips, and infotip shell extensions. In addition, folder views can be customized. This article covers these shell changes and includes a discussion of a number of other Windows XP additions. These include fast user switching, which lets users log on and off quickly, and AutoPlay support for a variety of devices and file types not previously supported.

Dino Esposito

MSDN Magazine November 2001

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend