C# 3.0 Extension methods add extensions to the base Type making calling that method on all instances of that Type legal.
Now, JavaScript I know implements IDispatchEx through which it's possible to add methods to a specific instance.
So how do I add a set of methods to an 'instance' of a C# class? I know this is a Dynamic vs. Static L...
Based on the code I've found, it seems that the Visitor is required to known the structure of the visited objects and call on the needed children. This seems a bit clunky in some cases where the visitor would want to continue to work even if the visited classes are modified.
I guess the real question is: Is their a pattern where the enu...
Say I have a visitor like this
class Visitor : IVisitor
{
void Accept(Visitable v)
{
/// other code
v.AChild.Visit(this);
v.BChild.Visit(this);
}
}
Where AChild and BChild can be of the exact same type but the visiting code needs to differentiate between them (it needs to operate differently o...
Hi there, i have a question regarding the visitor pattern, I currently have two assemblies. My first assembly contains several interfaces.
public interface INode
{
void Visit(INodeVisitor visitor);
}
public interface INodeVisitor
{
void VisitContainer(IContainer container);
}
public interface IContainer : INode
{
}
And my s...
Is there any advantage for using visitor pattern in a recursive scenario? If so can you demonstrate it programmatically?
...
I am attempting to implement the Visitor Design Pattern using OCaml's OO constructs and type system and am running into problems upon instantiation of an Element.
class virtual ['hrRep] employee = object
method virtual receiveEvaluation : 'hrRep -> unit
method virtual getName : string
end;;
class ['hrRep] accountant myName = object ...
Alrite, I am gonna jump straight to the code:
public interface Visitor {
public void visitInventory();
public void visitMaxCount();
public void visitCountry();
public void visitSomethingElse();
public void complete();
//the idea of this visitor is that when a validator would visit it, it would validate data
//when a persister visits i...
I am looking for an alternative to the visitor pattern. Let me just focus on a couple of pertinent aspects of the pattern, while skipping over unimportant details. I'll use a Shape example (sorry!):
You have a hierarchy of objects that implement the IShape interface
You have a number of global operations that are to be performed on all...
Would you say that Objective-C categories are an implementation of the visitor design pattern?
...
Can someone explain what are these referring to?
MemberReference, TypeReference, ExternType, Override, NestedType, PInvokeInfo, SecurityDeclaration and CustomAttribute and MarshalSpec
Best if can illustrate with examples. Will appreciate even if u don't know all, but still help me in understanding those u know.
Cos I am trying to write ...
I have the following code:
class Visitor
{
internal virtual void Visit(Node n) { }
}
class VisitorSpecial : Visitor
{
internal new void Visit(Node n) { }
}
class Base
{
internal virtual void Accept(Visitor v) { }
internal virtual void Accept(VisitorSpecial v) { }
}
class Node : Base
{
internal override void Acc...
Hi I am exploring ways to implement something Visitor Patterns alike without all the decorating visit methods. Sofar I found out I could use Option Strict Off in VB.NET but it has some side effects. I have a set of Shape classes that inherit from a baseclass Shape. Assume we have the following class that Accept's shapes:
Public Class Sh...
Title says it all. If it helps, the languages in question are java and c++.
...
I'm working on a library to generate SQL from LINQ expressions (basically a modified subset of LINQ-to-SQL). I'm using discriminated unions to model the SQL expressions, but have encountered some (perceived?) limitations. I want to do something like the following (note the last line):
type SqlSourceExpression =
| Table of string
...
(Disclaimer: these examples are given in the context of building a compiler, but this question is all about the Visitor pattern and does not require any knowledge of compiler theory.) I'm going through Andrew Appel's Modern Compiler Implementation in Java to try to teach myself compiler theory (so no, this isn't homework) and I'm havin...
I have been searching around for days to find an answer to this performance based issue.
After digging the Internet so far I have learned that there are couple of ways to use the Enums in java, well documented in here.
Well, definitely as a starter one would like use Enums in a switch-case statement, which provides clarity and better un...
Hello,
I'm having memory woes.
I've got a C++ Library (Equalizer from Eyescale) and they use the Traversal
Visitor Pattern to allow you to add new functionality to their classes.
I've finally figured out how it works, and I've got a Visitor that just
returns the properties from one of the objects. (since I don't know how
they'r...
With Delphi 2009 Enterprise I created code for the GoF Visitor Pattern in the model view, and separated the code in two units: one for the domain model classes, one for the visitor (because I might need other units for different visitor implementations, everything in one unit? 'Big ball of mud' ahead!).
unit VisitorUnit;
interface
use...
My collegue suggested me to write a visitor pattern to navigate the AST. Can anyone tell me more how would I start writing it?
As far as I understand, each Node in AST would have visit() method (?) that would somehow get called (from where?). That about concludes my understanding.
To simplify everything, suppose I have nodes Root, Expr...
I'm trying to use the visitor pattern to serialize the contents of objects. However one snag I'm hitting is when I'm visiting strings. My strings are of a templated type, similar to STL's basic_string. So something like:
basic_string<char_type, memory_allocator, other_possible_stuff> \\ many variations possible!
Since I can have very ...