Search Results

Search found 15353 results on 615 pages for 'native methods'.

Page 4/615 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • uitableview delegate methods are not called

    - by Sean
    hi all i got the problem that the tableview methods are not called the first time the tableview is shown. if switch back to the previous view and then click the button to show the tableview again, the methods are called this time. i've to say that i show an actionsheet while the tableview is loading. the actionsheet i call in the ViewWillAppear method. thanks in advance sean

    Read the article

  • code style for private methods in c#

    - by illdev
    I just found out, that it seems a common pattern to user UpperFirstLetterPascalCase() for private methods. I for myself, find this completely inconsistent with naming rules of private instance fields and variables and I find it difficult to read/debug, too. I would want to ask, why using a first upper letter for methods could be a better choice than a first lower (doThis())? Just out of curiosity...

    Read the article

  • Java: when to use 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

  • Methods in Ruby: objects or not?

    - by Mladen Jablanovic
    Inspired by this discussion, after some googling I wasn't able to find an answer to a pretty simple question regarding methods in Ruby: are they objects or not? There are different opinions here and there, and I would really like to hear, let's say, an in-depth explanation. I'm aware of Object#method method, which takes a method name and returns a Method instance, but, on the other hand, there's a similar thing you can do with blocks to make them into Proc instances, and blocks aren't objects, so what makes methods any different?

    Read the article

  • Cannot access Class methods from previous windows form - C#

    - by George
    I am writing an app, still, where I need to test some devices every minute for 30 minutes. It made sense to use a timer set to kick off every 60 secs and do whats required in the event handler. However, I need the app to wait for the 30 mins until I have finished with the timer since the following code alters the state of the devices I am trying to monitor. I obviously don't want to use any form of loop to do this. I thought of using another windows form, since I also display the progress, which will simply kick off the timer and wait until its complete. The problem I am having with this is that I use a device Class and cant seem to get access to the methods in the device class from the 2nd (3rd actually - see below) windows form. I have an initial windows form where I get input from the user, then call the 2nd windows form where it work out which tests need to be done and which device classes need to be used, and then I want to call the 3rd windows form to handle the timer. I will have up to 6-7 device classes and so wanted to only instantiate them when actually requiring them, from the 2nd form. Should I have put this logic into the 1st windows form (program class ??) ? Would I not still have the problem of not being able to access device class methods from there too ? Anyway, perhaps someone knows of a better way to do the checks every minute without the rest of the code executing (and changing the status of the devices) or how I should be accessing the methods in the app ?? Well that's the problem, I cant get that part of it to work correctly. Here is the definition for the calling form including the device class - namespace NdtStart { public partial class fclsNDTCalib : Form { NDTClass NDT = new NDTClass(); public fclsNDTCalib() (new fclsNDTTicker(NDT)).ShowDialog(); Here is the class def for the called form - namespace NdtStart { public partial class fclsNDTTicker : Form { public fclsNDTTicker() I tried lots but couldn't get the arguments to work.

    Read the article

  • Is there a way to use Linq projections with extension methods

    - by Acoustic
    I'm trying to use AutoMapper and a repository pattern along with a fluent interface, and running into difficulty with the Linq projection. For what it's worth, this code works fine when simply using in-memory objects. When using a database provider, however, it breaks when constructing the query graph. I've tried both SubSonic and Linq to SQL with the same result. Thanks for your ideas. Here's an extension method used in all scenarios - It's the source of the problem since everything works fine without using extension methods public static IQueryable<MyUser> ByName(this IQueryable<MyUser> users, string firstName) { return from u in users where u.FirstName == firstName select u; } Here's the in-memory code that works fine var userlist = new List<User> {new User{FirstName = "Test", LastName = "User"}}; Mapper.CreateMap<User, MyUser>(); var result = (from u in userlist select Mapper.Map<User, MyUser>(u)) .AsQueryable() .ByName("Test"); foreach (var x in result) { Console.WriteLine(x.FirstName); } Here's the same thing using a SubSonic (or Linq to SQL or whatever) that fails. This is what I'd like to make work somehow with extension methods... Mapper.CreateMap<User, MyUser>(); var result = from u in new DataClasses1DataContext().Users select Mapper.Map<User, MyUser>(u); var final = result.ByName("Test"); foreach(var x in final) // Fails here when the query graph built. { Console.WriteLine(x.FirstName); } The goal here is to avoid having to manually map the generated "User" object to the "MyUser" domain object- in other words, I'm trying to find a way to use AutoMapper so I don't have this kind of mapping code everywhere a database read operation is needed: var result = from u in new DataClasses1DataContext().Users select new MyUser // Can this be avoided with AutoMapper AND extension methods? { FirstName = v.FirstName, LastName = v.LastName };

    Read the article

  • Docs for auto-generated methods in Ruby on Rails

    - by macek
    Rails has all sorts of auto-generated methods that I've often times struggled to find documentation for. For example, in routes.rb, if I have: map.resources :projects do |p| p.resources :tasks end This will get a plethora of auto-generate path and url helpers. Where can I find documentation for how to work with these paths? I generally understand how to work with them, but more explicit docs might help me understand some of the magic that happens behind the scenes. # compare project_path(@project) project_task_path(@project, @task) # to project_path(:id => @project.id) project_task_path(:project_id => @project.id, :id => @task.id) Also, when I change an attribute on a model, @post.foo_changed? will be true. Where can I find documentation for this and all other magical methods that are created like this? If the magic is there, I'd love to take advantage of it. And finally: Is there a complete resource for config.___ statements for environment.rb? I was able to find docs for Configuration#gem but what attributes can I set within the stubs like config.active_record.___, config.action_mailer.___, config.action_controller.___, etc. Again, I'm looking for a complete resource here, not just a settings for the examples I provided. Even if you can only answer one of these questions, please chime in. These things seem to have been hiding from me and it's my goal to get them some more exposure, so I'll be upvoting all links to docs that point me to what I'm looking for. Thanks! ps, If they're not called auto-generated methods, I apologize. Someone can teach me a lesson here, too :) Edit I'm not looking for tutorials here, folks. I have a fair amount of experience with rails; I'm just looking for complete docs. E.g., I understand how routing works, I just want docs where I can read about all of the usage options.

    Read the article

  • IIS7 Modules - managed or native?

    - by Simon Linder
    Hi all, as the old ISAPI filters are going to die sooner or later, I want to rewrite an old ISAPI filter that was used in IIS 6 into a module for use in IIS 7. The module will be used globally, meaning it will be used within each site, on a Windows Server 2008 R2 with IIS 7.5 installed, that will host several thousand web sites and managing about 50 application pools. My question now is if I should write that module in managed or unmanaged code? One of my concerns regarding managed code is the massive memory consumption due to the .NET framework overhead. I don't know how this would effect the server's performance. I already wrote modules in managed as well as in unmanaged code. So this is not the bothering my decision. But I would prefer to write the module in C# if there are no huge drawbacks. Any suggestions about that issue?

    Read the article

  • Call methods on native Javascript types without wrapping with ()

    - by Anurag
    In Javascript, we can call methods on string literals directly without enclosing it within round brackets. But not for other types such as numbers, or functions. It is a syntax error, but is there a reason as to why the Javascript lexer needs these other types to be enclosed in round brackets? For example, if we extend Number, String, and Function with an alert method and try calling this method on the literals, it's a SyntaxError for Number and Function, while it works for a String. function alertValue() { alert(this); } Number.prototype.alert = alertValue; String.prototype.alert = alertValue; Function.prototype.alert = alertValue; We can call alert directly on a string object: "someStringLiteral".alert() // alerts someStringLiteral but it's a SyntaxError on numbers, and functions. 7.alert(); function() {}.alert(); To work with these types, we have to enclose it within brackets: (7).alert(); // alerts "7" (function() {}).alert(); // alerts "function() {}"

    Read the article

  • Visitor and templated virtual methods

    - by Thomas Matthews
    In a typical implementation of the Visitor pattern, the class must account for all variations (descendants) of the base class. There are many instances where the same method content in the visitor is applied to the different methods. A templated virtual method would be ideal in this case, but for now, this is not allowed. So, can templated methods be used to resolve virtual methods of the parent class? Given (the foundation): struct Visitor_Base; // Forward declaration. struct Base { virtual accept_visitor(Visitor_Base& visitor) = 0; }; // More forward declarations struct Base_Int; struct Base_Long; struct Base_Short; struct Base_UInt; struct Base_ULong; struct Base_UShort; struct Visitor_Base { virtual void operator()(Base_Int& b) = 0; virtual void operator()(Base_Long& b) = 0; virtual void operator()(Base_Short& b) = 0; virtual void operator()(Base_UInt& b) = 0; virtual void operator()(Base_ULong& b) = 0; virtual void operator()(Base_UShort& b) = 0; }; struct Base_Int : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; struct Base_Long : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; struct Base_Short : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; struct Base_UInt : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; struct Base_ULong : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; struct Base_UShort : public Base { void accept_visitor(Visitor_Base& visitor) { visitor(*this); } }; Now that the foundation is laid, here is where the kicker comes in (templated methods): struct Visitor_Cout : public Visitor { template <class Receiver> void operator() (Receiver& r) { std::cout << "Visitor_Cout method not implemented.\n"; } }; Intentionally, Visitor_Cout does not contain the keyword virtual in the method declaration. All the other attributes of the method signatures match the parent declaration (or perhaps specification). In the big picture, this design allows developers to implement common visitation functionality that differs only by the type of the target object (the object receiving the visit). The implementation above is my suggestion for alerts when the derived visitor implementation hasn't implement an optional method. Is this legal by the C++ specification? (I don't trust when some says that it works with compiler XXX. This is a question against the general language.)

    Read the article

  • Advice on whether to use native C++ DLL or not: PINVOKE & Marshaling ?

    - by Bob
    What's the best way to do this....? I have some Native C++ code that uses a lot of Win32 calls together with byte buffers (allocated using HeapAlloc). I'd like to extend the code and make a C# GUI...and maybe later use a basic Win32 GUI (for use where there is no .Net and limited MFC support). (A) I could just re-write the code in C# and use multiple PINVOKEs....but even with the PINVOKES in a separate class, the code looks messy with all the marshaling. I'm also re-writing a lot of code. (B) I could create a native C++ DLL and use PINVOKE to marshal in the native data structures. I'm assuming I can include the native C++ DLL/LIB in a project using C#? (C) Create a mixed mode DLL (Native C++ class plus managed ref class). I'm assuming that this would make it easier to use the managed ref class in C#......but is this the case? Will the managed class handle all the marshaling? Can I use this mixed mode DLL on a platform with no .Net (i.e. still access the native C++ unmanaged component) or do I limit myself to .Net only platforms. One thing that bothers me about each of these options is all the marshalling. Is it better to create a managed data structure (array, string etc.) and pass that to the native C++ class, or, the other way around? Any ideas on what would be considered best practice...?

    Read the article

  • Overriding LINQ extension methods

    - by Ruben Vermeersch
    Is there a way to override extension methods (provide a better implementation), without explicitly having to cast to them? I'm implementing a data type that is able to handle certain operations more efficiently than the default extension methods, but I'd like to keep the generality of IEnumerable. That way any IEnumerable can be passed, but when my class is passed in, it should be more efficient. As a toy example, consider the following: // Compile: dmcs -out:test.exe test.cs using System; namespace Test { public interface IBoat { void Float (); } public class NiceBoat : IBoat { public void Float () { Console.WriteLine ("NiceBoat floating!"); } } public class NicerBoat : IBoat { public void Float () { Console.WriteLine ("NicerBoat floating!"); } public void BlowHorn () { Console.WriteLine ("NicerBoat: TOOOOOT!"); } } public static class BoatExtensions { public static void BlowHorn (this IBoat boat) { Console.WriteLine ("Patched on horn for {0}: TWEET", boat.GetType().Name); } } public class TestApp { static void Main (string [] args) { IBoat niceboat = new NiceBoat (); IBoat nicerboat = new NicerBoat (); Console.WriteLine ("## Both should float:"); niceboat.Float (); nicerboat.Float (); // Output: // NiceBoat floating! // NicerBoat floating! Console.WriteLine (); Console.WriteLine ("## One has an awesome horn:"); niceboat.BlowHorn (); nicerboat.BlowHorn (); // Output: // Patched on horn for NiceBoat: TWEET // Patched on horn for NicerBoat: TWEET Console.WriteLine (); Console.WriteLine ("## That didn't work, but it does when we cast:"); (niceboat as NiceBoat).BlowHorn (); (nicerboat as NicerBoat).BlowHorn (); // Output: // Patched on horn for NiceBoat: TWEET // NicerBoat: TOOOOOT! Console.WriteLine (); Console.WriteLine ("## Problem is: I don't always know the type of the objects."); Console.WriteLine ("## How can I make it use the class objects when the are"); Console.WriteLine ("## implemented and extension methods when they are not,"); Console.WriteLine ("## without having to explicitely cast?"); } } } Is there a way to get the behavior from the second case, without explict casting? Can this problem be avoided?

    Read the article

  • Ruby Methods: how to return an usage string when insufficient arguments are given

    - by Shyam
    Hi, After I have created a serious bunch of classes (with initialize methods), I am loading these into IRb to test each of them. I do so by creating simple instances and calling their methods to learn their behavior. However sometimes I don't remember exactly what order I was supposed to give the arguments when I call the .new method on the class. It requires me to look back at the code. However, I think it should be easy enough to return a usage message, instead of seeing: ArgumentError: wrong number of arguments (0 for 9) So I prefer to return a string with the human readable arguments, by example using "puts" or just a return of a string. Now I have seen the rescue keyword inside begin-end code, but I wonder how I could catch the ArgumentError when the initialize method is called. Thank you for your answers, feedback and comments!

    Read the article

  • PHP: OOP and methods

    - by Pirkka
    Hello I`ve been wondering how to implement methods in a class. Could someone explain me what means if one does OOP in procedural style? Here is an example: class Fld extends Model { private $file; private $properties = array(); public function init($file) { $this->file = $file; $this->parseFile(); } private function parseFile() { // parses the file foreach($this->file as $line)...... .................. $this->properties = $result; } } I mean is it a good thing to have methods like these that do operations for the class properties like that. Or should I pass the class property as method parameter... I mean this would cause error if the file property wouldnt be declared.

    Read the article

  • Operator Overloading with C# Extension Methods

    - by Blinky
    I'm attempting to use extension methods to add an operater overload to the C# StringBuilder class. Specifically, given StringBuilder sb, I'd like sb += "text" to become equivalent to sb.Append("text"); Here's the syntax for creating an extension method for StringBuilder: public static class sbExtensions { public static StringBuilder blah(this StringBuilder sb) { return sb; } } It successfully adds the "blah" extension method to the StringBuilder. Unfortunately, operator overloading does not seem to work: public static class sbExtensions { public static StringBuilder operator +(this StringBuilder sb, string s) { return sb.Append(s); } } Among other issues, the keyword 'this' is not allowed in this context. Are adding operator overloads via extension methods possible? If so, what's the proper way to go about it?

    Read the article

  • Automatic conversion between methods and functions in Scala

    - by fikovnik
    I would like to understand the rules when can Scala automatically convert methods into functions. For example, if I have following two methods: def d1(a: Int, b: Int) {} def r[A, B](delegate: (A, B) ? Unit) {} I can do this: r(d1) But, when overloading r it will no longer work: def r[A, B, C](delegate: (A, B, C) ? Unit) {} r(d1) // no longer compiles and I have to explicitly convert method into partially applied function: r(d1 _) Is there any way to accomplish following with the explicit conversion? def r[A, B](delegate: (A, B) ? Unit) {} def r[A, B, C](delegate: (A, B, C) ? Unit) {} def d1(a: Int, b: Int) {} def d2(a: Int, b: Int, c: Int) {} r(d1) // only compiles with r(d1 _) r(d2) // only compiles with r(d2 _) There is somewhat similar question, but it is not fully explained.

    Read the article

  • How to: Show wait cursor in managed and native code

    - by TechTwaddle
    Someone on the MSDN forum asked about how to show a wait cursor, like when your application is loading or performing some (background) task. It’s pretty simple to show the wait cursor in both managed and native code, and in this post we will see just how. Managed Code (C#) Set Cursor.Current to Cursors.WaitCursor, and call Cursor.Show(). And to come back to normal cursor, set Cursor.Current to Cursors.Default and call Show() again. Below is a button handler for a sample app that I made, (watch the video below) private void button1_Click(object sender, EventArgs e) {     lblProgress.Text = "Downloading ether...";     lblProgress.Update();     Cursor.Current = Cursors.WaitCursor;     Cursor.Show();     //do some processing     for (int i = 0; i < 50; i++)     {         progressBar1.Value = 2 * (i + 1);         Thread.Sleep(100);     }     Cursor.Current = Cursors.Default;     Cursor.Show();     lblProgress.Text = "Download complete.";     lblProgress.Update(); }   Native Code In native code, call SetCursor(LoadCursor(NULL, IDC_WAIT)); to show the wait cursor; and SetCursor(LoadCursor(NULL, IDC_ARROW)); to come back to normal. The same button handler for native version of the app is below, case IDC_BUTTON_DOWNLOAD:     {         HWND temp;         temp = GetDlgItem(hDlg, IDC_STATIC_PROGRESS);         SetWindowText(temp, L"Downloading ether...");         UpdateWindow(temp);         SetCursor(LoadCursor(NULL, IDC_WAIT));         temp = GetDlgItem(hDlg, IDC_PROGRESSBAR);         for (int i=0; i<50; i++)         {             SendMessage(temp, PBM_SETPOS, (i+1)*2, 0);             Sleep(100);         }         SetCursor(LoadCursor(NULL, IDC_ARROW));         temp = GetDlgItem(hDlg, IDC_STATIC_PROGRESS);         SetWindowText(temp, L"Download Complete.");         UpdateWindow(temp);     }     break; Here is a video of the sample app running. First the managed version is deployed and the native version next,

    Read the article

  • Magic Methods in Python

    - by dArignac
    Howdy, I'm kind of new to Python and I wonder if there is a way to create something like the magic methods in PHP (http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods) My aim is to ease the access of child classes in my model. I basically have a parent class that has n child classes. These classes have three values, a language key, a translation key and a translation value. The are describing a kind of generic translation handling. The parent class can have translations for different translation key each in different languages. E.g. the key "title" can be translated into german and english and the key "description" too (and so far and so on) I don't want to get the child classes and filter by the set values (at least I want but not explicitly, the concrete implementation behind the magic method would do this). I want to call parent_class.title['de'] # or also possible maybe parent_class.title('de') for getting the translation of title in german (de). So there has to be a magic method that takes the name of the called method and their params (as in PHP). As far as I dug into Python this is only possible with simple attributes (_getattr_, _setattr_) or with setting/getting directly within the class (_getitem_, _setitem_) which both do not fit my needs. Maybe there is a solution for this? Please help! Thanks in advance!

    Read the article

  • Threading.Timer invokes asynchronously many methods

    - by Dimitar
    Hi guys! Please help! I call a threading.timer from global.asax which invokes many methods each of which gets data from different services and writes it to files. My question is how do i make the methods to be invoked on a regular basis let's say 5 mins? What i do is: in Global.asax I declare a timer protected void Application_Start() { TimerCallback timerDelegate = new TimerCallback(myMainMethod); Timer mytimer = new Timer(timerDelegate, null, 0, 300000); Application.Add("timer", mytimer); } the declaration of myMainMethod looks like this: public static void myMainMethod(object obj) { MyDelegateType d1 = new MyDelegateType(getandwriteServiceData1); d1.BeginInvoke(null, null); MyDelegateType d2 = new MyDelegateType(getandwriteServiceData2); d2.BeginInvoke(null, null); } this approach works fine but it invokes myMainMethod every 5 mins. What I need is the method to be invoked 5 mins after all the data is retreaved and written to files on the server. How do I do that?

    Read the article

  • Generics in return types of static methods and inheritance

    - by Axel
    Generics in return types of static methods do not seem to get along well with inheritance. Please take a look at the following code: class ClassInfo<C> { public ClassInfo(Class<C> clazz) { this(clazz,null); } public ClassInfo(Class<C> clazz, ClassInfo<? super C> superClassInfo) { } } class A { public static ClassInfo<A> getClassInfo() { return new ClassInfo<A>(A.class); } } class B extends A { // Error: The return type is incompatible with A.getClassInfo() public static ClassInfo<B> getClassInfo() { return new ClassInfo<B>(B.class, A.getClassInfo()); } } I tried to circumvent this by changing the return type for A.getClassInfo(), and now the error pops up at another location: class ClassInfo<C> { public ClassInfo(Class<C> clazz) { this(clazz,null); } public ClassInfo(Class<C> clazz, ClassInfo<? super C> superClassInfo) { } } class A { public static ClassInfo<? extends A> getClassInfo() { return new ClassInfo<A>(A.class); } } class B extends A { public static ClassInfo<? extends B> getClassInfo() { // Error: The constructor ClassInfo<B>(Class<B>, ClassInfo<capture#1-of ? extends A>) is undefined return new ClassInfo<B>(B.class, A.getClassInfo()); } } What is the reason for this strict checking on static methods? And how can I get along? Changing the method name seems awkward.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >