Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 36/962 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • Selectively intercepting methods using autofac and dynamicproxy2

    - by Mark Simpson
    I'm currently doing a bit of experimenting using Autofac-1.4.5.676, autofac contrib and castle DynamicProxy2. The goal is to create a coarse-grained profiler that can intercept calls to specific methods of a particular interface. The problem: I have everything working perfectly apart from the selective part. I gather that I need to marry up my interceptor with an IProxyGenerationHook implementation, but I can't figure out how to do this. My code looks something like this: The interface that is to be intercepted & profiled (note that I only care about profiling the Update() method) public interface ISomeSystemToMonitor { void Update(); // this is the one I want to profile void SomeOtherMethodWeDontCareAboutProfiling(); } Now, when I register my systems with the container, I do the following: // Register interceptor gubbins builder.RegisterModule(new FlexibleInterceptionModule()); builder.Register<PerformanceInterceptor>(); // Register systems (just one in this example) builder.Register<AudioSystem>() .As<ISomeSystemToMonitor>) .InterceptedBy(typeof(PerformanceInterceptor)); All ISomeSystemToMonitor instances pulled out of the container are intercepted and profiled as desired, other than the fact that it will intercept all of its methods, not just the Update method. Now, how can I extend this to exclude all methods other than Update()? As I said, I don't understand how I'm meant to say "for the ProfileInterceptor, use this implementation of IProxyHookGenerator". All help appreciated, cheers! Also, please note that I can't upgrade to autofac2.x right now; I'm stuck with 1.

    Read the article

  • Nested factory methods in Objective-C

    - by StephenT
    What's the best way to handle memory management with nested factory methods, such as in the following example? @implementation MyClass + (MyClass *) SpecialCase1 { return [MyClass myClassWithArg:1]; } + (MyClass *) SpecialCase2 { return [MyClass myClassWithArg:2]; } + (MyClass *) myClassWithArg:(int)arg { MyClass *instance = [[[MyClass alloc] initWithArg:arg] autorelease]; return instance; } - (id) initWithArg:(int)arg { self = [super init]; if (nil != self) { self.arg = arg; } return self; } @end The problem here (I think) is that the autorelease pool is flushed before the SpecialCaseN methods return to their callers. Hence, the ultimate caller of SpecialCaseN can't rely on the result having been retained. (I get "[MyClass copyWithZone:]: unrecognized selector sent to instance 0x100110250" on trying to assign the result of [MyClass SpecialCase1] to a property on another object.) The reason for wanting the SpecialCaseN factory methods is that in my actual project, there are multiple parameters required to initialize the instance and I have a pre-defined list of "model" instances that I'd like to be able to create easily. I'm sure there's a better approach than this.

    Read the article

  • Alternatives to static methods on interfaces for enforcing consistency

    - by jayshao
    In Java, I'd like to be able to define marker interfaces, that forced implementations to provide static methods. For example, for simple text-serialization/deserialization I'd like to be able to define an interface that looked something like this: public interface TextTransformable<T>{ public static T fromText(String text); public String toText(); Since interfaces in Java can't contain static methods though (as noted in a number of other posts/threads: here, here, and here this code doesn't work. What I'm looking for however is some reasonable paradigm to express the same intent, namely symmetric methods, one of which is static, and enforced by the compiler. Right now the best we can come up with is some kind of static factory object or generic factory, neither of which is really satisfactory. Note: in our case our primary use-case is we have many, many "value-object" types - enums, or other objects that have a limited number of values, typically carry no state beyond their value, and which we parse/de-parse thousands of time a second, so actually do care about reusing instances (like Float, Integer, etc.) and its impact on memory consumption/g.c. Any thoughts?

    Read the article

  • Multiple leaf methods problem in composite pattern

    - by Ondrej Slinták
    At work, we are developing an PHP application that would be later re-programmed into Java. With some basic knowledge of Java, we are trying to design everything to be easily re-written, without any headaches. Interesting problem came out when we tried to implement composite pattern with huge number of methods in leafs. What are we trying to achieve (not using interfaces, it's just an example): class Composite { ... } class LeafOne { public function Foo( ); public function Moo( ); } class LeafTwo { public function Bar( ); public function Baz( ); } $c = new Composite( Array( new LeafOne( ), new LeafTwo( ) ) ); // will call method Foo in all classes in composite that contain this method $c->Foo( ); It seems like pretty much classic Composite pattern, but problem is that we will have quite many leaf classes and each of them might have ~5 methods (of which few might be different than others). One of our solutions, which seems to be the best one so far and might actually work, is using __call magic method to call methods in leafs. Unfortunately, we don't know if there is an equivalent of it in Java. So the actual question is: Is there a better solution for this, using code that would be eventually easily re-coded into Java? Or do you recommend any other solution? Perhaps there's some different, better pattern I could use here. In case there's something unclear, just ask and I'll edit this post.

    Read the article

  • interface variables are final and static by default and methods are public and abstract

    - by sap
    The question is why it's been decided to have variable as final and static and methods as public and abstract by default. Is there any particular reason for making them implicit,variable as final and static and methods as public and abstract. Why they are not allowing static method but allowing static variable? We have interface to have feature of multiple inheritance in Java and to avoid diamond problem. But how it solves diamond problem,since it does not allow static methods. In the following program, both interfaces have method with the same name..but while implementing only one we implement...is this how diamond problem is solved? interface testInt{ int m = 0; void testMethod(); } interface testInt1{ int m = 10; void testMethod(); } public class interfaceCheck implements testInt, testInt1{ public void testMethod(){ System . out . println ( "m is"+ testInt.m ); System . out . println ( "Hi World!" ); } }

    Read the article

  • Repository Pattern Standardization of methods

    - by Nix
    All I am trying to find out the correct definition of the repository pattern. My original understanding was this (extremely dubmed down) Separate your Business Objects from your Data Objects Standardize access methods in data access layer. I have really seen 2 different implementations. Implementation 1 : public Interface IRepository<T>{ List<T> GetAll(); void Create(T p); void Update(T p); } public interface IProductRepository: IRepository<Product> { //Extension methods if needed List<Product> GetProductsByCustomerID(); } Implementation 2 : public interface IProductRepository { List<Product> GetAllProducts(); void CreateProduct(Product p); void UpdateProduct(Product p); List<Product> GetProductsByCustomerID(); } Notice the first is generic Get/Update/GetAll, etc, the second is more of what I would define "DAO" like. Both share an extraction from your data entities. Which I like, but i can do the same with a simple DAO. However the second piece standardize access operations I see value in, if you implement this enterprise wide people would easily know the set of access methods for your repository. Am I wrong to assume that the standardization of access to data is an integral piece of this pattern ? Rhino has a good article on implementation 1, and of course MS has a vague definition and an example of implementation 2 is here.

    Read the article

  • Using delegate Types vs methods

    - by Grant Sutcliffe
    I see increasing use of the delegate types offered in the System namespace (Action; Predicate etc). As these are delegates, my understanding is that they should be used where we have traditionally used delegates in the past (asynchronous calls; starting threads, event handling etc). Is it just preference or is it considered practice to use these delegate types in scenarios such as the below; rather than using calls to methods we have declared (or anonymous methods): public void MyMethod { Action<string> action = delegate(string userName { try { XmlDocument profile = DataHelper.GetProfile(userName); UpdateMember(profile); } catch (Exception exception) { if (_log.IsErrorEnabled) _log.ErrorFormat(exception.Message); throw (exception); } }; GetUsers().ForEach(action); } At first, I found the code less intuitive to follow than using declared or anonymous methods. I am starting to code this way, and wonder what the view are in this regard. The example above is all within a method. Is this delegate overuse.

    Read the article

  • Unit test approach for generic classes/methods

    - by Greg
    Hi, What's the recommended way to cover off unit testing of generic classes/methods? For example (referring to my example code below). Would it be a case of have 2 or 3 times the tests to cover testing the methods with a few different types of TKey, TNode classes? Or is just one class enough? public class TopologyBase<TKey, TNode, TRelationship> where TNode : NodeBase<TKey>, new() where TRelationship : RelationshipBase<TKey>, new() { // Properties public Dictionary<TKey, NodeBase<TKey>> Nodes { get; private set; } public List<RelationshipBase<TKey>> Relationships { get; private set; } // Constructors protected TopologyBase() { Nodes = new Dictionary<TKey, NodeBase<TKey>>(); Relationships = new List<RelationshipBase<TKey>>(); } // Methods public TNode CreateNode(TKey key) { var node = new TNode {Key = key}; Nodes.Add(node.Key, node); return node; } public void CreateRelationship(NodeBase<TKey> parent, NodeBase<TKey> child) { . . .

    Read the article

  • Working with multiple GIT severs

    - by th3flyboy
    Hello, I have a question. Is it possible to set up a system so that you have a private GIT server that you host, which automatically syncs with a remote one, hosted by a site like Sourceforge, and then you can commit your local to the private GIT server, and then when you have to merge the changes from your private wip branches that are on your private GIT over to the master/branch/tag from the public GIT, and then push the change to the public GIT? I ask this because I have a lot of personal work I would like to get working before putting it up for the public to see, and I'm shifting between several computers/operating systems in the process. If this is not possible in standard GIT, are there any other options that would allow me to do this? Thanks, Peter

    Read the article

  • Simultaneous private and public inheritance in C++

    - by gspr
    Suppose a class Y publicly inherits a class X. Is it possible for a class Z to privately inherit Y while publicly inheriting X? To make this clearer, suppose X defines public methods x1 and x2. Y inherits X, overrides x1 and provides a method y. Does C++ allow for a third class Z to subclass Y in such a way that Y's implementation of x1 and y are privately available to it, while the outside world only sees it inheriting X publicly, i.e. having only a single public method x2?

    Read the article

  • Private Accessor for method is not found

    - by Farinha
    I'm getting this error when generating a new unit test under Visual Studio 2010 using the context menu (right-click the method name - "Generate Unit Tests"): Private Accessor for methodName is not found. Please rebuild the containing project or run the Publicize.exe manually. The method is public (checked that by applying applying a filter to not show non-public methods in the "Generate Unit Tests" dialog. Visual Studio creates some kind of .accessor file automatically. Do I need to do anything in it? What else could be the problem?

    Read the article

  • Javascript: Inherit method from base class and return the subclass's private variable

    - by marisbest2
    I have the following BaseClass defined: function BaseClass (arg1,arg2,arg3) { //constructor code here then - var privateVar = 7500; this.getPrivateVar = function() { return privateVar; }; } I want to have the following subclass which allows changing privateVar like so: function SubClass (arg1,arg2,arg3,privateVar) { //constructor code here then - var privateVar = privateVar; } SubClass.prototype = new BaseClass(); Now I want SubClass to inherit the getPrivateVar method. However, when I try this, it always returns 7500 which is the value in the BaseClass and not the value of privateVar. In other words, is it possible to inherit a BaseClass's public methods but have any references in them refer to the SubClass's properties? And how would I do that?

    Read the article

  • is 'protected' ever reasonable outside of virtual methods and destructors?

    - by notallama
    so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn't mark them public because you don't want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don't want people to rely on behaviour that you're going to change later. so, why is it okay for that nincompoop to use those fields and methods from a subclass? as far as i can tell, they can still screw up in the same ways, and the same compatibility issues still exist if you change the implementation. the cases for protected i can think of are: non-virtual destructors, so you can't break things by deleting the base class. virtual methods, so you can override 'private' methods called by the base class. constructors in c++. in java/c# marking the class as abstract will do basically the same. any other use cases?

    Read the article

  • Could a singleton type replace static methods and classes?

    - by MKO
    In C# Static methods has long served a purpose allowing us to call them without instantiating classes. Only in later year have we became more aware of the problems of using static methods and classes. They can’t use interfaces They can’t use inheritance They are hard to test because you can’t make mocks and stubs Is there a better way ? Obviously we need to be able to access library methods without instantiated classes all the time otherwise our code would become pretty cluttered One possibly solution is to use a new keyword for an old concept: the singleton. Singleton’s are global instances of a class, since they are instances we can use them as we would normal classes. In order to make their use nice and practical we'd need some syntactic sugar however Say that the Math class would be of type singleton instead of an actual class. The actual class containing all the default methods for the Math singleton is DefaultMath, which implements the interface IMath. The singleton would be declared as singleton Math : IMath { public Math { this = new DefaultMath(); } } If we wanted to substitute our own class for all math operations we could make a new class MyMath that inherits DefaultMath, or we could just inherit from the interface IMath and create a whole new Class. To make our class the active Math class, you'd do a simple assignment Math = new MyMath(); and voilá! the next time we call Math.Floor it will call your method. Note that for a normal singleton we'd have to write something like Math.Instance.Floor but the compiler eliminates the need for the Instance property Another idea would be to be able to define a singletons as Lazy so they get instantiated only when they're first called, like lazy singleton Math : IMath What do you think, would it have been a better solution that static methods and classes? Is there any problems with this approach?

    Read the article

  • Designing interfaces: predict methods needed, discipline yourself and deal with code that comes to m

    - by fireeyedboy
    Was: Design by contract: predict methods needed, discipline yourself and deal with code that comes to mind I like the idea of designing by contract a lot (at least, as far as I understand the principal). I believe it means you define intefaces first before you start implementing actual code, right? However, from my limited experience (3 OOP years now) I usually can't resist the urge to start coding pretty early, for several reasons: because my limited experience has shown me I am unable to predict what methods I will be needing in the interface, so I might as well start coding right away. or because I am simply too impatient to write out the whole interfaces first. or when I do try it, I still wind up implementing bits of code already, because I fear I might forget this or that imporant bit of code, that springs to mind when I am designing the interfaces. As you see, especially with the last two points, this leads to a very disorderly way of doing things. Tasks get mixed up. I should draw a clear line between designing interfaces and actual coding. If you, unlike me, are a good/disciplined planner, as intended above, how do you: ...know the majority of methods you will be needing up front so well? Especially if it's components that implement stuff you are not familiar with yet. ...resist the urge to start coding right away? ...deal with code that comes to mind when you are designing the interfaces? UPDATE: Thank you for the answers so far. Valuable insights! And... I stand corrected; it seems I misinterpreted the idea of Design By Contract. For clarity, what I actually meant was: "coming up with interface methods before implementing the actual components". An additional thing that came up in my mind is related to point 1): b) How do you know the majority of components you will be needing. How do you flesh out these things before you start actually coding? For arguments sake, let's say I'm a novice with the MVC pattern, and I wanted to implement such a component/architecture. A naive approach would be to think of: a front controller some abstract action controller some abstract view ... and be done with it, so to speak. But, being more familiar with the MVC pattern, I know now that it makes sense to also have: a request object a router a dispatcher a response object view helpers etc.. etc.. If you map this idea to some completely new component you want to develop, with which you have no experience yet; how do you come up with these sort of additional components without actually coding the thing, and stuble upon the ideas that way? How would you know up front how fine grained some components should be? Is this a matter of disciplining yourself to think it out thoroughly? Or is it a matter of being good at thinking in abstractions?

    Read the article

  • Understanding Ruby class vs instance methods

    - by randombits
    I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts "Hello" p.chatter end private def chatter puts "Chattering" end end p = Person.new Person.speak I'd like to make chatter private, accessible only within p.. but I want p to be able to access it within the class method. Is there a better way to design this so chatter isn't available to the public, but a "factory" method like self.speak can call chatter?

    Read the article

  • TeamCity GitHub Private Key Access Denied

    - by Chance Robertson
    Does anyone know of a tutorial for using TeamCity with github with ssh private keys. I have tried to set up git hub to connect and I either get a authentication error or get access denied. I am running TeamCity on Windows 2003. I am running the build agent as a custom account. I am running the web server under the administrator account. I have create a key for the custom account and administrator account. I now get an error that: The connection test failed: com.jcraft.jsch.JSchException: java.io.FileNotFoundException: C:\Documents and Settings\Administrator.ssh (Access is denied) If anyone has successfully set this up please help. I am going on 3 hours into this and want to get it solved. Thanks.

    Read the article

  • private c# project hosting - plugin in visual studio

    - by b0x0rz
    is there a project hosting for c# code and that has a simple to use visual studio plugin? does not need to be free. it does need to be private. should have a plugin or already by usable from within visual studio. something like a hosted team foundation server would be best, however i only found one and for $150 per user per month. a bit much, don't you think :P the problem with searching via google is that there is a lot of free project hostings for open source and can't seem to weed them out :( thnx a lot for any info

    Read the article

  • Java: initialization problem with private-final-int-value and empty constructor

    - by HH
    $ javac InitInt.java InitInt.java:7: variable right might not have been initialized InitInt(){} ^ 1 error $ cat InitInt.java import java.util.*; import java.io.*; public class InitInt { private final int right; InitInt(){} public static void main(String[] args) { // I don't want to assign any value. // just initialize it, how? InitInt test = new InitInt(); System.out.println(test.getRight()); // later assiging a value } public int getRight(){return right;} } Initialization problem with Constructor InitInt{ // Still the error, "may not be initialized" // How to initialise it? if(snippetBuilder.length()>(charwisePos+25)){ right=charwisePos+25; }else{ right=snippetBuilder.length()-1; } }

    Read the article

  • C#: IComparable implementation private

    - by Anonymous Coward
    Hello I'm new to C# so this might be a really dump question: I implemented IComparable in my class and want to test it with NUnit. But the CompareTo-Method is marked as private and thus not accessible from the test. What's the reason for this and how can I fix this? The IComparable: public class PersonHistoryItem : DateEntity,IComparable { ... int IComparable.CompareTo(object obj) { PersonHistoryItem phi = (PersonHistoryItem)obj; return this.StartDate.CompareTo(phi.StartDate); } } The test: [TestMethod] public void TestPersonHistoryItem() { DateTime startDate = new DateTime(2001, 2, 2); DateTime endDate = new DateTime(2010, 2, 2); PersonHistoryItem phi1 = new PersonHistoryItem(startDate,endDate); PersonHistoryItem phi2 = new PersonHistoryItem(startDate, endDate); Assert.IsTrue(phi1.CompareTo(phi2)==0); }

    Read the article

  • Private VCS hosts for school projects?

    - by Ibrahim
    I want to use version control for a partner project for school, but these days it seems like there are no private, free VCS hosts that I could use. I would prefer to use git if possible, but I wouldn't mind SVN. Alternatively, if there aren't any, shouldn't there be some way for me to use git without a central repository? I don't know enough about git, but I assume that is the point of a DVCS, no? I've considered scp'ing a clone of the repository to my school unix account and then giving my partner access to that, but it seems like it would be a bit of a pain. What are your thoughts/suggestions? Edit: I do know of one site called xp-dev, but I'm not sure how much I trust it. But I could use that and use git-svn on my side, since my partner has actually only ever used svn. But still wondering if there are any alternatives.

    Read the article

  • Why can't sub-packages see package private classes?

    - by Polaris878
    Okay so, I have this project structure: package A.B class SuperClass (this class is marked package private) package A.B.C class SubClass (inherits from super class) I'd rather not make SuperClass publicly visible... It is really just a utility class for this specific project (A.B). It seems to me that SubClass should be able to see SuperClass, because package A.B.C is a subpackage of A.B... but this is not the case. What would be the best way to resolve this issue? I don't think it makes sense to move everything in A.B.C up to A.B or move A.B down to A.B.C... mainly because there will probably be an A.B.D which inherits from stuff in A.B as well... I'm a bit new to Java, so be nice :D (I'm a C++ and .NET guy)

    Read the article

  • Best CMS for doing private site with Charting

    - by anderswid
    I'm really new to website development and for a project I need: No public pages. All private. Login+Password (Users, Admins) Being able to upload XML-files from Android device Parse this XML into something I can plot. Easy charting. Admin users being able to read all sub-users uploads. Doesn't have to look good. No blog-post. Strictly XML-Charts. I thought about using Wordpress, but I don't know if it's the best idea. I can code, but I don't have to much PHP + MySQL experience. Maybe there's something simpler? Thanks for taking the time.

    Read the article

  • error: 'QTabWidget::QTabWidget(const QTabWidget&)' is private

    - by Mahdi_Nine
    I develop a program and I have 10 backups of it. I added some lines to it and when I compiled the project and now it has the following error: C:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets\qtabwidget.h:173: error: 'QTabWidget::QTabWidget(const QTabWidget&)' is private the error is from * line namespace Ui { class ContentControl; } class ContentControl : public QTabWidget // * from this line { Q_OBJECT public: . . . } All backups have this error now. Any idea why? I re-installed Qt but the problem is still present.

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >