Search Results

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

Page 112/1046 | < Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >

  • Is there a way to make ToEnum generic

    - by maxfridbe
    I would like to do this but it does not work. bool TryGetEnum<TEnum, TValue>(TValue value, out TEnum myEnum) { if (Enum.IsDefined(typeof(TEnum), value)) { myEnum = (TEnum)value; return true; } return false; } Example usage: MyEnum mye; bool success = this.TryGetEnum<MyEnum,char>('c',out mye);

    Read the article

  • Modeling a Generic Relationship (expressed in C#) in a Database

    - by StevenH
    This is most likely one for all you sexy DBAs out there: How would I effieciently model a relational database whereby I have a field in an "Event" table which defines a "SportType"? This "SportsType" field can hold a link to different sports tables E.g. "FootballEvent", "RubgyEvent", "CricketEvent" and "F1 Event". Each of these Sports tables have different fields specific to that sport. My goal is to be able to genericly add sports types in the future as required, yet hold sport specific event data (fields) as part of my Event Entity. Is it possible to use an ORM such as NHibernate / Entity framework / DataObjects.NET which would reflect such a relationship? I have thrown together a quick C# example to express my intent at a higher level: public class Event<T> where T : new() { public T Fields { get; set; } public Event() { EventType = new T(); } } public class FootballEvent { public Team CompetitorA { get; set; } public Team CompetitorB { get; set; } } public class TennisEvent { public Player CompetitorA { get; set; } public Player CompetitorB { get; set; } } public class F1RacingEvent { public List<Player> Drivers { get; set; } public List<Team> Teams { get; set; } } public class Team { public IEnumerable<Player> Squad { get; set; } } public class Player { public string Name { get; set; } public DateTime DOB { get; set;} }

    Read the article

  • Generic test suite for ASP.NET Membership/Role/Profile/Session Providers

    - by SztupY
    Hi! I've just created custom ASP.NET Membership, Role, Profile and Session State providers, and I was wondering whether there exists a test suite or something similar to test the implementation of the providers. I've checked some of the open source providers I could find (like the NauckIt.PostgreSQL provider), but neither of them contained unit tests, and all of the forum topics I've found mentioned only a few test cases (like checking whether creating a user works), but this is clearly not a complete test suite for a Membership provider. (And I couldn't find anything for the other three providers) Are there more or less complete test suites for the above mentioned providers, or are there custom providers out there that have at least some testing avaialable?

    Read the article

  • What is a custom collection?

    - by Win Coder
    A Group of objects. However i am having confusion in the following case. A sample class Class A { public string; } Class A_list { public A[] list; public A_list(A[] _list) { list = new A[_list.length]; for (int i = 0; i < _list.Length; i++) { list[i] = _list[i]; } } } static void Main(String[] args) { A[] names = new A[3] { new A("some"), new A("another"), new A("one"), }; A_list just_an_object = new A_list(names); } Which of the above is a custom collection the array or the object that holds array as a field or are both custom collections.

    Read the article

  • Compilers behave differently with a null parameter of a generic method

    - by Eyal Schneider
    The following code compiles perfectly with Eclipse, but fails to compile with javac: public class HowBizarre { public static <P extends Number, T extends P> void doIt(P value) { } public static void main(String[] args) { doIt(null); } } I simplified the code, so T is not used at all now. Still, I don't see a reason for the error. For some reason javac decides that T stands for Object, and then complains that Object does not conform to the bounds of T (which is true): HowBizarre.java:6: incompatible types; inferred type argument(s) java.lang.Number,java.lang.Object do not conform to bounds of type variable (s) P,T found : <P,T>void required: void doIt(null); ^ Note that if I replace the null parameter with a non-null value, it compiles fine. Which of the compilers behaves correctly and why? Is this a bug of one of them?

    Read the article

  • Setting generic type at runtime

    - by destroyer of evil
    I have a class public class A<T> { public static string B(T obj) { return TransformThisObjectToAString(obj); } } I can call the static function like this just fine on a known/specified type: string s= A<KnownType>.B(objectOfKnownType); How do I make this call, if I don't know T beforehand, rather I have a variable of type Type that holds the type. If I do this: Type t= typeof(string); string s= A<t>.B(someStringObject); I get this compiler error: Cannot implicitly convert type 't' to 'object'

    Read the article

  • Generic Rails Route Representation?

    - by Flemish Bee Cycle
    Given one or more instances of a model (AR or DM, whatever). Is it possible to generate the route in the requirement form, by which I mean "/foos/:id" Given the route: resource :foo do resource :bar end generate_route_method [@foo,@bar] - "/foos/:id/bars/:id" I'm not talking about #foos_path or #polymorphic_path, rather, literally generating the string containing the wildcard components (i.e ":id"), the same as it would appear as if you did "rake routes".

    Read the article

  • Binding Generic List Array to GridView

    - by OliverS
    Hi I have a List which returns an array of "Question". My question is how can I bind this to a grid view? When I try to call Question.Ordinal I get that it does not exist in the data source. I am using the following code: GridView1.DataSource = myList.GetQ(); GrdiView1.DataBind(); myList.GetQ() returns a List which is an array of "Question". When I set the column DataField to "!" I get the object Question. My question is how can I get the objects property? I tried "!.Ordinal" does not work. I was reading this post for reference, here, any help is greatly appreciated, thanks.

    Read the article

  • Hot to get generic type from object type

    - by Murat
    My Classes are; class BaseClass { } class DerivedClass1 : BaseClass { } class GenericClass<T> { } class DerivedClass2 : BaseClass { GenericClass<DerivedClass1> subItem; } I want to access all fields of DerivedClass2 class. I use System.Reflection and FieldInfo.GetValue() method; Bu I cant get subItem field. FieldInfo.GetValue() method return type is "object". And I cant cast to GenericClass<DerivedClass1> or I cant get DerivedClass1 type. I try this with BaseClass BaseClass instance = FieldInfo.Getvalue(this) as GenericClass<BaseClass>; but instance is null. How to get instance with type or how to get only type?

    Read the article

  • Generic WithEvents

    - by serhio
    Error: 'WithEvents' variables can only be typed as classes, interfaces or type parameters with class constraints Background: Public Class Tadpole(Of T As IVisibleChanged, P As IVisibleChanged) Private WithEvents _Tad As T ' ERROR ' Private WithEvents _Pole As P ' ERROR ' Public Property Tad() As T ... Public Property Pole() As P ... End Class ''' IVisibleChanged ''' Public Interface IVisibleChanged Property Visible() As Boolean Event VisibleChanged As EventHandler End Interface Workaround: a. Use AddHandler to handle events defined in a structure. EDIT b. use Private WithEvents _Tad AsIVisibleChanged (M.A. Hanin) c. ?

    Read the article

  • django app with a generic name

    - by zaharpopov
    Django tutorials everywhere use constant-set application name all around - in urls file, in HTML templates, in views. But if I want to distribute an application and let the user sets it name (i.e. its URL postfix on http://server.com/appname) - how can I do? I must have some common name setting then in configuration, but how to work it for template files, etc?

    Read the article

  • Casting Generic Types

    - by David Rutten
    Public Function CastToT(Of T)(ByVal GenericType(Of Object) data) As GenericType(Of T) Return DirectCast(data, GenericType(Of T)) End Function The above clearly does not work. Is there any way to perform this cast if I know that all objects inside data are in fact of Type T?

    Read the article

  • Using Reflection Invoke static generic method passing a Lamba as parameter

    - by Nikos Baxevanis
    Is it possible to write the following code via Reflection? var fake = A.Fake<Foo>( o => o.WithArgumentsForConstructor(new[] { "Hello" })); Where o is: Action<IFakeOptionsBuilder<T>> Where WithArgumentsForConstructor is: IFakeOptionsBuilder<T> WithArgumentsForConstructor(IEnumerable<object> argumentsForConstructor); The Foo class is: class Foo { public Foo(string s) { } } What I did was: object fake = typeof(A) .GetMethod("Fake", new Type[] { }) .MakeGenericMethod(new[] { this.targetType }) .Invoke(null, /* Here I need to pass the lambda. */);

    Read the article

  • Grouping a generic list via LINQ in VB.NET

    - by CD Smith
    I need to take a collection and group it via Linq but all the examples I've seen fail in some manner or other with some syntax difference that I can't quite lick. My collection: Dim a As New List(Of ProcessAlert) a.Add(New ProcessAlert("0000112367", "[email protected]", "Alert", 2)) a.Add(New ProcessAlert("0000112367", "[email protected]", "Document", 2)) a.Add(New ProcessAlert("0000112367", "[email protected]", "Note", 2)) a.Add(New ProcessAlert("0000112367", "[email protected]", "Alert", 1)) a.Add(New ProcessAlert("0000112367", "[email protected]", "Document", 1)) a.Add(New ProcessAlert("0000112367", "[email protected]", "Note", 1)) Return a I need to turn this collection into a simple way to give this final outcome: "[email protected]", "Alert, Document, Note" "[email protected]", "Alert, Document, Note" Here's the definition of the ProcessAlert class: Public Class ProcessAlert Public LoanNumber As String Public EmailAddress As String Public AlertType As String Public AlertMethodID As Byte End Class Thanks in advance, CD

    Read the article

  • How to implement generic callbacks in C++

    - by Kylotan
    Forgive my ignorance in asking this basic question but I've become so used to using Python where this sort of thing is trivial that I've completely forgotten how I would attempt this in C++. I want to be able to pass a callback to a function that performs a slow process in the background, and have it called later when the process is complete. This callback could be a free function, a static function, or a member function. I'd also like to be able to inject some arbitrary arguments in there for context. (ie. Implementing a very poor man's coroutine, in a way.) On top of that, this function will always take a std::string, which is the output of the process. I don't mind if the position of this argument in the final callback parameter list is fixed. I get the feeling that the answer will involve boost::bind and boost::function but I can't work out the precise invocations that would be necessary in order to create arbitrary callables (while currying them to just take a single string), store them in the background process, and invoke the callable correctly with the string parameter.

    Read the article

  • Does ASP.net 1.1 support Generic HttpHandlers ?

    - by Campos
    I need to get an image from a SQL Server as a byte[], and load it to a WebControl.Image. The only seemingly good way to do it that I found is to implement IHttpHandler and handle the request accordingly. But I'm stuck to using asp.net 1.1. Does it support ashx files?

    Read the article

  • How to display a generic error page in Asp.Net MVC 2

    - by Picflight
    I have the following in my base controller: protected override void OnException(ExceptionContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext"); } // If custom errors are disabled, we need to let the normal ASP.NET exception handler // execute so that the user can see useful debugging information. if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) { return; } Exception exception = filterContext.Exception; // If this is not an HTTP 500 (for example, if somebody throws an HTTP 404 from an action method), // ignore it. if (new HttpException(null, exception).GetHttpCode() != 500) { return; } // TODO: What is the namespace for ExceptionType? //if (!ExceptionType.IsInstanceOfType(exception)) //{ // return; //} // Send Email MailException(exception); // TODO: What does this line do? base.OnException(filterContext); filterContext.Result = new ViewResult { ViewName = "Error" }; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 500; } In my Shared folder, I have an Error.aspx View. Web.config <customErrors mode="On" /> I am still seeing the yellow screen when an exception occurs. What am I doing incorrectly?

    Read the article

  • FileInputStream for a generic file System

    - by Akhil
    I have a file that contains java serialized objects like "Vector". I have stored this file over Hadoop Distributed File System(HDFS). Now I intend to read this file (using method readObject) in one of the map task. I suppose FileInputStream in = new FileInputStream("hdfs/path/to/file"); wont' work as the file is stored over HDFS. So I thought of using org.apache.hadoop.fs.FileSystem class. But Unfortunately it does not have any method that returns FileInputStream. All it has is a method that returns FSDataInputStream but I want a inputstream that can read serialized java objects like vector from a file rather than just primitive data types that FSDataInputStream would do. Please help!

    Read the article

  • Generic callbacks

    - by bobobobo
    Extends So, I'm trying to learn template metaprogramming better and I figure this is a good exercise for it. I'm trying to write code that can callback a function with any number of arguments I like passed to it. // First function to call int add( int x, int y ) ; // Second function to call double square( double x ) ; // Third func to call void go() ; The callback creation code should look like: // Write a callback object that // will be executed after 42ms for "add" Callback<int, int, int> c1 ; c1.func = add ; c1.args.push_back( 2 ); // these are the 2 args c1.args.push_back( 5 ); // to pass to the "add" function // when it is called Callback<double, double> c2 ; c2.func = square ; c2.args.push_back( 52.2 ) ; What I'm thinking is, using template metaprogramming I want to be able to declare callbacks like, write a struct like this (please keep in mind this is VERY PSEUDOcode) <TEMPLATING ACTION <<ANY NUMBER OF TYPES GO HERE>> > struct Callback { double execTime ; // when to execute TYPE1 (*func)( TYPE2 a, TYPE3 b ) ; void* argList ; // a stored list of arguments // to plug in when it is time to call __func__ } ; So for when called with Callback<int, int, int> c1 ; You would automatically get constructed for you by < HARDCORE TEMPLATING ACTION > a struct like struct Callback { double execTime ; // when to execute int (*func)( int a, int b ) ; void* argList ; // this would still be void*, // but I somehow need to remember // the types of the args.. } ; Any pointers in the right direction to get started on writing this?

    Read the article

  • Generic transparent Qt widget that can catch clicks?

    - by Pieter
    I've figured out how to use QPainter to draw rectangles. Now I want to have a drawing area where if the user clicks, a 1x1 rectangle is drawn where the mouse pointer is. To accomplish this, I assume I need a transparent Qt widget that supports the clicked() signal. How do I make such a transparent widget? Or is there something else I can use? Perhaps I can only use the window's clicked() signal?

    Read the article

  • I have a generic implementation of PHP mcrypt module and its not decrypting

    - by Ken Mitchner
    class Crypt_Data { protected $_mcrypt=null; protected $_iv=null; protected $_key=null; public function __construct() { $this->_mcrypt = mcrypt_module_open('rijndael_256', '', 'cbc', ''); $key_size = mcrypt_enc_get_key_size($this->_mcrypt); for($i=0;$i<$key_size;$i++) $test_key .= "0"; $this->_iv = $test_key; $this->_key = $test_key; mcrypt_generic_init($this->_mcrypt,$this->_key,$this->_iv); } public function dataEncrypt($data) { return base64_encode(mcrypt_generic($this->_mcrypt, $data)); } public function dataDecrypt($data) { return mdecrypt_generic($this->_mcrypt, base64_decode($data)); } } $crypt = new Crypt_Data(); $string = "encrypt me"; $encrypted = $crypt->dataEncrypt($string); echo $encrypted."<BR>"; $decrypted = $crypt->dataDecrypt($encrypted); echo $decrypted."<BR>"; output: JJKfKxZckkqwfZ5QWeyVR+3PkMQAsP0Gr1hWaygV20I= qÌÌi_ÖZí(®`iÜ¥wÝÿ ô0€Í6Ÿhf[%ër No idea why this isn't working, everything seems to be fine on my end.. i tried decrypting it with mcrypt_cbc(); and it decrypted it properly.. so it has something to do with my mdecrypt_generic.. any ideas?

    Read the article

  • File Locked by Services (after service code reading the text file)

    - by rvpals
    I have a windows services written in C# .NET. The service is running on a internal timer, every time the interval hits, it will go and try to read this log file into a String. My issue is every time the log file is read, the service seem to lock the log file. The lock on that log file will continue until I stop the windows service. At the same time the service is checking the log file, the same log file needs to be continuously updated by another program. If the file lock is on, the other program could not update the log file. Here is the code I use to read the text log file. private string ReadtextFile(string filename) { string res = ""; try { System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(fs); res = sr.ReadToEnd(); sr.Close(); fs.Close(); } catch (System.Exception ex) { HandleEx(ex); } return res; } Thank you.

    Read the article

  • Windows Service doesn't start process with different credentials

    - by Marcus
    I have a Windows Service, running as a user, that should start several processes under different user credentials. I'm using the following code to start a process: Dim winProcess As New System.Diagnostics.Process With winProcess .StartInfo.Arguments = "some_args" .StartInfo.CreateNoWindow = True .StartInfo.ErrorDialog = False .StartInfo.FileName = "C:\TEMP\ProcessFromService\ProcessFromService\bin\Debug\ProcessFromService.exe" .StartInfo.UseShellExecute = False .StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'Opgave WorkingDirectory kan soms tot problemen leiden, indien betreffende directory 'niet bereikbaar (rechten) is voor opgegeven gebruiker. 'Beter dus om deze niet op te geven. '.StartInfo.WorkingDirectory = My.Computer.FileSystem.SpecialDirectories.Temp .StartInfo.Domain = "" .StartInfo.UserName = "MyUserId" Dim strPassword As String = "MyPassword" Dim ssPassword As New Security.SecureString For Each chrPassword As Char In strPassword.ToCharArray ssPassword.AppendChar(chrPassword) Next .StartInfo.Password = ssPassword .Start() End With The process is correctly started when I use the same credentials as of which the Windows Service is running under. The process is not started, without any error, when I use different credentials. In other words: If the Windows Service is running as UserA then I can start a process running as UserA. If the Windows Service is running as UserB then I can not start a process running as UserA. I have created a test project in which I can reproduce this problem. If you put this project in C:\Temp then the used paths will be correct. You can download this test project here: https://dl.dropboxusercontent.com/u/5391091/ProcessFromService.zip NB: I hope this info is enough to explain it. If you need more info, please let me know and I will add it.

    Read the article

  • wcf class implementing multiple service contracts

    - by Archie
    Hello, I have a class TestService which implements two service contracts called IService1 and IService2. But I'm facing a difficulty in implementation. My Code looks as follows: Uri baseAddress = new Uri("http://localhost:8000/ServiceModel/Service"); Uri baseAddress1 = new Uri("http://localhost:8080/ServiceModel/Service1"); ServiceHost selfHost = new ServiceHost(typeof(TestService)); selfHost.AddServiceEndpoint(typeof(IService1), new WSHttpBinding(), baseAddress); selfHost.AddServiceEndpoint(typeof(IService2), new WSHttpBinding(), baseAddress1); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; selfHost.Description.Behaviors.Add(smb); selfHost.Open(); Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); selfHost.Close(); I'm getting a run time error as: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address. What shall i do about it? Do I realy need two separate endpoints? Thanks.

    Read the article

  • Cast Object to Generic List

    - by CrazyJoe
    I have 3 generict type list. List<Contact> = new List<Contact>(); List<Address> = new List<Address>(); List<Document> = new List<Document>(); And save it on a variable with type object. Now i nedd do Cast Back to List to perfom a foreach, some like this: List<Contact> = (List<Contact>)obj; But obj content change every time, and i have some like this: List<???> = (List<???>)obj; I have another variable holding current obj Type: Type t = typeof(obj); Can i do some thing like that??: List<t> = (List<t>)obj; Obs: I no the current type in the list but i need to cast , and i dont now another form instead: List<Contact> = new List<Contact>(); Help Plz!!!

    Read the article

< Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >