Search Results

Search found 1575 results on 63 pages for 'reflection'.

Page 22/63 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • How can I find out if two arguments are instances of the same, but unknown class?

    - by Ingmar
    Let us say we have a method which accepts two arguments o1 and o2 of type Object and returns a boolean value. I want this method to return true only when the arguments are instances of the same class, e.g.: foo(new Integer(4),new Integer(5)); Should return true, however: foo(new SomeClass(), new SubtypeSomeClass()); should return false and also: foo(new Integer(3),"zoo"); should return false. I believe one way is to compare the fully qualified class names: public boolean foo(Object o1, Object o2){ Class<? extends Object> c1 = o1.getClass(); Class<? extends Object> c2 = o2.getClass(); if(c1.getName().equals(c2.getName()){ return true;} return false; } An alternative conditional statement would be : if (c1.isAssignableFrom(c2) && c2.isAssignableFrom(c1)){ return true; } The latter alternative is rather slow. Are there other alternatives to this problem?

    Read the article

  • Custom Attributes on Class Members

    - by ccook
    I am using a Custom Attribute to define how a class's members are mapped to properties for posting as a form post (Payment Gateway). I have the custom attribute working just fine, and am able to get the attribute by "name", but would like to get the attribute by the member itself. For example: getFieldName("name"); vs getFieldName(obj.Name); The plan is to write a method to serialize the class with members into a postable string. Here's the test code I have at this point, where ret is a string and PropertyMapping is the custom attribute: foreach (MemberInfo i in (typeof(CustomClass)).GetMember("Name")) { foreach (object at in i.GetCustomAttributes(true)) { PropertyMapping map = at as PropertyMapping; if (map != null) { ret += map.FieldName; } } } Thanks in advance!

    Read the article

  • How to find the first declaring method for a reference method

    - by Oliver Gierke
    Suppose you have a generic interface and an implementation: public interface MyInterface<T> { void foo(T param); } public class MyImplementation<T> implements MyInterface<T> { void foo(T param) { } } These two types are frework types. In the next step I want allow users to extend that interface as well as redeclare foo(T param) to maybe equip it with further annotations. public interface MyExtendedInterface extends MyInterface<Bar> { @Override void foo(Bar param); // Further declared methods } I create an AOP proxy for the extended interface and intercept especially the calls to furtherly declared methods. As foo(…) is no redeclared in MyExtendedInterface I cannot execute it by simply invoking MethodInvocation.proceed() as the instance of MyImplementation only implements MyInterface.foo(…) and not MyExtendedInterface.foo(…). So is there a way to get access to the method that declared a method initially? Regarding this example is there a way to find out that foo(Bar param) was declared in MyInterface originally and get access to the accoriding Method instance? I already tried to scan base class methods to match by name and parameter types but that doesn't work out as generics pop in and MyImplementation.getMethod("foo", Bar.class) obviously throws a NoSuchMethodException. I already know that MyExtendedInterface types MyInterface to Bar. So If I could create some kind of "typed view" on MyImplementation my math algorithm could work out actually.

    Read the article

  • Comparing Nested object properties using C#

    - by Kumar
    I have a method which compares two objects and returns a list of all the property names which are different. public static IList<string> GetDifferingProperties(object source, object) { var sourceType = source.GetType(); var sourceProperties = sourceType.GetProperties(); var targetType = target.GetType(); var targetProperties = targetType.GetProperties(); var properties = (from s in sourceProperties from t in targetProperties where s.Name == t.Name && s.PropertyType == t.PropertyType && s.GetValue(source,null) != t.GetValue(target,null) select s.Name).ToList(); return properties; } For example if I have two classes as follows: public class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string City { get; set; } public string State { get; set; } public string Zip { get; set; } } public class Employee { public string FirstName { get; set; } public string MiddleName { get; set; } public string LastName { get; set; } public Address EmployeeAddress { get; set; } } I am trying to compare the following two employee instances: var emp1Address = new Address(); emp1Address.AddressLine1 = "Microsoft Corporation"; emp1Address.AddressLine2 = "One Microsoft Way"; emp1Address.City = "Redmond"; emp1Address.State = "WA"; emp1Address.Zip = "98052-6399"; var emp1 = new Employee(); emp1.FirstName = "Bill"; emp1.LastName = "Gates"; emp1.EmployeeAddress = emp1Address; var emp2Address = new Address(); emp2Address.AddressLine1 = "Gates Foundation"; emp2Address.AddressLine2 = "One Microsoft Way"; emp2Address.City = "Redmond"; emp2Address.State = "WA"; emp2Address.Zip = "98052-6399"; var emp2 = new Employee(); emp2.FirstName = "Melinda"; emp2.LastName = "Gates"; emp2.EmployeeAddress = emp2Address; So when I pass these two employee objects to my GetDifferingProperties method currently it returns FirstName and EmployeeAddress, but it does not tell me which exact property (which in this case is Address1) in the EmployeeAddress has changed. How can I tweak this method to get something like EmployeeAddress.Address1?

    Read the article

  • How can I bind events to strongly typed datasets of different types?

    My application contains several forms which consist of a strongly typed datagridview, a strongly typed bindingsource, and a strongly typed table adapter. I am using some code in each form to update the database whenever the user leaves the current row, shifts focus away from the datagrid or the form, or closes the form. This code is the same in each case, so I want to make a subclass of form, from which all of these forms can inherit. But the strongly typed data objects all inherit from component, which doesn't expose the events I want to bind to or the methods I want to invoke. The only way I can see of gaining access to the events is to use: Type(string Name).GetEvent(string EventName).AddEventHandler(object Target,Delegate Handler) Similarly, I want to call the Update method of the strongly typed table adapter, and am using Type(string Name).GetMethod(String name, Type[] params).Invoke(object target, object[] params). It works ok, but it seems very heavy handed. Is there a better way? Here is my code for the main class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; using System.ComponentModel; namespace MyApplication { public class AutoSaveDataGridForm: Form { private DataRow PreviousRow; public Component Adapter { private get; set; } private Component dataGridView; public Component DataGridView { private get { return dataGridView; } set { dataGridView = value; Type t = dataGridView.GetType(); t.GetEvent("Leave").AddEventHandler(dataGridView, new EventHandler(DataGridView_Leave)); } } private Component bindingSource; public Component BindingSource { private get { return bindingSource; } set { bindingSource = value; Type t = bindingSource.GetType(); t.GetEvent("PositionChanged").AddEventHandler(bindingSource, new EventHandler(BindingSource_PositionChanged)); } } protected void Save() { if (PreviousRow != null && PreviousRow.RowState != DataRowState.Unchanged) { Type t = Adapter.GetType(); t.GetMethod("Update", new Type[] { typeof(DataRow[]) }).Invoke(Adapter, new object[] { new DataRow[] { PreviousRow } }); } } private void BindingSource_PositionChanged(object sender, EventArgs e) { BindingSource bindingSource = sender as BindingSource; DataRowView CurrentRowView = bindingSource.Current as DataRowView; DataRow CurrentRow = CurrentRowView.Row; if (PreviousRow != null && PreviousRow != CurrentRow) { Save(); } PreviousRow = CurrentRow; } private void InitializeComponent() { this.SuspendLayout(); // // AutoSaveDataGridForm // this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AutoSaveDataGridForm_FormClosed); this.Leave += new System.EventHandler(this.AutoSaveDataGridForm_Leave); this.ResumeLayout(false); } private void DataGridView_Leave(object sender, EventArgs e) { Save(); } private void AutoSaveDataGridForm_FormClosed(object sender, FormClosedEventArgs e) { Save(); } private void AutoSaveDataGridForm_Leave(object sender, EventArgs e) { Save(); } } } And here is a (partial) form which implements it: public partial class FileTypesInherited :AutoSaveDataGridForm { public FileTypesInherited() { InitializeComponent(); } private void FileTypesInherited_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'sharedFoldersInformationV2DataSet.tblFileTypes' table. You can move, or remove it, as needed. this.tblFileTypesTableAdapter.Fill(this.sharedFoldersInformationV2DataSet.tblFileTypes); this.BindingSource = tblFileTypesBindingSource; this.Adapter = tblFileTypesTableAdapter; this.DataGridView = tblFileTypesDataGridView; } }

    Read the article

  • How does AssemblyName.ReferenceMatchesDefinition work?

    - by Fabian Schmied
    Given the following code: var n1 = new AssemblyName ("TestDll, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089"); var n2 = new AssemblyName ("TestDll, Version=2.0.0.2001, Culture=en-US, PublicKeyToken=ab7a5c561934e089"); Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n1, n2)); Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n2, n1)); Why do both of these checks print "True"? I would have thought that AssemblyName.ReferenceMatchesDefinition should consider differences in the version, culture, and public key token attributes of an assembly name, shouldn't they? If not, what does ReferenceMatchesDefinition do that a comparison of the simple names doesn't?

    Read the article

  • Change classloader

    - by Chris
    I'm trying to switch the class loader at runtime: public class Test { public static void main(String[] args) throws Exception { final InjectingClassLoader classLoader = new InjectingClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); Thread thread = new Thread("test") { public void run() { System.out.println("running..."); // approach 1 ClassLoader cl = TestProxy.class.getClassLoader(); try { Class c = classLoader.loadClass("classloader.TestProxy"); Object o = c.newInstance(); c.getMethod("test", new Class[] {}).invoke(o); } catch (Exception e) { e.printStackTrace(); } // approach 2 new TestProxy().test(); }; }; thread.setContextClassLoader(classLoader); thread.start(); } } and: public class TestProxy { public void test() { ClassLoader tcl = Thread.currentThread().getContextClassLoader(); ClassLoader ccl = ClassToLoad.class.getClassLoader(); ClassToLoad classToLoad = new ClassToLoad(); } } (it is not relevant what the InjectingClassLoader is) I'd like to make the result of "approach 1" and "approach 2" exactly same, but it looks like thread.setContextClassLoader(classLoader) does nothing and the "approach 2" always uses the system classloader (can be determined by comparing tcl and ccl variables while debugging). Is it possible to make all classes loaded by new thread use given classloader?

    Read the article

  • How can I get System.Type from "System.Drawing.Color" string

    - by jonny
    I have an xml stored property of some control <Prop Name="ForeColor" Type="System.Drawing.Color" Value="-16777216" /> I want to convert it back as others System.Type type = System.Type.GetType(propertyTypeString); object propertyObj = TypeDescriptor.GetConverter(type).ConvertFromString(propertyValueString); System.Type.GetType("System.Drawing.Color") returns null. The question is how one can correctly get color type from string (it will be better not to do a special case just for Color properties) Update from time to time this xml will be edited by hand

    Read the article

  • Delphi getting property value of a member from ClassType

    - by Kayode Yusuf
    I am implementing a Boilerplate feature - allow users to Change descriptions of some components - like Tlabels - at run time. e.g. TFooClass = Class ( TBaseClass) Label : Tlabel; ... End; Var FooClass : TFooClass; ... At Design time, the value Label's caption property is say - 'First Name', when the application is run, there is a feature that allows the user to change the caption value to say 'Other Name'. Once this is changed, the caption for the label for the class instance of FooClass is updated immediately. The problem now is if the user for whatever reason wants to revert back to the design time value of say 'First Name' , it seems impossible. I can use the RTTIContext methods and all that but I at the end of the day, it seems to require the instance of the class for me to change the value and since this has already being changed - I seem to to have hit a brick wall getting around it. My question is this - is there a way using the old RTTI methods or the new RTTIContext stuff to the property of a class' member without instantiating the class - i.e. getting the property from the ClassType definition. This is code snippet of my attempt at doing that : c : TRttiContext; z : TRttiInstanceType; w : TRttiProperty; Aform : Tform; .... Begin ..... Aform := Tform(FooClass); for vCount := 0 to AForm.ComponentCount-1 do begin vDummyComponent := AForm.Components[vCount]; if IsPublishedProp(vDummyComponent,'Caption') then begin c := TRttiContext.Create; try z := (c.GetType(vDummyComponent.ClassInfo) as TRttiInstanceType); w := z.GetProperty('Caption'); if w <> nil then Values[vOffset, 1] := w.GetValue(vDummyComponent.ClassType).AsString ..... ..... .... .... I am getting all sorts of errors and any help will be greatly appreciated.

    Read the article

  • Dynamic Method Creation

    - by TJMonk15
    So, I have been trying to research this all morning, and have had no luck. I am trying to find a way to dynamically create a method/delegate/lambda that returns a new instance of a certain class (not known until runtime) that inherits from a certain base class. I can guarantee the following about the unknown/dynamic class It will always inherit from one known Class (Row) It will have atleast 2 constructors (one accepting a long, and one accepting an IDataRecord) I plan on doign the following: Finding all classes that have a certain attribute on them Creating a delegate/method/lambda/whatever that creates a new instance of the class Storing the delegate/whatever along with some properties in a struct/class Insert the struct into a hashtable When needed, pull the info out of the hashtable and calling the delegate/whatever to get a new instance of the class and returning it/adding it to a list/etc. I need help only with #2 above!!! I have no idea where to start. I really just need some reference material to get me started, or some keywords to throw into google. This is for a compact/simple to use ORM for our office here. I understand the above is not simple, but once working, should make maintaining the code incredibly simple. Please let me know if you need any more info! And thanks in advance! :)

    Read the article

  • Attribute lost with yield

    - by Nelson
    Here's an interesting one... There is some code that I'm trying to convert from IList to IEnumerable: [Something(123)] public IEnumerable<Foo> GetAllFoos() { SetupSomething(); DataReader dr = RunSomething(); while (dr.Read()) { yield return Factory.Create(dr); } } The problem is, SetupSomething() comes from the base class and uses: Attribute.GetCustomAttribute(new StackTrace().GetFrame(1).GetMethod(), typeof(Something)) Yield ends up creating MoveNext(), MoveNext() calls SetupSomething(), and MoveNext() does not have the [Something(123)] attribute. I can't change the base class, so it appears I am forced to stay with IList or implement IEnumerable manually (and add the attribute to MoveNext()). Is there any other way to make yield work in this scenario?

    Read the article

  • Merging .net object graph

    - by Tiju John
    Hi guys, has anyone come across any scenario wherein you needed to merge one object with another object of same type, merging the complete object graph. for e.g. If i have a person object and one person object is having first name and other the last name, some way to merge both the objects into a single object. public class Person { public Int32 Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } public class MyClass { //both instances refer to the same person, probably coming from different sources Person obj1 = new Person(); obj1.Id=1; obj1.FirstName = "Tiju"; Person obj2 = new Person(); ojb2.Id=1; obj2.LastName = "John"; //some way of merging both the object obj1.MergeObject(obj2); //?? //obj1.Id // = 1 //obj1.FirstName // = "Tiju" //obj1.LastName // = "John" } I had come across such type of requirement and I wrote an extension method to do the same. public static class ExtensionMethods { private const string Key = "Id"; public static IList MergeList(this IList source, IList target) { Dictionary itemData = new Dictionary(); //fill the dictionary for existing list string temp = null; foreach (object item in source) { temp = GetKeyOfRecord(item); if (!String.IsNullOrEmpty(temp)) itemData[temp] = item; } //if the same id exists, merge the object, otherwise add to the existing list. foreach (object item in target) { temp = GetKeyOfRecord(item); if (!String.IsNullOrEmpty(temp) && itemData.ContainsKey(temp)) itemData[temp].MergeObject(item); else source.Add(item); } return source; } private static string GetKeyOfRecord(object o) { string keyValue = null; Type pointType = o.GetType(); if (pointType != null) foreach (PropertyInfo propertyItem in pointType.GetProperties()) { if (propertyItem.Name == Key) { keyValue = (string)propertyItem.GetValue(o, null); } } return keyValue; } public static object MergeObject(this object source, object target) { if (source != null && target != null) { Type typeSource = source.GetType(); Type typeTarget = target.GetType(); //if both types are same, try to merge if (typeSource != null && typeTarget != null && typeSource.FullName == typeTarget.FullName) if (typeSource.IsClass && !typeSource.Namespace.Equals("System", StringComparison.InvariantCulture)) { PropertyInfo[] propertyList = typeSource.GetProperties(); for (int index = 0; index < propertyList.Length; index++) { Type tempPropertySourceValueType = null; object tempPropertySourceValue = null; Type tempPropertyTargetValueType = null; object tempPropertyTargetValue = null; //get rid of indexers if (propertyList[index].GetIndexParameters().Length == 0) { tempPropertySourceValue = propertyList[index].GetValue(source, null); tempPropertyTargetValue = propertyList[index].GetValue(target, null); } if (tempPropertySourceValue != null) tempPropertySourceValueType = tempPropertySourceValue.GetType(); if (tempPropertyTargetValue != null) tempPropertyTargetValueType = tempPropertyTargetValue.GetType(); //if the property is a list IList ilistSource = tempPropertySourceValue as IList; IList ilistTarget = tempPropertyTargetValue as IList; if (ilistSource != null || ilistTarget != null) { if (ilistSource != null) ilistSource.MergeList(ilistTarget); else propertyList[index].SetValue(source, ilistTarget, null); } //if the property is a Dto else if (tempPropertySourceValue != null || tempPropertyTargetValue != null) { if (tempPropertySourceValue != null) tempPropertySourceValue.MergeObject(tempPropertyTargetValue); else propertyList[index].SetValue(source, tempPropertyTargetValue, null); } } } } return source; } } However, this works when the source property is null, if target has it, it will copy that to source. IT can still be improved to merge when inconsistencies are there e.g. if FirstName="Tiju" and FirstName="John" Any commments appreciated. Thanks TJ

    Read the article

  • How To Test if a Type is Anonymous?

    - by DaveDev
    Hi Guys I have the following method which serialises an object to a HTML tag. I only want to do this though if the type isn't Anonymous. private void MergeTypeDataToTag(object typeData) { if (typeData != null) { Type elementType = typeData.GetType(); if (/* elementType != AnonymousType */) { _tag.Attributes.Add("class", elementType.Name); } // do some more stuff } } Can somebody show me how to achieve this? Thanks Dave

    Read the article

  • Can I call make runtime decided method calls in Java?

    - by Catalin Marin
    I know there is an invoke function that does the stuff, I am overall interested in the "correctness" of using such a behavior. My issue is this: I have a Service Object witch contains methods which I consider services. What I want to do is alter the behavior of those services without later intrusion. For example: class MyService { public ServiceResponse ServeMeDonuts() { do stuff... return new ServiceResponse(); } after 2 months I find out that I need to offer the same service to a new client app and I also need to do certain extra stuff like setting a flag, or make or updating certain data, or encode the response differently. What I can do is pop it up and throw down some IFs. In my opinion this is not good as it means interaction with tested code and may result in un wanted behaviour for the previous service clients. So I come and add something to my registry telling the system that the "NewClient" has a different behavior. So I'll do something like this: public interface Behavior { public void preExecute(); public void postExecute(); } public class BehaviorOfMyService implements Behavior{ String method; String clientType; public void BehaviorOfMyService(String method,String clientType) { this.method = method; this.clientType = clientType; } public void preExecute() { Method preCall = this.getClass().getMethod("pre" + this.method + this.clientType); if(preCall != null) { return preCall.invoke(); } return false; } ...same for postExecute(); public void preServeMeDonutsNewClient() { do the stuff... } } when the system will do something like this if(registrySaysThereIs different behavior set for this ServiceObject) { Class toBeCalled = Class.forName("BehaviorOf" + usedServiceObjectName); Object instance = toBeCalled.getConstructor().newInstance(method,client); instance.preExecute(); ....call the service... instance.postExecute(); .... } I am not particularly interested in correctness of code as in correctness of thinking and approach. Actually I have to do this in PHP, witch I see as a kind of Pop music of programming which I have to "sing" for commercial reasons, even though I play POP I really want to sing by the book, so putting aside my more or less inspired analogy I really want to know your opinion on this matter for it's practical necessity and technical approach. Thanks

    Read the article

  • How to allow users to customize a DAL

    - by rsteckly
    Hi, I'm working in ASP.NET in an application where often users want to add fields or change field names. I'd like to be able to have an xml schema in place that is parsed and a dynamic object model created from it that can be accessed throughout the application. My initial reaction is that this is not realistic. I think there is flexibility about the dynamic nature of it. I think the people I'm trying to build this for wouldn't mind recompiling. Even if the app recompiled, I don't know how to abstract away enough in my code access the data to allow for users changing property names, etc. How can you write LINQ when the properties might change? In short, there's two questions here: 1) is there a way to dynamically generate an object model of the database and 2) is there a way to abstract away enough so that code accessing the database doesn't break when properties change?

    Read the article

  • Use string value to create new instance

    - by Brian David Berman
    I have a few classes: SomeClass1, SomeClass2. How can I create a new instance of one of these classes by using the class name from a string? Normally, I would do: var someClass1 = new SomeClass1(); How can I create this instance from the following: var className = "SomeClass1"; I am assuming I should use Type.GetType() or something but I can't figure it out. Thanks.

    Read the article

  • How to determine if a .NET Type is a custom struct?

    - by SztupY
    Hi! How to write a simple method, that checks whether a concrete type is a custom struct (created with public struct { };) or not. Checking Type.IsValueType is not enough, because it is also true to int, long, etc, and adding a check to !IsPrimitiveType won't exclude decimal, DateTime and maybe some other value types. I know that most of the built in value types are actually "structs", but I only want to check for "custom structs" These questions are mostly the same but without the answer I need: #1 #2 #3

    Read the article

  • The uncatchable exception, pt 2

    - by chaiguy
    Ok I've done some testing and I've reduced the problem to something very simple: i. Create a method in a new class that throws an exception: public class Class1 { public void CallMe() { string blah = null; blah.ToLower(); } } ii. Create a MethodInfo that points to this method somewhere else: Type class1 = typeof( Class1 ); Class1 obj = new Class1(); MethodInfo method = class1.GetMethod( "CallMe" ); iii. Wrap a call to Invoke() in a try/catch block: try { method.Invoke( obj, null ); // exception is not being caught! } catch { } iv. Run the program without the debugger (works fine). v. Now run the program with the debugger. The debugger will halt the program when the exception occurs, even though it's wrapped in a catch handler that tries to ignore it. (Even if you put a breakpoint in the catch block it will halt before it reaches it!) In fact, the exception is happening when you run it without the debugger too. In a simple test project it's getting ignored at some other level, but if your app has any kind of global exception handling, it will get triggered there as well. This is causing me a real headache because it keeps triggering my app's crash-handler, not to mention the pain it is to attempt to debug.

    Read the article

  • f# types' properties in inconsistent order and of slightly differing types

    - by philbrowndotcom
    I'm trying to iterate through an array of objects and recursively print out each objects properties. Here is my object model: type firmIdentifier = { firmId: int ; firmName: string ; } type authorIdentifier = { authorId: int ; authorName: string ; firm: firmIdentifier ; } type denormalizedSuggestedTradeRecommendations = { id: int ; ticker: string ; direction: string ; author: authorIdentifier ; } Here is how I am instantiating my objects: let getMyIdeasIdeas = [| {id=1; ticker="msfqt"; direction="buy"; author={authorId=0; authorName="john Smith"; firm={firmId=12; firmName="Firm1"}};}; {id=2; ticker="goog"; direction="sell"; author={authorId=1; authorName="Bill Jones"; firm={firmId=13; firmName="ABC Financial"}};}; {id=3; ticker="DFHF"; direction="buy"; author={authorId=2; authorName="Ron James"; firm={firmId=2; firmName="DEFFirm"}};}|] And here is my algorithm to iterate, recurse and print: let rec recurseObj (sb : StringBuilder) o= let props : PropertyInfo [] = o.GetType().GetProperties() sb.Append( o.GetType().ToString()) |> ignore for x in props do let getMethod = x.GetGetMethod() let value = getMethod.Invoke(o, Array.empty) ignore <| match value with | :? float | :? int | :? string | :? bool as f -> sb.Append(x.Name + ": " + f.ToString() + "," ) |> ignore | _ -> recurseObj sb value for x in getMyIdeas do recurseObj sb x sb.Append("\r\n") |> ignore If you couldnt tell, I'm trying to create a csv file and am printing out the types for debugging purposes. The problem is, the first element comes through in the order you'd expect, but all subsequent elements come through with a slightly different (and confusing) ordering of the "child" properties like so: RpcMethods+denormalizedSuggestedTradeRecommendationsid: 1,ticker: msfqt,direction: buy,RpcMethods+authorIdentifierauthorId: 0,authorName: john Smith,RpcMethods+firmIdentifierfirmId: 12,firmName: Firm1, RpcMethods+denormalizedSuggestedTradeRecommendationsid: 2,ticker: goog,direction: sell,RpcMethods+authorIdentifierauthorName: Bill Jones,RpcMethods+firmIdentifierfirmName: ABC Financial,firmId: 13,authorId: 1, RpcMethods+denormalizedSuggestedTradeRecommendationsid: 3,ticker: DFHF,direction: buy,RpcMethods+authorIdentifierauthorName: Ron James,RpcMethods+firmIdentifierfirmName: DEFFirm,firmId: 2,authorId: 2, Any idea what is going on here?

    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

  • Getting the instance when Constructor#newInstance throws?

    - by Shtééf
    I'm working on a simple plugin system, where third party plugins implement a Plugin interface. A directory of JARs is scanned, and the implementing classes are instantiated with Constructor#newInstance. The thing is, these plugins call back into register* methods of the plugin host. These registrations use the Plugin instance as a handle. My problem is how to clean up these registrations if the constructor decides to fail and throw halfway through. InvocationTargetException doesn't seem to have anything on it to get the instance. Is there a way to get at the instance of an exception throwing constructor? P.S.: It's typically strongly advised to users that the constructor not do anything, but in practice people are doing it any ways.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >