Search Results

Search found 2166 results on 87 pages for 'obj'.

Page 18/87 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Hook IDispatch v-table in C++

    - by monoceres
    I'm trying to modify the behavior of an IDispatch interface already present in the system. To do this my plan was to hook into the objects v-table during runtime and modify the pointers so it points to a custom hook method instead. If I can get this to work I can add new methods and properties to already existing objects. Nice. First I tried hooking into the v-table for IUnknown (from which IDispatch inherits from) and that worked fine. However trying to change entires in IDispatch doesn't work at all. Nothing happens at all, the code works just as it did without the hook. Here's the code, it's very simple so it shouldn't be any problems to understand #include <iostream> #include <windows.h> #include <Objbase.h> #pragma comment (lib,"Ole32.lib") using namespace std; HRESULT __stdcall typecount(IDispatch *self,UINT*u) { cout << "hook" << endl; *u=1; return S_OK; } int main() { CoInitialize(NULL); // Get clsid from name CLSID clsid; CLSIDFromProgID(L"shell.application",&clsid); // Create instance IDispatch *obj=NULL; CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(IDispatch),(void**)&obj); // Get vtable and offset in vtable for idispatch void* iunknown_vtable= (void*)*((unsigned int*)obj); // There are three entries in IUnknown, therefore add 12 to go to IDispatch void* idispatch_vtable = (void*)(((unsigned int)iunknown_vtable)+12); // Get pointer of first emtry in IDispatch vtable (GetTypeInfoCount) unsigned int* v1 = (unsigned int*)iunknown_vtable; // Change memory permissions so address can be overwritten DWORD old; VirtualProtect(v1,4,PAGE_EXECUTE_READWRITE,&old); // Override v-table pointer *v1 = (unsigned int) typecount; // Try calling GetTypeInfo count, should now be hooked. But isn't works as usual UINT num=0; obj->GetTypeInfoCount(&num); /* HRESULT hresult; OLECHAR FAR* szMember = (OLECHAR*)L"MinimizeAll"; DISPID dispid; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; hresult = obj->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid) ; hresult = obj->Invoke(dispid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&dispparamsNoArgs, NULL, NULL, NULL); */ } Thanks in advance!

    Read the article

  • Problem with custom Equality in Entity Framework

    - by Shimmy
    Hello! I am using Entity Framework in my application. I implemented with the partial class of an entity the IEquatable<T> interface: Partial Class Address : Implements IEquatable(Of Address) 'Other part generated Public Overloads Function Equals(ByVal other As Address) As Boolean _ Implements System.IEquatable(Of Address).Equals If ReferenceEquals(Me, other) Then Return True Return AddressId = other.AddressId End Function Public Overrides Function Equals(ByVal obj As Object) As Boolean If obj Is Nothing Then Return MyBase.Equals(obj) If TypeOf obj Is Address Then Return Equals(DirectCast(obj, Address)) Else Return False End Function Public Overrides Function GetHashCode() As Integer Return AddressId.GetHashCode End Function End Class Now in my code I use it this way: Sub Main() Using e As New CompleteKitchenEntities Dim job = e.Job.FirstOrDefault Dim address As New Address() job.Addresses.Add(address) Dim contains1 = job.Addresses.Contains(address) 'True e.SaveChanges() Dim contains2 = job.Addresses.Contains(address) 'False 'The problem is that I can't remove it: Dim removed = job.Addresses.Remoeve(address) 'False End Using End Sub Note (I checked in the debugger visualizer) that the EntityCollection class stores its entities in HashSet so it has to do with the GetHashCode function, I want it to depend on the ID so entities are compared by their IDs. Please help me find what's wrong in the GetHashCode function (by ID) and what can I change to make it work. Thanks a lot.

    Read the article

  • Django JSON serializable error

    - by Hulk
    With the following code below, There is an error saying File "/home/user/web_pro/info/views.py", line 184, in headerview, raise TypeError("%r is not JSON serializable" % (o,)) TypeError: <lastname: jerry> is not JSON serializable In the models code header(models.Model): firstname = models.ForeignKey(Firstname) lastname = models.ForeignKey(Lastname) In the views code headerview(request): header = header.objects.filter(created_by=my_id).order_by(order_by)[offset:limit] l_array = [] l_array_obj = [] for obj in header: l_array_obj = [obj.title, obj.lastname ,obj.firstname ] l_array.append(l_array_obj) dictionary_l.update({'Data': l_array}) ; return HttpResponse(simplejson.dumps(dictionary_l), mimetype='application/javascript') what is this error and how to resolve this? thanks..

    Read the article

  • Append an object to a list in R?

    - by Nick
    If I have some R list mylist, you can append an item obj to it like so: mylist[[length(mylist)+1]] <- obj But surely there is some more compact way. When I was new at R, I tried writing append() like so: append <- function(lst, obj) { lst[[length(list)+1]] <- obj return(lst) } but of course that doesn't work due to R's call-by-name semantics (lst is effectively copied upon call, so changes to lst are not visible outside the scope of append(). I know you can do environment hacking in an R function to reach outside the scope of your function and mutate the calling environment, but that seems like a large hammer to write a simple append function. Can anyone suggest a more beautiful way of doing this? Bonus points if it works for both vectors and lists.

    Read the article

  • Referencing .NET Assembly in VB6 won't work

    - by dretzlaff17
    I wrote a .net assembly using c# to perform functions that will be used by both managed and unmanaged code. I have a VB6 project that now needs to use the assembly via COM. I created my .net assembly, made sure that ComVisible is set to true and that it is registered for COM interop via project properties. public class MyClass [ComVisible(true)] public string GetResponse() { return "Testing Response" } } I build the assembly and copied the file into a folder. TestInterop.dll I then run a batch file to register the assembly tool to register the object for COM. cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ regasm "c:\Program Files\TestApp\TestInterop.dll" /tlb:TestInterop.tlb I open a new VB6 application and reference TestInterop.dll In VB6 I write the following code and it compiles. Dim obj as TestInterop.MyClass Set obj = new TestInterop.MyClass Dim strTest as string strTest = obj.GetRespose() When I run the program it errors on the obj.GetResponse() line. Run-time error' -2147024894 (80070002'): Automation error The system cannot find the file specified Also, the intellesense does not work on obj. I had to type the GetResponse method. Is this normal? Does anyone have any clue what could be wrong or what steps I missed. Thanks!

    Read the article

  • PHP: How to dynamically add to http_build_query?

    - by oni-kun
    I have a scraping object basically. I want to be able to add POST variables to it like $obj->addvar('Name', 'Value'); What I have now is this: function addvar($var, $val) { $postvars[] = Array($var=>$val); } function initiate() { $this->q = $postvars; } if(!empty($this->post)) { $this->params = http_build_query($q); } I haven't tested because it's too incomplete, But would my addvar() function work? How on earth do I append a key+value to the array so http_build_query would accept it? IE (this is what I want): $obj->addvar('username', 'abc'); $obj->addvar('password', 'foobar'); $obj->send(); //..

    Read the article

  • remove element in javascript

    - by Hulk
    In the below code how to remove the hyperlink after getting the innerHTML function test(obj) { var a=obj.innerHTML // remove obj element here } $p = $('<a id="name" onclick="javascript:var ele=test(this);">').html( "test" ); $('#questions').append( $p ); Thanks..

    Read the article

  • how to set Anonymous delegate as one parameter for InvokeSelf ?

    - by KentZhou
    I tried to use InvokeSelf for silverlight to communicate with html: InvokeSelf can take object[] as parameter when making a call: ScriptObject Myjs; ScriptObject obj = Myjs.InvokeSelf(new object[] { element }) as ScriptObject; then I want make a call like with anonymous delegate: Object obj; obj = InvokeSelf(new object[] { element, delegate { OnUriLoaded(reference); } }); I got the error said: Cannot convert anonymous method to type 'object' because it is not a delegate type How to resolve this problem?

    Read the article

  • PHP parsing XML file with and without namespaces

    - by Mike
    I need to get a XML File into a Database. Thats not the problem. Cant read it, parse it and create some Objects to map to the DB. Problem is, that sometimes the XML File can contain namespaces and sometimes not. Furtermore sometimes there is no namespace defined at all. So what i first got was something like this: <?xml version="1.0" encoding="UTF-8"?> <struct xmlns:b="http://www.w3schools.com/test/"> <objects> <object> <node_1>value1</node_1> <node_2>value2</node_2> <node_3 iso_land="AFG"/> <coords lat="12.00" long="13.00"/> </object> </objects> </struct> And the parsing: $t = $xml->xpath('/objects/object'); foreach($nodes AS $node) { if($t[0]->$node) { $obj->$node = (string) $t[0]->$node; } } Thats fine as long as there are no namespaces. Here comes the XML File with namespaces: <?xml version="1.0" encoding="UTF-8"?> <b:struct xmlns:b="http://www.w3schools.com/test/"> <b:objects> <b:object> <b:node_1>value1</b:node_1> <b:node_2>value2</b:node_2> <b:node_3 iso_land="AFG"/> <b:coords lat="12.00" long="13.00"/> </b:object> </b:objects> </b:struct> I now came up with something like this: $xml = simplexml_load_file("test.xml"); $namespaces = $xml->getNamespaces(TRUE); $ns = count($namespaces) ? 'a:' : ''; $xml->registerXPathNamespace("a", "http://www.w3schools.com/test/"); $nodes = array('node_1', 'node_2'); $obj = new stdClass(); foreach($nodes AS $node) { $t = $xml->xpath('/'.$ns.'objects/'.$ns.'object/'.$ns.$node); if($t[0]) { $obj->$node = (string) $t[0]; } } $t = $xml->xpath('/'.$ns.'objects/'.$ns.'object/'.$ns.'node_3'); if($t[0]) { $obj->iso_land = (string) $t[0]->attributes()->iso_land; } $t = $xml->xpath('/'.$ns.'objects/'.$ns.'object/'.$ns.'coords'); if($t[0]) { $obj->lat = (string) $t[0]->attributes()->lat; $obj->long = (string) $t[0]->attributes()->long; } That works with namespaces and without. But i feel that there must be a better way. Before that i could do something like this: $t = $xml->xpath('/'.$ns.'objects/'.$ns.'object'); foreach($nodes AS $node) { if($t[0]->$node) { $obj->$node = (string) $t[0]->$node; } } But that just wont work with namespaces.

    Read the article

  • Problem with custom Equality and GetHashCode in a mutable object

    - by Shimmy
    Hello! I am using Entity Framework in my application. I implemented with the partial class of an entity the IEquatable<T> interface: Partial Class Address : Implements IEquatable(Of Address) 'Other part generated Public Overloads Function Equals(ByVal other As Address) As Boolean _ Implements System.IEquatable(Of Address).Equals If ReferenceEquals(Me, other) Then Return True Return AddressId = other.AddressId End Function Public Overrides Function Equals(ByVal obj As Object) As Boolean If obj Is Nothing Then Return MyBase.Equals(obj) If TypeOf obj Is Address Then Return Equals(DirectCast(obj, Address)) Else Return False End Function Public Overrides Function GetHashCode() As Integer Return AddressId.GetHashCode End Function End Class Now in my code I use it this way: Sub Main() Using e As New CompleteKitchenEntities Dim job = e.Job.FirstOrDefault Dim address As New Address() job.Addresses.Add(address) Dim contains1 = job.Addresses.Contains(address) 'True e.SaveChanges() Dim contains2 = job.Addresses.Contains(address) 'False 'The problem is that I can't remove it: Dim removed = job.Addresses.Remoeve(address) 'False End Using End Sub Note (I checked in the debugger visualizer) that the EntityCollection class stores its entities in HashSet so it has to do with the GetHashCode function, I want it to depend on the ID so entities are compared by their IDs. The problem is that when I hit save, the ID changes from 0 to its db value. So the question is how can I have an equatable object, being properly hashed. Please help me find what's wrong in the GetHashCode function (by ID) and what can I change to make it work. Thanks a lot.

    Read the article

  • How do I add a click handler to a new element when I create it? [closed]

    - by vicky
    How do I add a click handler to a new element when I create it? This is what I have tried, but it does not work as expected: DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "Img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': SayHi(this) })); document.body.appendChild(DeCheBX); DeImg = $('MyDiv').insert(new Element('img', { 'id': "Imgx" + obj[i].Nam, 'src': obj[i].IM })); document.body.appendChild(DeImg); } SayHi = function (x) { try { if ($(x).checked == true) { alert("press" + x); } } catch (e) { alert("error");

    Read the article

  • Testing for undefined and null child objects in ActionsScript/Flex

    - by dbasch
    Hi Everyone, I use this pattern to test for undefined and null values in ActionScript/Flex : if(obj) { execute() } Unfortunately, a ReferenceError is always thrown when I use the pattern to test for child objects : if(obj.child) { execute() } ReferenceError: Error #1069: Property child not found on obj and there is no default value. Why does testing for child objects with if statements throw a ReferenceError? Thanks!

    Read the article

  • Some question of object property name in Actionscript3.

    - by unsouled
    A.as package { public class A { public static var someObject:Object = { (B.SOME_CONST): { value: 10 } }; } } B.as package { public class B { public static const SOME_CONST:String = "someStringConst"; } } And this is test code. var obj:Object = A.someObject; trace(obj.hasOwnProperty(B.SOME_CONST)); trace(obj.hasOwnProperty("someStringConst")); trace(obj.hasOwnProperty("SOME_CONST")); I expected that result will be true, true, false but real result is false, false, true. Why?

    Read the article

  • How to handle value types when embedding IronPython in C#?

    - by kloffy
    There is a well known issue when it comes to using .NET value types in IronPython. This has recently caused me a headache when trying to use Python as an embedded scripting language in C#. The problem can be summed up as follows: Given a C# struct such as: struct Vector { public float x; public float y; } And a C# class such as: class Object { public Vector position; } The following will happen in IronPython: obj = Object() print obj.position.x # prints ‘0’ obj.position.x = 1 print obj.position.x # still prints ‘0’ As the article states, this means that value types are mostly immutable. However, this is a problem as I was planning on using a vector library that is implemented as seen above. Are there any workarounds for working with existing libraries that rely on value types? Modifying the library would be the very last resort, but I'd rather avoid that.

    Read the article

  • What does this code mean?

    - by joseph
    Hello, I do not know, what is function of code lookups.singleton in code below public class ProjectNode extends AbstractNode { public ProjectNode(MainProject obj, ProjectsChildren children) { super (children, Lookups.singleton(obj)); setDisplayName ( obj.getName()); } }

    Read the article

  • Android HttpsURLConnection and JSON for new GCM

    - by Ryan Gray
    I'm overhauling certain parts of my app to use the new GCM service to replace C2DM. I simply want to create the JSON request from a Java program for testing and then read the response. As of right now I can't find ANY formatting issues with my JSON request and the google server always return code 400, which indicates a problem with my JSON. http://developer.android.com/guide/google/gcm/gcm.html#server JSONObject obj = new JSONObject(); obj.put("collapse_key", "collapse key"); JSONObject data = new JSONObject(); data.put("info1", "info_1"); data.put("info2", "info 2"); data.put("info3", "info_3"); obj.put("data", data); JSONArray ids = new JSONArray(); ids.add(REG_ID); obj.put("registration_ids", ids); System.out.println(obj.toJSONString()); I print my request to the eclipse console to check it's formatting byte[] postData = obj.toJSONString().getBytes(); try{ URL url = new URL("https://android.googleapis.com/gcm/send"); HttpsURLConnection.setDefaultHostnameVerifier(new JServerHostnameVerifier()); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "key=" + API_KEY); System.out.println(conn.toString()); OutputStream out = conn.getOutputStream(); // exception thrown right here. no InputStream to get InputStream in = conn.getInputStream(); byte[] response = null; out.write(postData); out.close(); in.read(response); JSONParser parser = new JSONParser(); String temp = new String(response); JSONObject temp1 = (JSONObject) parser.parse(temp); System.out.println(temp1.toJSONString()); int responseCode = conn.getResponseCode(); System.out.println(responseCode + ""); } catch(Exception e){ System.out.println("Exception thrown\n"+ e.getMessage()); } } I'm sure my API key is correct as that would result in error 401, so says the google documentation. This is my first time doing JSON but it's easy to understand because of its simplicity. Anyone have any ideas on why I always receive code 400? update: I've tested the google server example classes provided with gcm so the problem MUST be with my code.

    Read the article

  • Working on a jQuery plugin : viewport simulator

    - by pixelboy
    Hi community, i'm working on a jQuery plugin that's aiming to simulate one axis camera movements. The first step to achieving this is simple : use conventional, clean markup, and get the prototype to work. Heres how to initiate the plugin : $('#wrapper').fluidGrids({exclude: '.exclude'}); Here's a working demo of the WIP thing : http://sandbox.test.everestconseil.com/protoCitroen/home.html Where am I having issues : Is there a fast way to detect if parent of each target (clickable animated element) is a href link, and if so to save this url ? My clone uses the original background image to then animate it.fade it to black/white. But when you clik on an element, image url is found, but doesn't seem to be injected. Do you see anything ? Finally, about animation of elements : as you can see in source code, I'm using the container $('#wrapper') to position all animated children. What would be the perfect properties to apply to make this cross browser proof ? Here's the source code for the plugin, fully commented. (function($){ $.fn.extend({ //plugin name - fluidGrids fluidGrids: function(options) { //List and default values for available options var defaults = { //The target that we're going to use to handle click event hitTarget: '.animateMe', exclude: '.exclude', animateSpeed: 1000 }; var options = $.extend(defaults, options); return this.each(function() { var o = options; //Assign current element to variable var obj = $(this); //We assign default width height and positions to each object in order to get them back when necessary var objPosition = obj.position(); //Get all ready to animate targets in innerViewport var items = $(o.hitTarget, obj); //Final coords of innerViewport var innerViewport = new Object(); innerViewport.top = parseInt(objPosition.top); innerViewport.left = parseInt(objPosition.left); innerViewport.bottom = obj.height(); innerViewport.right = obj.width(); items.each(function(e){ //Assign a pointer cursor to each clickable element $(this).css("cursor","pointer"); //To load distant url at last, we look for it in Title Attribute if ($(this).attr('title').length){ var targetUrl = $(this).attr('title'); } //We assign default width height and positions to each object in order to get them back when necessary var itemPosition = $(this).position(); var itemTop = itemPosition.top; var itemLeft = itemPosition.left; var itemWidth = $(this).width(); var itemHeight = $(this).height(); //Both the original and it's animated clone var original = $(this); //To give the if (original.css('background-image')){ var urlImageOriginal = original.css('background-image').replace(/^url|[("")]/g, ''); var imageToInsert = "<img src="+urlImageOriginal+"/>" } var clone = $(this).clone(); original.click(function() { $(clone).append(imageToInsert); $(clone).attr("id","clone"); $(clone).attr('top',itemTop); $(clone).attr('left',itemLeft); $(clone).css("position","absolute"); $(clone).insertAfter(this); $(this).hide(); $(clone).animate({ top: innerViewport.top, left: innerViewport.left, width: innerViewport.bottom, height: innerViewport.right }, obj.animateSpeed); $("*",obj).not("#clone, #clone * , a , "+ o.exclude).fadeOut('fast'); //Si l'objet du click est un lien return false; }); }); }); } }); })(jQuery);

    Read the article

  • ZeroC Ice "checked casts" in Scala

    - by Alexey Romanov
    ZeroC Ice for Java translates every Slice interface Simple into (among other things) a proxy interface SimplePrx and a proxy SimplePrxHelper. If I have an ObjectPrx (the base interface for all proxies), I can check whether it actually has interface Simple by using a static method on SimplePrxHelper: val obj : Ice.ObjectPrx = ...; // Get a proxy from somewhere... val simple : SimplePrx = SimplePrxHelper.checkedCast(obj); if (simple != null) // Object supports the Simple interface... else // Object is not of type Simple... I wanted to write a method castTo so that I could replace the second line with val simple = castTo[SimplePrx](obj) or val simple = castTo[SimplePrxHelper](obj) So far as I can see, Scala's type system is not expressive enough to allow me to define castTo. Is this correct?

    Read the article

  • Mingling C++ classes with Objective C classes

    - by Joey
    I am using the iphone SDK and coding primarily in C++ while using parts of the SDK in obj-c. Is it possible to designate a C++ class in situations where an obj-c class is needed? For instance: 1) when setting delegates to obj-c objects. I cannot make a C++ class derive from a Delegate protocol so this and possibly other reasons prevent me from making my C++ class a delegate for various obj-c objects. What I do as a solution is create an obj-c adapter class that contains a ptr to the C++ class and is used as the delegate (notifying the C++ class when it is called). It feels cumbersome to write these every time I need to get delegate notifications to a C++ class. 2) when setting selectors This goes hand in hand with item 1. Say I want to set a callback to fire when something is done, like a button press or a setAnimationDidStopSelector in the UIView animation functionality. It would be nice to be able to designate a C++ function along with the relevant delegate for setAnimationDelegate. Well, I suspect this isn't readily possible, but if anyone has any suggestions on how to do it if it is, or on how to write such things more easily, I would love to hear them. Thanks.

    Read the article

  • Decompressing a very large serialized object and managing memory

    - by Mike_G
    I have an object that contains tons of data used for reports. In order to get this object from the server to the client I first serialize the object in a memory stream, then compress it using the Gzip stream of .NET. I then send the compressed object as a byte[] to the client. The problem is on some clients, when they get the byte[] and try to decompress and deserialize the object, a System.OutOfMemory exception is thrown. Ive read that this exception can be caused by new() a bunch of objects, or holding on to a bunch of strings. Both of these are happening during the deserialization process. So my question is: How do I prevent the exception (any good strategies)? The client needs all of the data, and ive trimmed down the number of strings as much as i can. edit: here is the code i am using to serialize/compress (implemented as extension methods) public static byte[] SerializeObject<T>(this object obj, T serializer) where T: XmlObjectSerializer { Type t = obj.GetType(); if (!Attribute.IsDefined(t, typeof(DataContractAttribute))) return null; byte[] initialBytes; using (MemoryStream stream = new MemoryStream()) { serializer.WriteObject(stream, obj); initialBytes = stream.ToArray(); } return initialBytes; } public static byte[] CompressObject<T>(this object obj, T serializer) where T : XmlObjectSerializer { Type t = obj.GetType(); if(!Attribute.IsDefined(t, typeof(DataContractAttribute))) return null; byte[] initialBytes = obj.SerializeObject(serializer); byte[] compressedBytes; using (MemoryStream stream = new MemoryStream(initialBytes)) { using (MemoryStream output = new MemoryStream()) { using (GZipStream zipper = new GZipStream(output, CompressionMode.Compress)) { Pump(stream, zipper); } compressedBytes = output.ToArray(); } } return compressedBytes; } internal static void Pump(Stream input, Stream output) { byte[] bytes = new byte[4096]; int n; while ((n = input.Read(bytes, 0, bytes.Length)) != 0) { output.Write(bytes, 0, n); } } And here is my code for decompress/deserialize: public static T DeSerializeObject<T,TU>(this byte[] serializedObject, TU deserializer) where TU: XmlObjectSerializer { using (MemoryStream stream = new MemoryStream(serializedObject)) { return (T)deserializer.ReadObject(stream); } } public static T DecompressObject<T, TU>(this byte[] compressedBytes, TU deserializer) where TU: XmlObjectSerializer { byte[] decompressedBytes; using(MemoryStream stream = new MemoryStream(compressedBytes)) { using(MemoryStream output = new MemoryStream()) { using(GZipStream zipper = new GZipStream(stream, CompressionMode.Decompress)) { ObjectExtensions.Pump(zipper, output); } decompressedBytes = output.ToArray(); } } return decompressedBytes.DeSerializeObject<T, TU>(deserializer); } The object that I am passing is a wrapper object, it just contains all the relevant objects that hold the data. The number of objects can be a lot (depending on the reports date range), but ive seen as many as 25k strings. One thing i did forget to mention is I am using WCF, and since the inner objects are passed individually through other WCF calls, I am using the DataContract serializer, and all my objects are marked with the DataContract attribute.

    Read the article

  • dynamic check_box using field_for in rails

    - by Craig Whitley
    I have a many-to-many relationship with a link box, and I want to pull those models together into one form so I can update from the same page. I'm really struggling with getting the check_box to even show all the elements of my array - I've scoured the net and been working on this literally all day, and I'm finding it difficult to apply the information I'm reading to my problem. I'm also extremely new to RoR and I've been following a bit of an outdated video tutorial (pre 2.0) so apologies for my code. So far, I've got it to output only one key pair in the array (the last one) - although outside the form, the code used in the tutorial works exactly how it should. Thats of little use though! Host is the model for which the main form is for, and Billing is the outside model that I'm trying to add to the form. This is the code that works outside of the form from the tutorial: <% for billing in @billings -%> <%= check_box_tag('billing_title[]', billing.id, @host.billings.collect {|obj| obj.id}.include?(billing.id))%> <%= billing.title %><br /> <% end -%> I just need to know how to make it work inside the form. This is the aforementioned code that only retrieves the last array keypair after looping through them: <% f.fields_for :billings do |obj| %><br /> <%= check_box_tag('billing_title[]', billing.id, @billings.collect {|obj| obj.id}.include?(billing.id))%> <%= billing.title %><br /> <% end %> The debug(@billings) : --- - !ruby/object:Billing attributes: title: Every Month id: "1" attributes_cache: {} - !ruby/object:Billing attributes: title: 12 Months id: "2" attributes_cache: {} - !ruby/object:Billing attributes: title: 6 Months id: "5" attributes_cache: {} Any help really appreciated.

    Read the article

  • Remove accents from a JSON response using the raw content.

    - by Pentium10
    This is a follow up of this question: Remove accents from a JSON response. The accepted answer there works for a single item/string of a raw JSON content. But I would like to run a full transformation over the entire raw content of the JSON without parsing each object/array/item. What I've tried is this function removeAccents($jsoncontent) { $obj=json_decode($jsoncontent); // use decode to transform the unicode chars to utf $content=serialize($obj); // serialize into string, so the whole obj structure can be used string as a whole $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿRr'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'; $content=utf8_decode($content); $jsoncontent = strtr($content, $a, $b); // at this point the accents are removed, and everything is good echo $jsoncontent; $obj=unserialize($jsoncontent); // this unserialization is returning false, probably because we messed up with the serialized string return json_encode($obj); } As you see after I decoded JSON content, I serialized the object to have a string of it, than I remove the accents from that string, but this way I have problem building back the object, as the unserialize stuff returns false. How can I fix this?

    Read the article

  • Building a specific piece of Android platform?

    - by Chrisc
    Hi, I have been trying to build only the "/libcore" directory of the Android platform. When I try mmm libcore I end up with the following output: ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=2.1-update1 TARGET_PRODUCT=generic TARGET_BUILD_VARIANT=eng TARGET_SIMULATOR=false TARGET_BUILD_TYPE=release TARGET_ARCH=arm HOST_ARCH=x86 HOST_OS=linux HOST_BUILD_TYPE=release BUILD_ID=ECLAIR ============================================ make: Entering directory `/home/chris/android/platform' target Prebuilt: (out/target/product/generic/system/etc/security/cacerts.bks) host Prebuilt: run-core-tests-on-ri (out/host/linux-x86/obj/EXECUTABLES/run-core-tests-on-ri_intermediates/run-core-tests-on-ri) target Prebuilt: run-core-tests (out/target/product/generic/obj/EXECUTABLES/run-core-tests_intermediates/run-core-tests) Copy: out/target/product/generic/system/etc/apns-conf.xml Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-full-debug.jar Copying: out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/classes-full-debug.jar /bin/bash: jar: command not found make: *** [out/host/common/core-tests.jar] Error 127 make: *** Deleting file `out/host/common/core-tests.jar' make: Leaving directory `/home/chris/android/platform' Does anyone have any suggestions on what Error 127 is, or another method I can go about building "libcore" without having to build the entire platform again? Thanks, Chris

    Read the article

  • Java Static Methods

    - by KP65
    Hello, I am wondering when to use static methods? Say If i have a class with a few getters and setters, a method or two, and i want those methods only to be invokable on an instance object of the class. Does this mean i should use a static method? e.g Obj x = new Obj(); x.someMethod or Obj.someMethod (is this the static way?) I'm rather confused!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >