|
vasuarya wrote: Please send it as soon as possible...
Please forward $1,000,000 to me and I can assure you that I will make this my top priority.
|
|
|
|
|
Any thoughts, though Math and Forms.Application class have all static methods Math class is static while Application is declared as sealed?
I can see that methods in Math class are kind of independent from each other, any other reason you know?
|
|
|
|
|
Mirani Ajay wrote: Any thoughts, though Math and Forms.Application class have all static methods Math class is static while Application is declared as sealed?
You only need one math-class, and having it static makes it faster by eliminating the lookup for the correct object.
Now, the "static" keyword is not there to prevent inheritance; it's there to make sure that there's only one instance of the class (a singleton). The sealed-keyword is there to prevent inheritance.
Application is a special object, containing MarshallByRefObject's - I guess that's the reason why it's not simply a static class.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How about so you can use them without declaring an instance of the class??
Seems a little obvious to me....
|
|
|
|
|
Dave Kreskowiak wrote: How about so you can use them without declaring an instance of the class?? I'd say that's an too easy answer; only the method needs to be static to get that particular behaviour. The class doesn't need be static nor sealed. Or, in other words, item C already does what you say, without A or B being considered.
static class A
{
public static void FooBar() { }
}
sealed class B
{
public static void FooBar() { }
}
class C
{
public static void FooBar() { }
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yep, but then again, the question isn't real specific either.
|
|
|
|
|
In .NET 1.0 / 1.1, both the System.Math [^] and System.Windows.Forms.Application [^] classes were sealed with a private constructor.
When static classes were introduced in .NET 2.0, the Math class was updated to take advantage of this new construct, but it looks like the System.Windows.Forms.Application wasn't.
Looking at the source[^], the class doesn't have any instance members, and is never instantiated, so it would have made sense to change it to a static class. However, this change wouldn't make any significant difference, so it's unlikely that it will ever be changed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Mirani Ajay wrote: s Math class is static while Application is declared as sealed? ...Any thoughts,
Microsoft programmers are human just like the rest of us and their implementations are thus subject to the same irregularities that any other programmer might create.
|
|
|
|
|
Hi Friends!I want to make Vb.net application with romanies to Nepali Unicode.(When I type roman text in vb.net control(text box),there should change text into Nepali unicode). Please help me.
|
|
|
|
|
You will need to find or write a program that will translate between the two.
|
|
|
|
|
Is the translitaration of Nepali defined well enough? At least such that the Nepali version can be exactly deduced from the romanized version?
By the way, I'd suggest to process the romanized input not after each keystroke, rather after some "phrase", e.g. after spaces, commas, or on the Leave event of the textbox: Indian alphabets are syllable-centric, with the vocals being written before/after/on top/below/around the consonant (I don't know for Nepali, but that's an Indian alphabet too, isn't it?).
|
|
|
|
|
yes, Nepali is like indian. Please help me. I need romanized input to nepali after space.
Bishnu
|
|
|
|
|
Steps
1. Determine which Unicode character set you are using. Call this U1.
2. Determine what character set will be used in the text box. Call this L1.
3. Determine the span of characters in L1 which must be mapped to U1.
4. Find all of the characters in U1 that correspond to those found in 3.
5. Determine HOW you will store the data from U1. You CANNOT use a string.
6. Create a map of the data from 4 to 5.
7. Implement 6 storing the data as specified in 5.
|
|
|
|
|
I created one windows service and i need to set specific time i.e at 9 AM daily once in windows service.
How to achieve this. If anybody knows please reply me.
thanks in advance.
|
|
|
|
|
|
I have several classes that wrap native API functions. In those classes I have declared private P/Invoke methods to carry out the class' purpose. My question is a style question from FXCop telling me that I should move those private P/Invoke methods to a NativeMethods class and thus make them available to the entire assembly. One of these messages is
Quote: CA1060 Move P/Invokes to NativeMethods class Because it is a P/Invoke method, 'OSInterface.iniWrapper.GetPrivateProfileSection(ByRef String, Byte(), Integer, ByRef String)' should be defined in a class named NativeMethods, SafeNativeMethods, or UnsafeNativeMethods.
My question is what is considered correct? I consider this to be erroneous because following this advise breaks OO design.
Mike Ober
|
|
|
|
|
obermd wrote: My question is what is considered correct? Whatever you want it to be.
obermd wrote: I consider this to be erroneous because following this advise breaks OO design. OO-design are guidelines; you won't go to jail if you break them.
I think FxCop is giving good advice here, as the WinAPI is a giant black box we interop to. It's a single, static object. It's also not much work to have an extra class as a layer in between - you'd simply be calling a static method on a static class, instead of interop directly. The huge (!) advantage is that all your WinAPI prototypes are centralized. That makes maintenance easier; I'd rather update the signature once then in a dozen classes.
TL;DR: following OO-design would break the DRY-principle.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I can see your point, but when you consider that many of the WinAPIs are designed to work as teams and some of them you have to call twice to get the actual size of the data before you can use the call to get the data my position is that if I have a dotNet class that is the sole user of an API call it should have the P/Invoke interface internally.
Obviously if it's an API call that will be used in multiple places it should be in a global NativeMethods static class.
I just had a thought - what if I create a private NativeMethods static class for this object? I'll have to give that a try this evening. That would have dual benefits - the API calls will be obvious when reading the class source and it keeps APIs that are specific to supporting that class in the class source code and not dependent on another source file.
|
|
|
|
|
I just modified the class in question to have a private static class for the P/Invokes (it's in VB)
Private NotInheritable Class NativeMethods
Public Declare ...
End Class
FXCop didn't throw the CA1060 warning. Apparently it's just looking for the NativeMethods class anywhere. This satisfies both FXCop and OO Design. This private class forces the P/Invoke calls to be obvious and it allow the containing class to be understood by itself.
|
|
|
|
|
Hi,
I have developed a ASP.net Website (Razor 2) in VS 2012. I have a class which sent mail using System.Web.Helpers.WebMail.Send() method. This method has 13 Parameters and it works fine locally.
After uploading the same project on TFS 2012 it gives exception stating too many arguments for System.Web.Helpers.WebMail.Send() method.
Below is the Snippet of code which works fine before adding to TFS 2012
WebMail.Send(EmailTo, MailHeader, MailBody, EmailFrom, , , False, , "abc@gmail.com", , , , )
Error after adding on TFS 2012
Too many arguments to 'Public Shared Sub Send(to As String, subject As String, body As String, [from As String = Nothing], [cc As String = Nothing], [filesToAttach As System.Collections.Generic.IEnumerable(Of String) = Nothing], [isBodyHtml As Boolean = True], [additionalHeaders As System.Collections.Generic.IEnumerable(Of String) = Nothing])'
Regards.
Thanks.
|
|
|
|
|
This is an ASP.NET question, please post in the correct forum.
|
|
|
|
|
Hello,
I am hoping this makes sense.
I am developing an application which will be a plugin inside of an existing application. The application has DirectX output that is placed in a WPF container/window.
I would like to get a "handle" on that DirectX output such that I can change basic properties of that Output such as switching to a stereoscopic 3d display, switching said output to full screen, etc.
I am not trying to manipulate the objects/information/etc. of that output, just how it is presented.
Any direction I can head in?
Thank you.
|
|
|
|
|
Hello All,
I am working on the correct usage of IOCContainer(Autofac) in a project which has mulitple assemblies. I am not able to understand the nested dependency pattern correctly as well as what would be the best exception handling strategy in case of failed resolves.
The post is not concise, as I am afraid I cannot explain my confusion in a brief manner. So apologies..
I am trying to use the 'constructor injection pattern' instead of 'property' or 'method' injection. so a class which looked like this:
Class Foo()
{
private static readonly IDependency = IOCContainer.Resolve<IDependency>();
}
is changed to something like this
Class Foo(IDependency dependency)
{
private readonly IDependency = dependency;
}
however after cleaning up the whole code with the constructor pattern, the code looks like this
Class Foo(){
public Foo(IDependency dependency)
{
this.dependency = dependency;
....
var bar = new Bar(this.dependency);
}
}
Class Bar{
public Bar(IDependency dependency)
{
this.dependency = dependency;
}
}
Now if the dependency was not available (IOCContainer failed to resolve this dependency), Foo will pass that dependency around, without worrying about the failed resolved call..
I think that given this scenario, the property or method injection methods seem correct as all the classes are directly calling IOCContainer resolves and then they would have a way to check if the dependency was resolved or not directly from the IOCContainer.
However A null check or a try catch can be applied when we access the dependency anyways even with the constructor injection pattern, for e.g.
class Bar()
{
public SomeMethod()
{
(dependency != null ? dependency.doSomething : throw new Exception(DependencyNotAvailable);
}
}
Is it correct approach? How should I handle the exceptions from IOCContainer otherwise?
Thanks in advance,
Preaa
|
|
|
|
|
I see some things in your code which I would change, and this should hopefully clear things up for you. Basically, you're mixing up IoC with newing stuff. If I were you, I would change the implementations to something like this:
public interface IBar
{
void DoSomethingInteresting();
}
public class Bar : IBar
{
private IDependency dependency;
public Bar(IDependency dependency)
{
if (dependency == null) throw new ArgumentNullException("dependency");
this.dependency = dependency;
}
public void DoSomethingInteresting() {}
}
public class Foo
{
private IDependency dependency;
private IBar bar;
public Foo(IDependency dependency, IBar bar)
{
if (dependency == null) throw new ArgumentNullException("dependency");
if (bar == null) throw new ArgumentNullException("bar");
this.dependency = dependency;
this.bar = bar;
}
public void DoSomething()
{
bar.DoSomethingInteresting();
}
} As you can see, we're relying on injecting any dependencies here (i.e. injecting IBar rather than newing up Bar), and we test in the constructor for nulls. That way, we determine early on whether or not an actual implementation has been passed in.
|
|
|
|
|
Thanks for the answer Pete,
This clears my confusion..
Fail early (throw exception in the constructor) is the preferred way.
Regards,
|
|
|
|