|
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,
|
|
|
|
|
It's certainly the way I like to work. That way, I can tell whether or not I've wired my dependencies up properly.
|
|
|
|
|
hello can you help me in the code of projet :" Création d'un outil intelligent pour la vidéosurveillance" with vb.net 2008
|
|
|
|
|
No, nobody is going to just hand you code.
Ask a specific question about a problem you're having writing your own code and you might get a better answer.
|
|
|
|
|
Hello. I have this error when i load my from:
Unable to cast object of type
Private Sub followupfrm_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim myda As New SqlDataAdapter("select * from customers", mcon)
Dim myds As New DataSet
myda.Fill(myds, "customers")
cmbcustomer.DataSource = myds.Tables(0)
cmbcustomer.DisplayMember = "company"
cmbcustomer.ValueMember = "serial"
fillgrid()
End Sub
here where the error occures:
Private Sub cmbcustomer_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbcustomer.SelectedIndexChanged
txtticketnumber.Text = "9" + Format(cmbcustomer.SelectedValue, "0000")
End Sub
Any suggestions?
|
|
|
|
|
Member 10506215 wrote: Any suggestions? You may get a better chance of an answer in the Visual Basic forum. Also, show exactly which line the error shows on, and which item is the System.Data.DataRowView object.
|
|
|
|
|
The error occurs here:
txtticketnumber.Text = "9" + Format(cmbcustomer.SelectedValue, "0000")
|
|
|
|
|
|
|
|
|
Use a Try Catch Statement
Private Sub cmbcustomer_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbcustomer.SelectedIndexChanged
Try
txtticketnumber.Text = "9" + Format(cmbcustomer.SelectedValue, "0000")
Catch ex As Exception
End Try
End Sub
|
|
|
|