Search Results

Search found 6357 results on 255 pages for 'generic relations'.

Page 14/255 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • StructureMap Open Generic Types

    - by Shane Fulmer
    I have the following classes: public interface IRenderer<T> { string Render(T obj); } public class Generic<T> { } public class SampleGenericRenderer<T> : IRenderer<Generic<T>> { public string Render(Generic<T> obj) { throw new NotImplementedException(); } } I would like to be able to call StructureMap with ObjectFactory.GetInstance<IRenderer<Generic<string>>>(); and receive SampleGenericRenderer<string>. I'm currently using the following registration and receiving this error when I call GetInstance. "Unable to cast object of type 'ConsoleApplication1.SampleGenericRenderer'1[ConsoleApplication1.Generic'1[System.String]]' to type 'ConsoleApplication1.IRenderer'1[ConsoleApplication1.Generic'1[System.String]]'." public class CoreRegistry : Registry { public CoreRegistry() { Scan(assemblyScanner => { assemblyScanner.AssemblyContainingType(typeof(IRenderer<>)); assemblyScanner.AddAllTypesOf(typeof(IRenderer<>)); assemblyScanner.ConnectImplementationsToTypesClosing(typeof(IRenderer<>)); }); } } Is there any way to configure StructureMap so that it creates SampleGenericRenderer<string> instead of SampleGenericRenderer<Generic<string>>?

    Read the article

  • C# Generic Generics (A Serious Question)

    - by tahirhassan
    In C# I am trying to write code where I would be creating a Func delegate which is in itself generic. For example the following (non-Generic) delegate is returning an arbitrary string: Func<string> getString = () => "Hello!"; I on the other hand want to create a generic which acts similarly to generic methods. For example if I want a generic Func to return default(T) for a type T. I would imagine that I write code as follows: Func<T><T> getDefaultObject = <T>() => default(T); Then I would use it as getDefaultObject<string>() which would return null and if I were to write getDefaultObject<int>() would return 0. This question is not merely an academic excercise. I have found numerous places where I could have used this but I cannot get the syntax right. Is this possible? Are there any libraries which provide this sort of functionality?

    Read the article

  • Call Generic method using runtime type and cast return object

    - by markpirvine
    I'm using reflection to call a generic method with a type determined at runtime. My code is as follows: Type tType = Type.GetType(pLoadOut.Type); MethodInfo method = typeof(ApiSerialiseHelper).GetMethod("Deserialise", new Type[] { typeof(string) }); MethodInfo generic = method.MakeGenericMethod(tType); generic.Invoke(obj, new object[] { pLoadOut.Data }); This works ok. However the generic.Invoke method returns an object, but what I would like is the type determined at runtime. Is this possible with this approach, or is there a better option? Mark

    Read the article

  • Can't find generic USB audio driver for a Samson COU1 USB microphone

    - by marcipollo
    I am unable to use a Samson USB CO1U microphone on a PC running XP, SP3. When I plug it into the USB port, Windows generates the sound indicating that it has found new hardware, and the green LED on the mic lights. But, it does not work, and the device manager reports that it cannot find a driver after searching. The same mic works on a Vista machine. Samson has no driver on their Web site, and insists that the generic audio driver in Windows should work. (http://www.samsontech.com/PRODUCTS/productpage.cfm?prodID=1810). I cannot find a generic USB audio driver at Microsoft.com. Can anyone help? Larry

    Read the article

  • Can't find generic USB audio driver for a Samson COU1 USB microphone

    - by user10321
    I am unable to use a Samson USB CO1U microphone on a PC running XP, SP3. When I plug it into the USB port, Windows generates the sound indicating that it has found new hardware, and the green LED on the mic lights. But, it does not work, and the device manager reports that it cannot find a driver after searching. The same mic works on a Vista machine. Samson has no driver on their Web site, and insists that the generic audio driver in Windows should work. (http://www.samsontech.com/PRODUCTS/productpage.cfm?prodID=1810). I cannot find a generic USB audio driver at Microsoft.com. Can anyone help? Larry

    Read the article

  • Generic Windows 98 USB Drive drivers?

    - by Electrons_Ahoy
    I've got an old Win98 machine that I'd like to pull some data off of. (Tens of gigs of data, actually.) The machine still runs fine, but due to the age, it doesn't have a cd burner, and the pre-NT networking won't connect to SMB shares without a fair amount of wrenching on the registry that I don't really want to do. What I really want to do is plug in an external USB hard drive and copy the files. But - Win98 didn't ship with generic USB drive drivers, and external drives don't ship with them these days. Can anyone point me at a reputable generic driver I can install?

    Read the article

  • How to use method hiding (new) with generic constrained class

    - by ongle
    I have a container class that has a generic parameter which is constrained to some base class. The type supplied to the generic is a sub of the base class constraint. The sub class uses method hiding (new) to change the behavior of a method from the base class (no, I can't make it virtual as it is not my code). My problem is that the 'new' methods do not get called, the compiler seems to consider the supplied type to be the base class, not the sub, as if I had upcast it to the base. Clearly I am misunderstanding something fundamental here. I thought that the generic where T: xxx was a constraint, not an upcast type. This sample code basically demonstrates what I'm talking about. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericPartialTest { class ContextBase { public string GetValue() { return "I am Context Base: " + this.GetType().Name; } public string GetOtherValue() { return "I am Context Base: " + this.GetType().Name; } } partial class ContextSub : ContextBase { public new string GetValue() { return "I am Context Sub: " + this.GetType().Name; } } partial class ContextSub { public new string GetOtherValue() { return "I am Context Sub: " + this.GetType().Name; } } class Container<T> where T: ContextBase, new() { private T _context = new T(); public string GetValue() { return this._context.GetValue(); } public string GetOtherValue() { return this._context.GetOtherValue(); } } class Program { static void Main(string[] args) { Console.WriteLine("Simple"); ContextBase myBase = new ContextBase(); ContextSub mySub = new ContextSub(); Console.WriteLine(myBase.GetValue()); Console.WriteLine(myBase.GetOtherValue()); Console.WriteLine(mySub.GetValue()); Console.WriteLine(mySub.GetOtherValue()); Console.WriteLine("Generic Container"); Container<ContextBase> myContainerBase = new Container<ContextBase>(); Container<ContextSub> myContainerSub = new Container<ContextSub>(); Console.WriteLine(myContainerBase.GetValue()); Console.WriteLine(myContainerBase.GetOtherValue()); Console.WriteLine(myContainerSub.GetValue()); Console.WriteLine(myContainerSub.GetOtherValue()); Console.ReadKey(); } } }

    Read the article

  • Windows Azure Directory Sync Generic Failure

    - by Armand
    Ok so I have a domain that I want to sync to Office365 but when I start the Windows Azure Active Directory Sync tool Configuration Wizard I get an error with the following details: System.Management.ManagementException: Generic failure at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext() at Microsoft.Online.DirSync.Common.MiisAction.GetTargetMA() at Microsoft.Online.DirSync.Common.MiisAction.IsSyncInProgress() at Microsoft.Online.DirSync.Common.PrerequisiteChecks.ThrowIfSyncInProgress() at Microsoft.Online.DirSync.UI.IntroductionWizardPage.PrerequisiteValidation() at Microsoft.Online.DirSync.UI.IntroductionWizardPage.OnLoad(EventArgs e) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) I have searched far and wide to no avail, this happens before I can even enter any details. A few notes: The server is not the domain controller Sharepoint 2013 is installed on this server The account I log in with and run the application with is a domain and enterprise admin I right click and run as administrator when I start the application So when I click continue on the error and go through the steps I get two possible scenarios that change from time to time at now predictable rate: 1) I just get an error, generic failure. 2) I get an error "Cannot start service MSOnlineSyncScheduler on computer '.'." Any help?

    Read the article

  • How can I update generic non-pnp monitor?

    - by njk
    Background I've been running a KVM switch with my monitor at 1920 x 1080 over VGA for over a year. Did a Windows Update on 12/11/12 which did the following: Update for Windows 7 for x64-based Systems (KB2779562) Security Update for Windows 7 for x64-based Systems (KB2779030) Cumulative Security Update for Internet Explorer 8 for Windows 7 for x64-based Systems (KB2761465) Windows Malicious Software Removal Tool x64 - December 2012 (KB890830) Security Update for Windows 7 for x64-based Systems (KB2753842) Security Update for Windows 7 for x64-based Systems (KB2758857) Security Update for Windows 7 for x64-based Systems (KB2770660) After a restart, my extended monitor was dark. I attempted to reset the extended display configuration, and noticed my monitor was being detected as a Generic Non-PnP Monitor: I uninstalled, downloaded new, and re-installed display drivers. Nothing. I attempted to unplug my monitor from the power for 15 minutes. Nothing. I followed some of the suggestions on this thread; specifically DanM's which suggested to create a new *.inf file and replace that in Device Manager. Device Manager said the "best driver software for your device is already installed". The only thing that works is when the monitor is directly attached to the laptop. This obviously is not what I want. My thought is to somehow remove the Generic Non-PnP Monitor from registry. How would I accomplish this and would this help? Any other suggestions? Relevant Hardware ASUS VE276 Monitor TRENDnet 2-Port USB KVM Switch (TK-207K) HP Laptop w/ ATI Radeon HD 4200 Screens

    Read the article

  • Compile error on inheritance of generic inner class extending with bounds

    - by Arne Burmeister
    I have a problem when compiling a generic class with an inner class. The class extends a generic class, the inner class also. Here the interface implemented: public interface IndexIterator<Element> extends Iterator<Element> { ... } The generic super class: public abstract class CompoundCollection<Element, Part extends Collection<Element>> implements Collection<Element> { ... protected class CompoundIterator<Iter extends Iterator<Element>> extends ImmutableIterator<Element> { ... } } The generic subclass with the compiler error: public class CompoundList<Element> extends CompoundCollection<Element, List<Element>> implements List<Element> { ... private class CompoundIndexIterator extends CompoundIterator<IndexIterator<Element>> implements IndexIterator<Element> { ... } } The error is: type parameter diergo.collect.IndexIterator<Element> is not within its bound extends CompoundIterator<IndexIterator<Element>> ^ What is wrong? The code compiles with eclipse, but bot with java 5 compiler (I use ant with java 5 on a mac and eclipse 3.5). No, I cannot convert it to a static inner class.

    Read the article

  • .NET EventHandlers - Generic or no?

    - by Chris Marasti-Georg
    Every time I start in deep in a C# project, I end up with lots of events that really just need to pass a single item. I stick with the EventHandler/EventArgs practice, but what I like to do is have something like: public delegate void EventHandler<T>(object src, EventArgs<T> args); public class EventArgs<T>: EventArgs { private T item; public EventArgs(T item) { this.item = item; } public T Item { get { return item; } } } Later, I can have my public event EventHandler<Foo> FooChanged; public event EventHandler<Bar> BarChanged; However, it seems that the standard for .NET is to create a new delegate and EventArgs subclass for each type of event. Is there something wrong with my generic approach? EDIT: The reason for this post is that I just re-created this in a new project, and wanted to make sure it was ok. Actually, I was re-creating it as I posted. I found that there is a generic EventHandler<TEventArgs, so you don't need to create the generic delegate, but you still need the generic EventArgs<T class, because TEventArgs: EventArgs. Another EDIT: One downside (to me) of the built-in solution is the extra verbosity: public event EventHandler<EventArgs<Foo>> FooChanged; vs. public event EventHandler<Foo> FooChanged; It can be a pain for clients to register for your events though, because the System namespace is imported by default, so they have to manually seek out your namespace, even with a fancy tool like Resharper... Anyone have any ideas pertaining to that?

    Read the article

  • Register and Resolve Generic Interfaces Unity

    - by user1643791
    I am trying to register some generic interfaces and resolve them . I have the registering function private static void RegisterFolderAssemblies(Type t,string folder) { var scanner = new FolderGenericInterfaceScanner(); var scanned = scanner.Scan(t,folder); // gets the implementations from a specific folder scanned.ForEach(concrete => { if (concrete.BaseType != null || concrete.IsGenericType) { myContainer.RegisterType(t, Type.GetType(concrete.AssemblyQualifiedName), concrete.AssemblyQualifiedName); } }); } which is called by the bootstrapper with RegisterFolderAssemblies(typeof(IConfigurationVerification<>),Environment.CurrentDirectory); The registration seem to go through ok but when I try to Resolve them with Type generic = typeof(IConfigurationVerification<>); Type specific = generic.MakeGenericType(input.Arguments[0].GetType()); var verifications = BootStrap.ResolveAll(specific); The input.Arguments[0] is an object of the type the generic is implemented in I also tried using typeof(IConfigurationVerification<) instead and get the same error . When ResolveAll is public static List<object> ResolveAll(Type t) { return myContainer.ResolveAll(t).ToList(); } I get a ResolutionFailedException with them message "The current type, Infrastructure.Interfaces.IConfigurationVerification`1[Infrastructure.Configuration.IMLogPlayerConfiguration+LoadDefinitions], is an interface and cannot be constructed. Are you missing a type mapping?" Any help will be great. Thanks in advance

    Read the article

  • JPA joined column allow every value...

    - by Fabio Beoni
    I'm testing JPA, in a simple case File/FileVersions tables (Master/Details), with OneToMany relation, I have this problem: in FileVersions table, the field "file_id" (responsable for the relation with File table) accepts every values, not only values from File table. How can I use the JPA mapping to limit the input in FileVersion.file_id only for values existing in File.id? My class are File and FileVersion: FILE CLASS @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="FILE_ID") private Long id; @Column(name="NAME", nullable = false, length = 30) private String name; //RELATIONS ------------------------------------------- @OneToMany(mappedBy="file", fetch=FetchType.EAGER) private Collection <FileVersion> fileVersionsList; //----------------------------------------------------- FILEVERSION CLASS @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="VERSION_ID") private Long id; @Column(name="FILENAME", nullable = false, length = 255) private String fileName; @Column(name="NOTES", nullable = false, length = 200) private String notes; //RELATIONS ------------------------------------------- @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="FILE_ID", referencedColumnName="FILE_ID", nullable=false) private File file; //----------------------------------------------------- and this is the FILEVERSION TABLE CREATE TABLE `JPA-Support`.`FILEVERSION` ( `VERSION_ID` bigint(20) NOT NULL AUTO_INCREMENT, `FILENAME` varchar(255) NOT NULL, `NOTES` varchar(200) NOT NULL, `FILE_ID` bigint(20) NOT NULL, PRIMARY KEY (`VERSION_ID`), KEY `FK_FILEVERSION_FILE_ID` (`FILE_ID`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

    Read the article

  • Device driver with generic communication media layer

    - by Tom
    Greetings all, I'm trying to implement driver for an embedded device with generic communication media layer. Not sure what is the best way to do it so I'm seeking an advice from more experienced stackoverflow users:). Basically we've got devices around the country communicating with our head office. Usual form of communication is over TCP/IP, but could be also using usb, RF dongle, IR, etc. The plan is to have object corresponding with each of these devices, handling the proprietary protocol on one side and requests/responses from other internal systems on the other. The thing is how create something generic in between the media and the handling objects. I had a play around with the TCP dispatcher using boost.asio but trying to create something generic seems like a nightmare :). Anybody tried to do something like that? What is the best way how to do it? Cheers, Tom

    Read the article

  • Value is out of Range Exception While setting ResourceDictionary Source to CustomControl's generic.X

    - by Subhen
    Hi, I have a custom Control which contains the generic.xaml inside the Themes folder. I have set the build action to Resource. Now from App.xaml I am setting the reference to the DLL by using : xmlns:localFolder="clr-namespace:customControl;assembly=customControl" After the reference is set I am trying to Merge the Resource dictionary in my App.xaml as follow: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="localFolder;component/Themes/generic.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> But while running my application I am getting the following XAMLParseException: Attribute localFolder;component/Themes/generic.xaml value is out of range. [Line: 16 Position: 44]

    Read the article

  • Is it possible to define a generic lambda?

    - by Mike OBrien
    I have some logic in a method that operates on a specified type and I'd like to create a generic lambda that encapsulates the logic. This is the spirit of what I'm trying to do: public void DoSomething() { // ... Func<T> GetTypeName = () => T.GetType().Name; GetTypeName<string>(); GetTypeName<DateTime>(); GetTypeName<int>(); // ... } I know I can pass the type as a parameter or create a generic method but I'm interested if it can just be a generic lambda (So I'm not looking for alternatives). From what I can tell C# 3.0 doesn't support this. TIA, m

    Read the article

  • List of generic algorithms and data structures

    - by Jake Petroules
    As part of a library project, I want to include a plethora of generic algorithms and data structures. This includes algorithms for searching and sorting, data structures like linked lists and binary trees, path-finding algorithms like A*... the works. Basically, any generic algorithm or data structure you can think of that you think might be useful in such a library, please post or add it to the list. Thanks! (NOTE: Because there is no single right answer I've of course placed this in community wiki... and also, please don't suggest algorithms which are too specialized to be provided by a generic library) The List: Data structures AVL tree B-tree B*-tree B+-tree Binary tree Binary heap Binary search tree Linked lists Singly linked list Doubly linked list Stack Queue Sorting algorithms Binary tree sort Bubble sort Heapsort Insertion sort Merge sort Quicksort Selection sort Searching algorithms

    Read the article

  • Type patterns and generic classes in Haskell

    - by finnsson
    I'm trying to understand type patterns and generic classes in Haskell but can't seem to get it. Could someone explain it in laymen's terms? In [1] I've read that "To apply functions generically to all data types, we view data types in a uniform manner: except for basic predefined types such as Float, IO, and ?, every Haskell data type can be viewed as a labeled sum of possibly labeled products." and then Unit, :*: and :+: are mentioned. Are all data types in Haskell automatically versions of the above mentioned and if so how do I figure out how a specific data type is represented in terms of :*:, etc? The users guide for generic classes (ch. 7.16) at haskell.org doesn't mention the predefined types but shouldn't they be handled in every function if the type patterns should be exhaustive? [1] Comparing Approaches to Generic Programming in Haskell, Ralf Hinze, Johan Jeuring, and Andres Löh

    Read the article

  • Pass a captured named regular expression to URL dictionary in generic view

    - by Trent Jurewicz
    I am working with a generic view in Django. I want to capture a named group parameter in the URL and pass the value to the URL pattern dictionary. For example, in the URLConf below, I want to capture the parent_slug value in the URL and pass it to the queryset dictionary value like so: urlpatterns = patterns('django.views.generic.list_detail', (r'^(?P<parent_slugs>[-\w])$', 'object_list', {'queryset':Promotion.objects.filter(category=parent_slug)}, 'promo_promotion_list'), ) Is this possible to do in one URLConf entry, or would it be wiser if I create a custom view to capture the value and pass the queryset directly to the generic view from my overridden view?

    Read the article

  • How to invoke a method with a generic return type using reflection

    - by Andre Luus
    Hi there! I'm trying to invoke a method with reflection that has a generic return type, like this: public class SomeClass<T> { public List<T> GetStuff(); } I get an instance of SomeClass with a call to a Repository's GetClass<T> generic method. MethodInfo lGetSomeClassMethodInfo = typeof(IRepository) .GetMethod("GetClass") .MakeGenericMethod(typeof(SomeClass<>); object lSomeClassInstance = lGetSomeClassMethodInfo.Invoke( lRepositoryInstance, null); After that, I this is where I try to invoke the GetStuff method: typeof(SomeClass<>).GetMethod("GetStuff").Invoke(lSomeClassInstance, null) I get an exception about the fact that the method has generic arguments. However, I can't use MakeGenericMethod to resolve the return type. Also, if instead of typeof(SomeClass<>) I use lSomeClassInstance.GetType() (which should have resolved types) GetMethod("GetStuff") returns null! UPDATE I have found the solution and will post the answer shortly.

    Read the article

  • Dynamically find the parameter to be passed as <T> to a generic method

    - by Codex
    A generic method is defined as follows: private static T GetComparisonObject<T>(ComparisonAttribute attribute, object objectToParse) { // Perform a some action return (T)resultObject; } The method is invoked as follows: var srcObjectToCompare = GetComparisonObject<DynamicType>(attributeToCompare, srcObject); The type for which the method needs to be invoked is configured in the config file as: <add attributename ="Count" attributetype ="MemberInformation" attributeparam ="Count" type="System.Int32" comparertype="ditCreditEMGTestAutomationDifferenceEngine.Comparers.TypeComparer, ditCreditEMGTestAutomationDifferenceEngine.dll" /> The token that is passed in < for the generic methods has to be the type for which the method is being invoked. From the type key configuration in the XML, an instance of Type represnting the type can be created{i.e. Type.GetType("System.Int32")}, but how can the Type Definition be generated which can then be passed to the the Generic method? Hope am not missing something elementary here!! :-O Thanks in advance.

    Read the article

  • C# - Dictionary with generic array as value

    - by alhazen
    In my class, I want to use a dictionary with the following declaration: Dictionary<string, T[]> Since the operations of my class are exactly the same for all generic types, I do not wish to define my class as generic (which means I would have to create a separate instance of my class for each generic type I insert into the dictionary ?). One alternative I'm attempting is to use Dictionary<string, object> instead: public void Add<T>(string str, T value) { // Assuming key already exists var array = (T[]) dictionary[str]; array[0] = value; } However, when iterating over the dictionary, how do I cast the object value back to an array ? foreach(string strKey in dictionary.Keys) { var array = (T[]) dictionary[strKey]; // How to cast here ? //... array[0] = default(T); } Thanks.

    Read the article

  • Generic XML parser in Silverlight 3.0

    - by Ummar
    Hi I am developing an application in Silverlight 3.0, I want to make a generic parser of XML in it, as on every call to webservice I am receiving a different XML, I want to make it generic so that I receive an XML in native datastructure of C#? Please help me out? like I am getting XML like this one time <test> <node1></node1> <node2></node2> </test> and other time <mytest> <application name="XYZ">My Application</application> <application name="ABC">My Application</application> </mytest> I want the generic parser, e.g. it makes some tree structure of whole XML

    Read the article

  • Generic Post Script driver for Windows Vista x64?

    - by Rick
    I have an old HP parallel port printer that is not supported by Vista. No drivers I've found online work with it. As a last ditch effort, I was hoping to find some generic postscript drivers for Vista x64 in the hopes that the printer will accept those commands. Does anyone know where I could come by such drivers?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >