|
Here is my experience.
You will have overall performance boost by using OOPS and Generics.
I have a project where I have used many classes and many generics almost in the same way as you are doing it. We did a performance test by bombarding with several request to the project and it performed better as against using OOPS without generics (many many classes and hence objects).
Generics gives the ability to precast and late binding, and also once loaded in memory it stays there to be consumed upon request.
|
|
|
|
|
Why not just use the build in List< U>.ForEach(instance.Act)?
If you need to use IEnumerable, then a trivial extension method would work:
static void ActOnABunchOfStuff< U>(IEnumerable< U> bunch, Action< U> action)<br />
{ foreach(var stuff in bunch) action(stuff); }
Use with:
int[] foo = {1,2,3,4,5};<br />
ActOnABunchOfStuff(foo, doItTarget.Act);
VB-i-cise it at your leisure
|
|
|
|
|
Why not just use the build in List< U>.ForEach(instance.Act)?
Are you assuming Action< U> is a delegate for a void function that takes a single parameter of type U? I'm not terribly familiar with C# syntax, and I don't see any declaration for Action.
Also, I would guess that the last statement was supposed to be ActOnABunchOfStuff< integer>(foo, doItTarget.Act); but the board gobbled up what it thought was a tag?
If all the items in the list are of the same concrete type, I suppose that approach would work, at the expense of generating lots of silly little wrapper functions. Maybe that's no worse than generating silly little classes, but the generics approach I describe could offer another benefit that might be harder to achieve without generics: one could have a list of objects and do an enumerated invoke with something like if typeof(it) is iAct(of T) Then CType(it, iAct(of T)).Act(whatever). Not sure what the performance of that would be, but it would allow one to achieve a form of event handling without requiring every item to create a delegate for every different event that it supports. One could do such 'typeof/is' testing in a wrapper function, but that would seem a bit inelegant.
|
|
|
|
|
With that last statement, the type parameter U is inferred (at least in C#) from the type of foo (which is as you say an int).
System.Action(Of T) is in mscorlib, and has the signature you guessed. Theres also a couple of others with extra parameters.
I may have got a little confused with what you are trying to achieve. Invoking a method on each instance in a list, passing the same parameters?
I would use the equivalent of listOfThings.ForEach(x => x.SomeMethod(p1,p2,p3,etc));. This might be a little messy in VB though.
|
|
|
|
|
The basic concept is that I have an class for objects that contain a number of objects that the class doesn't really understand in detail (an iEnumerable is a common example of such a thing, though hardly the most sophisticated) and I would like for code outside the class to be able to invoke methods on some or all of the objects within, generally passing the same parameters to all. In some regards similar to delegates, except (1) delegates are hard-wired for particular method-object pairs, and (2) there is no need to hold the method info for a delegate without holding a hard reference to the object.
One class I created using this approach (which seems to work nicely, though I haven't benchmarked its behavior in a program with hundreds of classes) manages something like event subscription, but using weak references. Any number of objects may subscribe to a 'publisher' object; performing .Exec(of T) on the publisher object will cause it to call function iAct(of T).Act on any subscribed object supporting interface iAct(of T). Subscription and unsubscription are O(1), non-locking, and thread-safe; an object will be unsubscribed if it (1) gets garbage-collected, (2) uses the Unsubscribe method of the Subscription object returned when the object originally subscribed, or (3) one of its iAct(of T) functions returns True when invoked.
My original intended application for this class would be in an application where a number of forms have controls that affect the same properties and should thus all affect each other. While events provide a nice way to achieve much of that functionality, all the forms need a reference to an object that will support all of the events they need. If new events are added, the linking object will have to be extended to support them. Worse, using events creates the possibility of memory or resource leaks if any objects don't get properly disposed. Finalizers won't do any good if delegates keep objects alive forever.
Using my actionLink class avoids these difficulties; if I create a class called e.g. volumeChangedParam, I can call Exec(of volumeChangedParam) on my event publisher object and any subscribed object that supports an iAct(of volumeChangedParam) will have its iAct(of volumeChangedParam).Act function called. The actionLink class doesn't have to know anything about volumeChangedParam or any of the other classes it works with; additional classes could be added to support other operations.
All this stuff seems to work fine, but I wouldn't want to engineer too much of a system around it if it turned out that, e.g. the .net framework performs wonderfully when an application uses less than a certain number of classes, and starts dogging badly if the application uses more.
|
|
|
|
|
Trying to build a dynamic datatable and not sure how to define a blob column.
eg
DataTable dt = new DataTable();
dt.Columns.Add("uid");
dt.Columns.Add("test", Type.GetType("System.String"));
dt.Columns.Add("MyBlob",???
|
|
|
|
|
DataTable dt = new DataTable();
dt.Columns.Add("uid");
dt.Columns.Add("test", Type.GetType("System.String"));
dt.Columns.Add("MyBlob",Type.GetType("System.Object"));
Just a guess, haven't run it through the compiler
I are troll
|
|
|
|
|
If you're going to store the blob into database, write the contents to a file etc, I think it would be easiest to use byte[] , so you could write:
dt.Columns.Add("MyBlob", typeof(byte[]));
Just a sidenote, you could use typeof operation instead of using Type.GetType("...") like:
dt.Columns.Add("test", typeof(string));
One advantage is that if you make a typo, the compiler sees it and won't compile. If you write
dt.Columns.Add("test", Type.GetType("System.Striiiiiiing"));
it will compile but you will get an exception at runtime.
|
|
|
|
|
you can use Object, string or even byte[] type.
|
|
|
|
|
First of all I need to say I'm not an expert .NET programmer
I'm working in a Windows environment (using VB.NET) and I need to launch
an X Command over a Linux machine. On the Windows environment I have installed
an X emulator.
I found that the SharpSSH library from Tamir Gal web site should solve my problem, but
testing the example "SshExeTest" I cannot visualize any graphical interface (e.g. Xclock display)
while it seems to be possible as reported in the README.txt file at the SharpSsh example web page
Could someone provide me information about this topic and (possibly) a code snippet in order to
properly execute the X command?
Many many thanks...
|
|
|
|
|
Hi Guys,
I've got a custom VirtualPageProvider setup and running locally on Cassini, but when i deployed it, i found i had problems with the virtual files. I have added tracing and both the FileExists() method and GetFile() methods are called by pages that physically exist in the website (i.e. Default, Login) and are noted in the log, however, the virtual pages I'm trying to access never even hit the FileExists() method, and instead return a 404 error.
The file types are .wmv and .jpg, and i have tried including the following in my config file:
<add verb="GET,HEAD,POST" path="*.jpg" type="System.Web.StaticFileHandler" validate="true" />
<add verb="GET,HEAD,POST" path="*.wmv" type="System.Web.StaticFileHandler" validate="true" />
Without any success.
I have no idea what the hell is going on here, anyone got any ideas?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
modified on Monday, January 19, 2009 10:49 AM
|
|
|
|
|
I assume you mean a VirtualPathProvider (not Page).
There is not enough info to help.
Things to try if you haven't already:
1. Write an empty wrapper for all VirtualPathProvider methods and set a breakpoint in each, check which, if any are called.
2. Write a simple IHttpHandler to use as the static file handler, again set a breakpoint in ProcessRequest and follow it.
I had to do both to get my first vpp working.
I use System.Web.StaticFileHandler with vpp's and it works, StaticFileModule however does not.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi CMK,
I have made both a wrapper for the VirtualPath and an HTTP handler. The VPP gets hit by non virtual pages, but not for virtual pages. The Http handler does not get hit for virtual pages.
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Other things to check:
You aren't using a url rewrite engine, or any IHttpModule, that isn't vpp aware, i.e. it's failing the request as file not found.
The static file isn't being handled by a handler earlier in the chain (earlier in the web.config file).
As mentioned i had to fiddle for a while to get things just right. In particular i return a merged VirtualDirectory from GetDirectory and merged CacheDependency from GetCacheDependency.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
as title,
Develope Tool in PPC,C#???
i do want to get the tool i can use it develop pragrom in PPC
thank you~
|
|
|
|
|
You can do this using Visual Studio with the Smart Device project type.
«_Superman_»
|
|
|
|
|
thanks
but i waner develope pragroms in PPC
for example Python for windows mobile
|
|
|
|
|
A PocketPC is a smart device?
I are troll
|
|
|
|
|
i cant find a good tool about c# in PPC
now using PythonCE :P
|
|
|
|
|
ox0101 wrote: i cant find a good tool about c# in PPC
You don't have Visual Studio?
only two letters away from being an asset
|
|
|
|
|
Hi all ,
What i want to understand is , why isn't it enough to sign with a public key .
Public key guarantees that either my code or its hash hasn't been tampered .
Private key -as I've been told - guarantees the identity of who made the assembly , how is that ??
Assume that i made a bad code , and signed it with private and public key that match , and then claim that this assembly has been made by Microsoft .
What's the purpose of signing with private key before shipping the dll ?
Another question ,
What happens to the delayed-public-signed hash code when i finally sign with a private key (just before release) ?
|
|
|
|
|
bolly-81 wrote: Private key -as I've been told - guarantees the identity of who made the assembly , how is that ??
Because the key is private to you. You don't ever give the private key to anyone else. The only person that could have made the assembly is the person with the private key.
bolly-81 wrote: Assume that i made a bad code , and signed it with private and public key that match , and then claim that this assembly has been made by Microsoft .
But your private key would not match Microsoft's private key, and so you are unable to do that.
bolly-81 wrote: What's the purpose of signing with private key before shipping the dll ?
To authenticate where the assembly came from. As I said, only you have the private key.
|
|
|
|
|
I think you're misunderstanding how the public/private key thing works. You encrypt something (or sign something) with either key (it, technically, doesn't matter which,). This creates an encrypted package that only the other key can decrypt. So, of the case of signing an assembly, you sign with the private key (the one you give to noone else on this planet!), and only the public key (the one you give to everyone) can verify the signature on the assembly. If the public key doesn't work, the assembly wasn't signed with the matching private key, thereby warning the code/user the assembly has been tampered with.
|
|
|
|
|
If all you have is a digital signature produced by some public key, and you don't have any idea where that public key really came from, the signature isn't worth much.
There are, however, a some ways in which signatures can be worth something:
-1- If you have two signatures, both produced using the same public key, you can tell both signatures were produced by a person or persons with access to the same private key.
-2- If you have received a copy of a person's public key via some reliable channel, or even if you have a good cryptographic hash of the key, then you can confirm that a document signed using that public key was indeed signed using the person's private key.
-3- There exist a number of entities which will sign a certificate containing a public key and statement of identity; these companies make their living from the trust other people place in their certificates, so if someone asks for a certificate that says "Microsoft" the certificate authority will confirm that the person requesting the certificate has authority to act on Microsoft's behalf.
Most computers have a list of trusted root certificate authorities and their public keys. A full digital certificate might contain the following:
-a- A digitially signed affirmation by root signature authority that a particular public key from Bob's Certificate House is valid.
-b- A statement signed by Bob's Certificate House indicating that a particular key belongs to Acme Software.
-c- A statement signed by Acme Software indicating that a particular key may be used to validate its Whizbang products.
-d- A statement signed with the Whizbang products key indicating that a particular piece of software is valid.
Things are a little more complicated than that, to allow for the possibility of signature revocation, but the idea is that there is a chain of trust so that the root-level signature authorities don't have to validate every single piece of software that's supposed to be signed. If all the entities in the chain can be trusted (both to avoid signing anything they shouldn't, and to keep their key secure) then the final signature should be trusted. If any entity is dubious, so is the signature.
|
|
|
|
|
thanks man,
what about the delayed signing
i know why do we use it , (to keep our private key safe till we launch the final project)
Delayed signing stands for signing with only a "Public Key" , till we're done with the development then we "Actually sign it with the private key"
that's what i've red in lots of articles and msdn .
And that's what most confused me , because private key can never be exported , plus , the hash is already encrypted with the public key , hence , the delayed signing (with public key only)suppose to be sufficient
or , what do they mean by Actually sign it??
What do you think ??
|
|
|
|
|