In PHP, there is a special method named __call($calledMethodName, $arguments), which allows class to catch calls to non-existing methods, and do something about it.
Since most of classic languages are strongly typed, compiler won't allow calling a method that does not exist, I'm clear with that part.
What I want to accomplish (and I figured this is how I would do it in PHP, but C# is something else) is to proxy calls to a class methods and log each of these calls.
Right now, I have code similar to this:
class ProxyClass {
static logger;
public AnotherClass inner { get; private set; }
public ProxyClass() { inner = new AnotherClass(); }
}
class AnotherClass {
public void A() {}
public void B() {}
public void C() {}
// ...
}
// meanwhile, in happyCodeLandia...
ProxyClass pc = new ProxyClass();
pc.inner.A();
pc.inner.B();
// ...
So, how can I proxy calls to an object instance in extensible way? Extensible, meaning that I don't have to modify ProxyClass whenever AnotherClass changes.
In my case, AnotherClass can have any number of methods, so it wouldn't be appropriate to overload or wrap all methods to add logging.
I am aware that this might not be the best approach for this kind of problem, so if anyone has idea what approach to use, shoot.
Thanks!
Hello!
I'm trying to modify and set alert templates on a SP (working on a copy of alerttemplates.xml), but I'd like to deploy them just on some specific sites, not the whole farm. Is this possible? I'm using SharePoint 2010 RTM.
Thanks
In my last question I asked about parsing the links out of an HTML page. Since I haven't found a solution yet I thought I tried something else in the meantime: search for every <a href= and copy whatever is there until I hit a </a>.
Now, my C is a bit rusty but I do remember i can use strstr() to get the first instance of that string, but how do I get the rest?
Any help is appreciated.
PS: No. This is not homework on school or something like that. Just so you know.
I have an ASP.NET page that has about 40 custom controls embedded in it. The controls vary in size; in their .ascx files, the biggest is about 1,500 lines and the smaller ones are between 100 and 200 lines (markup, script, etc).
Each control is contained in a Panel. Only one of these panels is ever visible at any one time, which means only one control is ever visible at one time.
My question is this: do the controls that are invisible still send ViewState for themselves and all their children to the client? It makes sense that they might have to serialize the fact that they're invisible, but not all the state info for their children...
I am trying to connect to a server remotely using the command line client window.
I am using MySQL 5.1 and I do not know why I am getting syntax error.
If you can help me, that would be much appreciated.
username as user
password as pass
hostname as example.com
I have tried:
mysql> -u user -h example.com -p ;
mysql> -h example.com -u user -p ;
I have looked at the reference manual and other verisons of remote connection with Server 5.1 but I can't see the syntax error.
Are you an iPhone/iPad/Android programmer with a designer soul? If so we would like to hear from you.
Drop us your best work/portfolio and than we talk.
[email protected]
Cheers
T
Here's the problem: my input is XML file that looks something like:
<BaseEntityClassInfo>
<item>
<key>BaseEntityClassInfo.SomeField</key>
<value>valueData1</value>
</item>
<item>
<key>BaseEntityClassInfo.AdditionalDataClass.SomeOtherField</key>
<value>valueData2</value>
</item>
<item>
<key>BaseEntityClassInfo.AdditionalDataClass.AnotherClassInfo.DisplayedText</key>
<value>valueData3</value>
</item>
...
...
</BaseEntityClassInfo>
The <key> element somehow describes entity classes fields and relationships (used in some other app that I don't have access to) and the <value> stores the actual data that I need.
My goal is to programatically generate a typed Dataset from this XML that could then be used for creating reports. I thought of building some XSD schema from input XML file first and then use this schema to generate Dataset but I'm not sure how to do that. The problem is that I don't want all data in one table, I need several tables with relationships based on the <key> value so I guess I need to infer relational structure from XML <key> data in some way.
So what do you think? How could this be done and what would be the best approach?
Any advice, ideas, suggestions would be appreciated!
Is it considered a bad practice to pass around a large string or object (lets say from an ajax response) between functions? Would it be beneficial in any way save the response in a variable and keep reusing that variable?
So in the code it would be something like this:
var response;
$.post(url, function(resp){
response = resp;
})
function doSomething() {
// do something with the response here
}
vs
$.post(url, function(resp){
doSomething(resp);
})
function doSomething(resp) {
// do something with the resp here
}
Assume resp is a large object or string and it can be passed around between multiple functions.
I have a following string - "AACCGGTTT" (alphabet is ["A","G","C","T"]). I would like to generate all strings that differ from the original in any two positions i.e.
GAGCGGTTT
^ ^
TATCGGTTT
^ ^
How can I do it in Python?
I have only brute force solution (it is working):
generate all strings on a given alphabet with the same length
append strings that have 2 mismatches with a given string
However, could you suggest more efficient way to do so?
When looking at the log of a folder in Tortoise SVN, you can filter out files which aren't in the folder.
The checkbox says: "Hide unrelated changed paths".
How can I accomplish the same with svn log? I want the verbose output of the tool to not display file paths that aren't inside the current target.
Thanks
I have a direct3d project that uses D3DXCreateTextureFromFile() to load some images. This function takes a LPCWSTR for the path to file. I want to load a series of textures that are numbered consecutively (ie. MyImage0001.jpg, MyImage0002.jpg, etc) But c++'s crazy strings confuse me.
How do i:
for(int i=0; i < 3;i++)
{
//How do I convert i into a string path i can use with D3DXCreateTextureFromFile?
}
I'm debugging some code and wondered if there is any practical difference between $1 and \1 in Perl regex substitutions
For example:
my $package_name = "Some::Package::ButNotThis";
$package_name =~ s{^(\w+::\w+)}{$1};
print $package_name; # Some::Package
This following line seems functionally equivalent:
$package_name =~ s{^(\w+::w+)}{\1};
Are there subtle differences between these two statements? Do they behave differently in different versions of Perl?
Hi there .
I have a A=set of strings and a B=seperate string. I want to count the number of occurences in from B in A.
Example :
A:
10001
10011
11000
10010
10101
B:
10001
result would be 3.(10001 is a subset of 10001,10011,10101)
So i need a function that takes a set and string and returns an int.
int myfunc(set<string> , string){
int result;
// My Brain is melting
return result ;
}
Answers to a recent post (Any chances to imitate times() Ruby method in C#?) use the = operator in the usage examples. What does this operator do? I can't locate it in my C# book, and it is hard to search for symbols like this online. (I couldn't find it.)
if ([tempArray containsObject: [sectionInfo indexTitle]])
{
return nil;
}else
{
[tempArray addObject: [sectionInfo indexTitle]];
return [sectionInfo indexTitle];
}
return [sectionInfo indexTitle];
The code above groups the cells in alphabetical order but displays a blank header instead of the appropriate title. Could this possibly be because I did not specify the number of headers? This would naturally be a single header for every letter in the alphabet.
I want to read a binary file which was created outside of my program. One obvious way in C# to read a binary file is to define class representing the file and then use a BinaryReader and read from the file via the Read* methods and assign the return values to the class properties.
What I don't like with the approach is that I manually have to write code that reads the file, although the defined structure represents how the file is stored. I also have to keep the order correct when I read.
After looking a bit around I came across the BinaryFormatter which can automatically serialize and deserialze object in binary format. One great advantage would be that I can read and also write the file without creating additional code. However I wonder if this approach is good for files created from other programs on not just serialized .NET objects. Take for example a graphics format file like BMP. Would it be a good idea to read the file with a BinaryFormatter or is it better to manually and write via BinaryReader and BinaryWriter? Or are there any other approaches which suit better? I'am not looking for concrete examples but just for an advice what is the best way to implement that.
Is there a way to embed the last command's elapsed wall time in a Bash prompt? I'm hoping for something that would look like this:
[last: 0s][/my/dir]$ sleep 10
[last: 10s][/my/dir]$
Background
I often run long data-crunching jobs and it's useful to know how long they've taken so I can estimate how long it will take for future jobs. For very regular tasks, I go ahead and record this information rigorously using appropriate logging techniques. For less-formal tasks, I'll just prepend the command with time.
It would be nice to automatically "time" every single interactive command and have the timing information printed in a few characters rather than 3 lines.
Hi, well I know from my asp.net mvc experience that you can have attributes that handle exceptions (HandleErrorAttribute). As far as I can tell the Controller class has some OnException event which may be integral to this behaviour. However, I want to do something similar in my own code:
dream example:
public String MyProperty
{
[ExceptionBehaviour(typeof(FormatException), MyExEnum.ClearValue)]
set
{
_thing.prop = Convert.ToThing(value);
}
}
....
The code above obviously makes very little sense, but is close to the kind of thing I wish to do. I want the attribute on the property set accessor to catch some type of exception and then deal with this in some custom way (or even just swallow it).
Any ideas guys?
hi all,
i'm using c sharp and crystal reports in visual studio 2008 in my application.
the problem is that there is a form that i have crystalreporviewer on,
when i call the form from form1 by button click event, the form and the report loads perfect, but when i call the from from another from that i've called from form1, this exception appears "load report fail". how can i solve this problem. i've googled and i didn't find any solution. I think there is a difference between form1 and the other form which i call the form of the report from.
this is the code of the report form load
try {
cryRpt.Load("..\\..\\CrystalReport1.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}
thanks in advance for any replies
I am interested in hearing opinions and experiences of fellow developers on topic of designing user interface, usability AND maintainability-wise.
Common approach is to allow users to tweak options and after form gets "dirty", enable "Apply" button, and user has possibility to back out by pressing cancel. This is most common approach on Windows platform (I believe MS usability guidelines say to do so as well).
Another way is to apply changes after every single change has been made to options. Example, user checks some checkbox, and change is applied. User changes value of some text box, and change is applied after box looses focus, etc. You get the point. This approach is most common on Mac OSX.
Regardless of my personal opinion (which is that Apple is better at usability, but software I usually write targets Windows users), what do you people think?
Hi there ,
i always asked myself. Why are there so many DB management systems?
I am not an DB expert and i never thought about using another DB than mysql.
Programming languages offer different paradigms, so there it makes sense to choose a specific language for your purpose.
What are factors to choose a specific DB management system ?
Before I jump in at the very deep end and try to make my own version of Moon Pig (www.moonpig.com) I would like to know what (if any) software/platforms currently exist that allow for visitors to personalise cards with text and uploaded photos and then purchase printed versions all via a single e-Commerce style platform.
I have Googled till my fingers bled and I cannot find anything that matches my needs, which are:
admin can provide templates (backgrounds) for the cards
users can customise the card with text (font style and colour)
users can upload their own photos (minor editing e.g. crop) to insert into the cards
user can purchase a printed card via credit card payment
Seeing as this kind of e-Commerce has been around for a while now, I would have thought there were some systems to purchase that can provide this functionality?
I have a 'user' table in MySQL
When users login to my app, they can see a list of all other users and via some javascript-drag-drop can arrange which order the other users appear in. We want to save that order.
And it is saved to their record (i.e. 'order_pref' = 4,3,5,23... list of user_ids in the order they specified).
So that's fine but when it comes to displaying.. Is there an easy way I can sort based on this comma delimited list of user_ids using just one query?
unichar myChar = [myString characterAtIndex:0];
[myNSMutableArray addObject:myChar];
I am trying to insert the first char of a string into an array, to create an array of chars. the first line does not give me an error. The second line however, provides the following error: warning: passing argument 1 of 'addObject:' makes pointer from integer without a cast
This also crashes the application with a "bad address" error. I thought this error was due to a problem with memory allocation. Can someone shed some light on this.