Search Results

Search found 26126 results on 1046 pages for 'generic service contract'.

Page 76/1046 | < Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >

  • Why is a .net generic dictionary so big

    - by thefroatgt
    I am serializing a generic dictionary in VB.net and I am very surprised that it is about 1.3kb with a single item. Am I doing something wrong, or is there something else I should be doing? I have a large number of dictionaries and it is killing me to send them all across the wire. The code I use for serialization is Dim dictionary As New Dictionary(Of Integer, Integer) Dim stream As New MemoryStream Dim bformatter As New BinaryFormatter() dictionary.Add(1, 1) bformatter.Serialize(stream, dictionary) Dim len As Long = stream.Length

    Read the article

  • Template function as a template argument

    - by Kos
    I've just got confused how to implement something in a generic way in C++. It's a bit convoluted, so let me explain step by step. Consider such code: void a(int) { // do something } void b(int) { // something else } void function1() { a(123); a(456); } void function2() { b(123); b(456); } void test() { function1(); function2(); } It's easily noticable that function1 and function2 do the same, with the only different part being the internal function. Therefore, I want to make function generic to avoid code redundancy. I can do it using function pointers or templates. Let me choose the latter for now. My thinking is that it's better since the compiler will surely be able to inline the functions - am I correct? Can compilers still inline the calls if they are made via function pointers? This is a side-question. OK, back to the original point... A solution with templates: void a(int) { // do something } void b(int) { // something else } template<void (*param)(int) > void function() { param(123); param(456); } void test() { function<a>(); function<b>(); } All OK. But I'm running into a problem: Can I still do that if a and b are generics themselves? template<typename T> void a(T t) { // do something } template<typename T> void b(T t) { // something else } template< ...param... > // ??? void function() { param<SomeType>(someobj); param<AnotherType>(someotherobj); } void test() { function<a>(); function<b>(); } I know that a template parameter can be one of: a type, a template type, a value of a type. None of those seems to cover my situation. My main question is hence: How do I solve that, i.e. define function() in the last example? (Yes, function pointers seem to be a workaround in this exact case - provided they can also be inlined - but I'm looking for a general solution for this class of problems).

    Read the article

  • Can JAXB generate a generic class?

    - by dinesh
    Can I get JAXB 2.0 XJC compiler to generate a generic class for me? Something as simple as:- public class Shape<T> { T myShape; // getter / setter } I see references for this in the spec but am not sure I'm reading it right. I always get Object references.

    Read the article

  • Why membership provider is not generic?

    - by Timmy O' Tool
    I have to confess that I hate membership provider. The default implementation is not very appropriate normally and I haven't seen so far a good implementation of a custom membership provider, probably because this is not possible :-) So the question is: In your opinion: which are the reasons for not having membership/role provider as a generic class? I mean, why Microsoft didn't selected this approach.

    Read the article

  • C#.NET Generic Methods and Inheritance.

    - by ealgestorm
    Is it possible to do the following with generics in C#.NET public abstract class A { public abstract T MethodB<T>(string s); } public class C: A { public override DateTime MethodB(string s) { } } i.e. have a generic method in a base class and then use a specific type for that method in a sub class.

    Read the article

  • Cuboid inside generic polyhedron

    - by DOFHandler
    I am searching for an efficient algorithm to find if a cuboid is completely inside or completely outside or (not-inside and not-outside) a generic (concave or convex) polyhedron. The polyhedron is defined by a list of 3D points and a list of facets. Each facet is defined by the subset of the contour points ordinated such as the right-hand normal points outward the solid. Any suggestion? Thank you

    Read the article

  • .net Generic Calls <T>

    - by Ryan
    I have a function that accepts a generic parameter T that is of type class like so : public Func<T, bool> MyMethod<T>(string paramName, object value) where T : class But when calling the function I do not have direct access to the class that needs to be the parameter. MyMethod<foo>("foo1", "foo2") Is there a way I can get the class foo via other means like reflection so I can use the function?

    Read the article

  • can I have an abstract base class with the key attribute being generic

    - by Greg
    Hi, I want to create a re-usable library. I was going to use extension methods however I run into some issues in some cases for the client to have to specify in the calling method the types. QUESTION - If I use an abstract base class as the basis, can I specify an attribute/property in the class to be generic (e.g. the key property might be an 'int' in one case, or a 'string' in another)?

    Read the article

  • Trouble with abstract generic methods

    - by DanM
    Let's say I have a class library that defines a couple entity interfaces: public interface ISomeEntity { /* ... */ } public interface ISomeOtherEntity { /* ... */ } This library also defines an IRepository interface: public interface IRepository<TEntity> { /* ... */ } And finally, the library has an abstract class called RepositorySourceBase (see below), which the main project needs to implement. The goal of this class is to allow the base class to grab new Repository objects at runtime. Because certain repositories are needed (in this example a repository for ISomeEntity and ISomeOtherEntity), I'm trying to write generic overloads of the GetNew<TEntity>() method. The following implementation doesn't compile (the second GetNew() method gets flagged as "already defined" even though the where clause is different), but it gets at what I'm trying to accomplish: public abstract class RepositorySourceBase // This doesn't work! { public abstract Repository<TEntity> GetNew<TEntity>() where TEntity : SomeEntity; public abstract Repository<TEntity> GetNew<TEntity>() where TEntity : SomeOtherEntity; } The intended usage of this class would be something like this: public class RepositorySourceTester { public RepositorySourceTester(RepositorySourceBase repositorySource) { var someRepository = repositorySource.GetNew<ISomeEntity>(); var someOtherRepository = repositorySource.GetNew<ISomeOtherEntity>(); } } Meanwhile, over in my main project (which references the library project), I have implementations of ISomeEntity and ISomeOtherEntity: public class SomeEntity : ISomeEntity { /* ... */ } public class SomeOtherEntity : ISomeOtherEntity { /* ... */ } The main project also has an implementation for IRepository<TEntity>: public class Repository<TEntity> : IRepository<TEntity> { public Repository(string message) { } } And most importantly, it has an implementation of the abstract RepositorySourceBase: public class RepositorySource : RepositorySourceBase { public override Repository<SomeEntity> GetNew() { return new Repository<SomeEntity>("stuff only I know"); } public override Repository<SomeOtherEntity> GetNew() { return new Repository<SomeOtherEntity>("other stuff only I know"); } } Just as with RepositorySourceBase, the second GetNew() method gets flagged as "already defined". So, C# basically think I'm repeating the same method because there's no way to distinguish the methods from parameters, but if you look at my usage example, it seems like I should be able to distinguish which GetNew() I want from the generic type parameter, e.g, <ISomeEntity> or <ISomeOtherEntity>. What do I need to do to get this to work?

    Read the article

  • Not Equal two Generic Lists

    - by David Johnson
    I have two generic lists, both containing different data, except 4 fields, which I want to compare to another list and find items that do not match in either list. I need to basically replace where it says equals below, with not equals! var unMatchedData = from liveLines in liveList join oldList in comapreSnapshotList on new {liveLines.ClientNo, liveLines.SequenceNo, liveLines.LineNo, liveLines.Text} equals new {oldList.ClientNo, oldList.SequenceNo, oldList.LineNo, oldList.Text} select new KNOWTXTS { ClientNo = liveLines.ClientNo, SequenceNo = liveLines.SequenceNo, LineNo = liveLines.LineNo, Text = liveLines.Text };

    Read the article

  • Pagination of Date-Based Generic Views in Django

    - by Apreche
    I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?

    Read the article

  • How do I find matching values in a generic list

    - by TDDG
    I have anywhere from 5 to 10 generic list in an ASP.NET VB.NET web app. I would like to write a method to pass them all into, and return only the elements they all have in common. I'm looking for some ideas how to accomplish this the easiest and cleanest way possible.

    Read the article

  • How to return a value based on the type of the generic T

    - by Blankman
    I have a method like: public T Get<T>(string key) { } Now say I want to return "hello" if the type is a string, and 110011 if it is type int. how can I do that? typeof(T) doesn't seem to work. I ideally want to do a switch statement, and return something based on the Type of the generic (string/int/long/etc). Is this possible?

    Read the article

  • Generic object comparison diff routine

    - by MicMit
    The question stems from database tables comparison. Let's say we put left row in the instance Left and the right one into instance Right of the same type. And we'got many tables and respective types. How to implement more or less generic routine resulting in a collection of diffs e.g. propertyName , leftValue , rightValue for each such a pair of instances of the same type.

    Read the article

  • Generic solution to deselect buttons in java

    - by Hectoret
    In a set of radio buttons of the same group, only one can be selected at the same time. I would like to have the same behaviour with a normal button. Imagine there's a row of 3 buttons. When a button is selected it changes: but.setSelected(true) and the other two buttons should be NOT selected: but.setSelected(false) Now, is there a generic, simple and clean solution to accomplish that in Java (Swing) ?

    Read the article

< Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >