Search Results

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

Page 163/255 | < Previous Page | 159 160 161 162 163 164 165 166 167 168 169 170  | Next Page >

  • Activator.CreateInstance(string) and Activator.CreateInstance<T>() difference

    - by Juan Manuel Formoso
    No, this is not a question about generics. I have a Factory pattern with several classes with internal constructors (I don't want them being instantiated if not through the factory). My problem is that CreateInstance fails with a "No parameterless constructor defined for this object" error unless I pass "true" on the non-public parameter. Example // Fails Activator.CreateInstance(type); // Works Activator.CreateInstance(type, true); I wanted to make the factory generic to make it a little simpler, like this: public class GenericFactory<T> where T : MyAbstractType { public static T GetInstance() { return Activator.CreateInstance<T>(); } } However, I was unable to find how to pass that "true" parameter for it to accept non-public constructors (internal). Did I miss something or it isn't possible?

    Read the article

  • Is google gson running on android?

    - by Janusz
    I'm playing arround with google gson for communication with my web back end at the moment. This and this older posts indicate that there are some problems with gson on android. I did some easy tests on the device already but maybe I just missed the bug. Edit I'm now parsing a lot more data. Generic lists etc. still not encountered the bug. Has anybody used gson on Android already? How does it work? Has somebody encountered bugs or something that will stop me from using it once it gets more complicated?

    Read the article

  • Data Model Evolution

    - by redleafong
    Hey guys, When writing code I am seeing requirements to change data models (e.g. adding/changing/removing data members from a class). When these data models belong to an interface, it seems difficult to change without breaking the existing client codes. So I am wondering if there is any best practice of designing interfaces/data models in a way to minimize the impact during evolution. The closest thing I can find from google is data contract versioning. But that seems to be a .net specific topic. I am wondering if the same practice applies to the Java world, or there is a different or generic way to deal with data model evolution. Thanks

    Read the article

  • Selecting an element based on class and id in jquery - similar to an SQL query

    - by Ankur
    I want to select an element based on it's class and id, I have seen many similar questions on SO. Most of the users ask why would you ever want to do this - which is not very helpful, trust me, this is the simplest way of solving my UI problem, and it's a very unique and intereting UI related to making generic triple stores easily browsable. At the moment the jQUery looks like this: $(document).ready( function() { $(".predicates").hide(); $(".objects").hide(); $("#subject").click( function() { $("#predId, .predicates").toggle(); // this line } ); $("#predId").click( function() { $("#objId, .objects").toggle(); } ); }); The line I am really interested in is this $("#predId, .predicates").toggle(); how do I get the select to ensure that both #predId and .predicates are true, at the moment it seems that only one or the other has to be true. Is there something like an && operator?

    Read the article

  • Taming the malloc/free beast -- tips & tricks

    - by roufamatic
    I've been using C on some projects for a master's degree but have never built production software with it. (.NET & Javascript are my bread and butter.) Obviously, the need to free() memory that you malloc() is critical in C. This is fine, well and good if you can do both in one routine. But as programs grow, and structs deepen, keeping track of what's been malloc'd where and what's appropriate to free gets harder and harder. I've looked around on the interwebs and only found a few generic recommendations for this. What I suspect is that some of you long-time C coders have come up with your own patterns and practices to simplify this process and keep the evil in front of you. So: how do you recommend structuring your C programs to keep dynamic allocations from becoming memory leaks?

    Read the article

  • Unchecked call to compareTo

    - by Dave Jarvis
    Background Create a Map that can be sorted by value. Problem The code executes as expected, but does not compile cleanly: http://pastebin.com/bWhbHQmT The syntax for passing Comparable as a generic parameter along to the Map.Entry<K, V> (where V must be Comparable?) -- so that the (Comparable) typecast shown in the warning can be dropped -- eludes me. Warning Compiler's cantankerous complaint: SortableValueMap.java:24: warning: [unchecked] unchecked call to compareTo(T) as a member of the raw type java.lang.Comparable return ((Comparable)entry1.getValue()).compareTo( entry2.getValue() ); Question How can the code be changed to compile without any warnings (without suppressing them while compiling with -Xlint:unchecked)? Related TreeMap sort by value How to sort a Map on the values in Java? http://paaloliver.wordpress.com/2006/01/24/sorting-maps-in-java/ Thank you!

    Read the article

  • Good learning resources for JNDI implementation (JBoss 5)

    - by iandisme
    I have been working with JavaEE/EJB3 web apps for about half a year now. Until recently, I haven't had to touch a lot of the behind-the-scenes stuff, just the meat of the code. I have been wrestling with JNDI problems, and though I've solved a couple of them, I'm pretty much just doing the whole cargo cult copy-paste routine. It would really help me to better understand JNDI; my understanding of it right now can be summarized as "it's that thing these classes sometimes do to find other classes." My question is, has anyone had success learning JNDI/EJB3/related topics from a book or online content? I've googled for it but the stuff that comes up is old or specific to a certain framework I'm not using. I'm looking for something that's either JBoss-specific or generic enough to be useful anyway.

    Read the article

  • drupal bootstrap script: how to get list of all nodes of type x?

    - by groovehunter
    hi. I create a custom import and export, at the moment as an external script (via bootstrap), i plan to create a module in a more generic fashion lateron. I am building a frontend for nagios and for our host management and nagios configuration btw. Maybe it might become useful for other environments (networkmanagement) Now i need to know how to get list of all nodes of type x? I want to avoid direct SQL. A suggestion i got was to make an rss and parse it but i acess the drupal db a dozen times to extract various nodes, so it feels strange to do a web request for one thing So what i am looking for as newbie drupal dev is just a pointer to basic search module api for this task TIA florian

    Read the article

  • Differences between WPF Custom Control Library and plain Class Library?

    - by David Veeneman
    I posted a question a few months ago about sharing resource dictionaries across assemblies. It turns out you can do that using the Component Resource Key markup extension. At the time, I could only get it working with a WPF Custom Control project, not with a plain Class Library project. Now I need to use an existing plain Class Library project to host a shared resource dictionary. That means I need to retrofit the Class Library project to support the Component Resource Key markup extension. I have added a Themes folder and a Generic.xaml resource dictionary document to the Class Library project, as well as references to PresentationCore, PresentationFramework, and WindowsBase. Unfortunately, that doesn't seem to do the trick. So, here is my question: Other than the above, what does a WPF Custom Control Library project have that a plain Class Library project doesn't? Or, to put it another way, what else could I add to my class library project to get this feature working? Thanks.

    Read the article

  • Adding two Set[Any]

    - by Alex Boisvert
    Adding two Set[Int] works: Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Server VM, Java 1.6.0_23). Type in expressions to have them evaluated. Type :help for more information. scala> Set(1,2,3) ++ Set(4,5,6) res0: scala.collection.immutable.Set[Int] = Set(4, 5, 6, 1, 2, 3) But adding two Set[Any] doesn't: scala> Set[Any](1,2,3) ++ Set[Any](4,5,6) <console>:6: error: ambiguous reference to overloaded definition, both method ++ in trait Addable of type (xs: scala.collection.TraversableOnce[Any])scala.collection.immutable.Set[Any] and method ++ in trait TraversableLike of type [B >: Any,That](that: scala.collection.TraversableOnce[B])(implicit bf: scala.collection.generic.CanBuildFrom[scala.collection.immutable.Set[Any],B,That])That match argument types (scala.collection.immutable.Set[Any]) Set[Any](1,2,3) ++ Set[Any](4,5,6) ^ Any suggestion to work around this error?

    Read the article

  • Can't Instantiate Windsor Custom Component Activator

    - by jeffn825
    Hi, I'm getting an exception calling Resolve: KernelException: Could not instantiate custom activator Inner Exception: {"Constructor on type 'MyProj.MyAdapter`1[[MyProj.MyBusinessObject, MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' not found."} There's definitely a public parameterless constructor there (and I've verified this using reflection at runtime)...so I figure the problem might have to do with the fact that it's generic? I've tried getting the component model object and setting RequiresGenericArguments to true, but that hasn't gotten me anywhere. Any help would be much appreciated! Thanks.

    Read the article

  • geographic location uri scheme

    - by diciu
    I'd like to use a URI scheme to enable the users of one of my apps to share geographic locations. I don't want to invent my own URI scheme and "geo" seems the most appropriate but there are only two Internet Drafts on the subject (draft-mayrhofer-geo-uri-01, draft-mayrhofer-geo-uri-02), both expired and wildly different in the way they approach the standard. Is there an URI that's suited for encoding latitude and longitude and that made it as an RFC? Should I use a generic URI such as the tag URI scheme?

    Read the article

  • Generics and Exposing .Net Types For COM Consumers?

    - by IbrarMumtaz
    I remember seeing a question on my official MS 70-536 exam that talked about a simple class that was designed to be exposed for COM calling clients and etc. of all the members defined in the classes I chose the answer D. The one that used a generic. My question to you guys is this: If you were designing a .net custom type that was to be eventually consumed by a com caller or a com type .... of all the guidelines I have read on this subject. Generics is the one .Net topic I would not include in a class for this purpose I would omit such a data member or use something else? Am I right in thinking this. As soon as I saw this question I knew it was generics but I can't seem to prove it. Surely I did not make this up ... generics is a .net feature right?

    Read the article

  • Is it OK to open a DB4o file for query, insert, update multiple times?

    - by Khnle
    This is the way I am thinking of using DB4o. When I need to query, I would open the file, read and close: using (IObjectContainer db = Db4oFactory.OpenFile(Db4oFactory.NewConfiguration(), YapFileName)) { try { List<Pilot> pilots = db.Query<Pilot>().ToList<Pilot>(); } finally { try { db.Close(); } catch (Exception) { }; } } At some later time, when I need to insert, then using (IObjectContainer db = Db4oFactory.OpenFile(Db4oFactory.NewConfiguration(), YapFileName)) { try { Pilot pilot1 = new Pilot("Michael Schumacher", 100); db.Store(pilot1); } finally { try { db.Close(); } catch (Exception) { }; } } In this way, I thought I will keep the file more tidy by only having it open when needed, and have it closed most of the time. But I keep getting InvalidCastException Unable to cast object of type 'Db4objects.Db4o.Reflect.Generic.GenericObject' to type 'Pilot' What's the correct way to use DB4o?

    Read the article

  • Recreating a Dictionary from an IEnumerable

    - by learnerplates
    But some of the callers is the Dictionary's TryGetValue and ContainsKey and so require the result of the method to be a Dictionary, how can I convert the IEnumerable into a Dictionary so that I can use TryGetValue ? I've a method which at present returns an IEnumerable. I want to make it more generic by making it return an IEnumerable. method: public IEnumerable<KeyValuePair<string, ArrayList>> GetComponents() { // ... yield return new KeyValuePair<string, ArrayList>(t.Name, controlInformation); } caller: Dictionary<string, ArrayList> actual = target.GetComponents(); actual.ContainsKey("something");

    Read the article

  • Multiple classes in a Python module

    - by ralphL
    I'm very new to Python (I'm coming from a JAVA background) and I'm wondering if anyone could help me with some of the Python standards. Is it a normal or "proper" practice to put multiple class in a module? I have been working with Django and started with the tutorials and they place their database model classes in the same module. Is this something that is normally done or should I stick with 1 class per module? Is their a reason I would do one over the other? Hope I'm being clear and not to generic. Thanks to everyone in advance!

    Read the article

  • Why does LINQ-to-SQL Paging fail inside a function?

    - by ssg
    Here I have an arbitrary IEnumerable<T>. And I'd like to page it using a generic helper function instead of writing Skip/Take pairs every time. Here is my function: IEnumerable<T> GetPagedResults<T>(IEnumerable<T> query, int pageIndex, int pageSize) { return query.Skip((pageIndex - 1) * pageSize).Take(pageSize); } And my code is: result = GetPagedResults(query, 1, 10).ToList(); This produces a SELECT statement without TOP 10 keyword. But this code below produces the SELECT with it: result = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); What am I doing wrong in the function?

    Read the article

  • C# simpler run time generics

    - by Hellfrost
    Is there a way to invoke a generic function with a type known only at run time? I'm trying to do something like: static void bar() { object b = 6; string c = foo<typeof(b)>(); } static string foo<T>() { return typeof (T).Name; } Basically I want to decide on the type parameter only at run time, but the function I'm calling depends on the type parameter. Also I know this can be done with reflections... but it's not the nicest solution to the problem... I'm sort of looking for dynamic features in C#...

    Read the article

  • Xcode 4: deleting items in Build Settings

    - by occulus
    In XCode 4.0 there's a newly designed Build Settings page. My problem is that I can't see how to remove a setting once I've specified it. Example: I've changed "Versioning System" to "Apple Generic" at the target level. Afterwards I realised I should set it at the project level, and so I want to delete the target level setting. However, there's no way I can see to remove the setting -- you click on it and there's two options, neither of which is the default "not specified" empty setting. Hitting the delete key on the keyboard nothing. The same goes for fields that accept text -- if I try to delete a setting by just deleting all the text set, it still shows that field in green, but with no text in it, and regards it as the presence of a setting.

    Read the article

  • Are multiply-thrown Exceptions checked or runtime?

    - by froadie
    I have an Exception chain in which method1 throws an Exception to method2 which throws the Exception on to main. For some reason, the compiler forces me to deal with the error in method2 and marks it as an error if I don't, indicating that it's a checked Exception. But when the same Exception is thrown further down the line to main, the compiler allows me to ignore it and doesn't display any errors. The original Exception in method1 is a ParseException, which is checked. But the method has a generic throws Exception clause in the header, and the same object is thrown to method2, which has an identical throws Exception clause. When and how does this Exception lose the status of being checked / caught by the compiler? Edited to clarify: public void method1() throws Exception{ // code that may generate ParseException } public void method2() throws Exception{ method1(); //compiler error } public static void main(String[] args){ method2(); //ignored by compiler }

    Read the article

  • Refresh layout while filling it

    - by neutrino
    Hi guys, I have an activity with a HorizontalScrollView. When it opens, I start filling this view (or rather, a container layout inside it) with another views. This is done from another thread by using handler.post. The views are added in bunches of 15, and when there are no more views to add, I start updating them with new data (this is a kind of streaming data from a server). The problem is that the scrollview is empty until all of the views are added. As soon as they are all added and start updating, the scrollview gets drawn. How do I refresh it in the process of adding views? I don't want the screen to be empty for 3 seconds while all of the views are added. Thanks a lot. UPDATE: turned out this problem is not specific for HorizontalScrollView, this is the case for any generic layout.

    Read the article

  • Why should I use a container div in HTML?

    - by lara.robertson
    I am currently learning html/css, and have noticed a common technique is to place a generic container div in the root of the body tag: <html> <head> ... </head> <body> <div id="container"> ... </div> </body> </html> Is there a valid reason for doing this? Why can't the css just reference the body tag?

    Read the article

  • NHibernate and SetSessionAuth audit columns

    - by user86431
    We have audit columns set by triggers. For obscure security reasons predating my tenure and out of my control, we log in with a generic user, and do a 'set session authorization' to change the user to the db user of the user who is logged in. When we converted to NHibernate, it creates a whole new session and jacks everything up when we try to do a set session auth, so we turned the set session auth off... Now we are trying to find out a way to get NHibernate to let us do 'set session authorization' without recycling the session on us, so we can use our existing trigger based audit column stuff with both legacy apps, and our new NHibernate apps. It's not a ideal soloution, or the best way to do it even, but is it possible? I was hoping there was a alternate interface that allowed this kind of access. Does anyone know how to do it, or can you point me towards and good hints? Thanks, Eric-

    Read the article

  • Graph diffing and versioning tool

    - by hashable
    I am working with a team that edits large DAGs represented as single files. Currently we are unable to work with multiple users concurrently modifying the DAG. Is there a tool (somewhat like the Eclipse SVN plugin) that can do do revision control on the file (manage timestamps/revision stamps) to identify incoming/outgoing/conflicting changes (Node/Link insertion/deletion/modification) and merge changes just like programmers do with source code files? The system should be able to do dependency management also. E.g. an incoming Link must not be accepted when one of the two Nodes is absent. That is, it should not "break" the existing DAG by allowing partial updates. If there is a framework to do this using generic "Node" and "Link" interfaces? Note: I am aware of Protege and its plugins. They currently do not satisfy my requirements.

    Read the article

  • Segmentation fault when accessing a PHP page

    - by Justin Ethier
    Sometimes when one of our Apache web servers is restarted, we experience segmentation faults when any PHP page is subsequently accessed. The following line is printed in the httpd error_log: [Wed Jun 16 10:59:33 2010] [notice] child pid 31513 exit signal Segmentation fault (11) There will be one of these lines for each PHP page that is accessed. This appears to happen randomly - the "workaround" to-date is to restart httpd, which eventually fixes the problem (almost always after a single restart). Although we only see this happen rarely, it still happens frequently enough to be of concern. So my question is, why is this happening in the first place? Is this a known bug with the version of Apache / PHP / Linux / etc that we are using? Any ideas? The environment is: Fedora 11 Apache 2.2.15 (Default settings) PHP 5.2.13 I can provide more information if that would help narrow things down, since this error message is rather generic... Any help is appreciated.

    Read the article

< Previous Page | 159 160 161 162 163 164 165 166 167 168 169 170  | Next Page >