|
Yes the input will be provided during installation (Say username), I want to validate this. Where should I write code to check this validation?
|
|
|
|
|
I was able to add a user interface but not able to do any validations to it as I don't know where exactly I can refer the user interface I added.
So, I decided to do it another way. i.e run my application exe after the installation. My application has a windows form which accepts user details and can validate through code behind.
In this case I don't want to show "Installation Complete" screen. I want my application to be launched instead of "Installation Complete" screen. How can I do this?
Can you please help me in this?
|
|
|
|
|
I have a method that I am exploring that takes in generic parameters.
public void Test<t,x>(t source, x destination) {
what I am trying to do is determine if x is either a collection or a class anything else should throw an exception.
The collection on I got by using the following
if(destination is ICollection<x>)
But my Googlefu keeps bring me back to the Type class and all I keep using is the IsAnsiClass but this registers true even if I pass an integer variable.
Is there a way to determine if the destination variable is a class?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I may well be misunderstanding you here, but...anything that isn't a class is a struct in C#, so won't this work:
public void Test<t,x>(t source, x destination)
{
if (!(destination is ValueType))
{
Console.WriteLine("Class");
}
else
{
Console.WriteLine("Not Class");
}
}
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
You hit the nail on the head there Griff thank you..
I blame my stupidness on a lack of Coffee
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I frequently try the same; sadly no one believes me...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Of course, if you want to restrict the input so that you only accept class types, just add where x : class as the generic constraint.
|
|
|
|
|
Thanks Pete, I was aware of the where t: class .
The end game that I was trying to achieve as a learning experiment was to create my own version of Automapper to allow me to convert either EF tables or single rows from tables.
The second part of the learning was to create a single class that would act as a facade to the whole process and direct the conversion depending on weather it was a BindingList, List or class.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
modified 25-Mar-14 16:14pm.
|
|
|
|
|
Sweet. I look forward to seeing an article on this as it sounds absolutely fascinating.
|
|
|
|
|
The problem that I see in what you're doing is that you're checking for the passed in type at run-time. The whole point behind Generics is that you treat the T as a template at compile-time, preventing you from writing invalid code before you even compile it.
Pete's solution takes care of that little problem by limiting what types can be passed in as you're writing the code.
|
|
|
|
|
I was aware of suggestion that Pete made where X : class
I was experimenting with basically creating my own version of Automapper as a learning exercise that would allow me to convert EF tables or single rows form the tables into business objects to use outside of the data layer.
I was trying to use a single facade class to act as the start of the conversion process which would then direct the data depending on the type that X was i.e. BindingList, List or class.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
In the sample code below, how can i set varying column widths for each column individually? The DescriptionColumnName width is expected to be much wider than other columns and Col1Name is not expected to be equal to Col2Name in width?. Currently, all columns are being returned with the same column width, and the description column in most cases contains alot of free text, so i want to reduce the width of columns Col1Name & Col2Name and then increase DescriptionColumnName width.
Document document;
document.NewPage();
System.Collections.ArrayList columnWidth = new System.Collections.ArrayList();
for (int i = 0; i < this.dataTable.Columns.Count; i++)
{
if (i < 2)
{
columnWidth.Add(2f);
}
else
{
columnWidth.Add(1f);
}
}
float[] headerWidths = columnWidth.OfType<float>().Select(w => (float)w).ToArray();
PdfPTable tableHeader = new PdfPTable(3);
tableHeader.AddCell(GetCell(Col1Name));
tableHeader.AddCell(GetCell(Col2Name));
tableHeader.AddCell(GetCell(DescriptionColumnName));
tableHeader.SetWidths(headerWidths);
tableHeader.HeaderRows = 1;
PopulatePDFCell(tableHeader);
document.Add(tableHeader);
|
|
|
|
|
Guys,
Am struck up with a scenario below,
I have 50 "Subfolder" under my "MainFolder"
In my project, On selecting a "Add Applications" button am browsing to MainFolder and selecting the same.
Now all the subfolders under the MainFolder need to be populated in the DataGird View, in my Project.
I tried with few commands which i got by browsing in blog, but not successfull.
Please assist, how can i acheive this.
Cheers,
|
|
|
|
|
What code do you have right now? When you say you want all subfolders to be populated in the DataGrid view, what exactly do you mean by this? Do you just want the folder names or do you want the contents of those folders as well? Do you need to keep iterating so that you pick up the entire folder tree under the main folder (i.e. subfolders of subfolders)?
|
|
|
|
|
I want to show a file under the SubFolder, (*.SFT)
MainFolder(is what am selecting)---> SubFolders--> (*.SFT) files
for e.g. 10 subfolder = 10 (*.SFT) files in it, to be listed in the DataGrid.
i use the below code to get the FolderPath.
string FldrPath = "";
// Create a new instance of FolderBrowserDialog.
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
FldrPath = folderBrowserDialog1.SelectedPath;
}
MessageBox.Show(FldrPath);
Cheers,
|
|
|
|
|
Below is some simple code that will get you started. This isn't the most flexible code that you can use but it should allow you to get started on the problem.
Personally I would build up a collection (Array, List or DataTable) and assign that as a data source.
Also it will only show the folders in the directory which you have specified and not each folders sub directory's.
DataGridViewTextBoxColumn first = new DataGridViewTextBoxColumn();
first.Name = "Name";
first.HeaderText = "Name";
dataGridView1.Columns.Add(first);
DataGridViewTextBoxColumn second = new DataGridViewTextBoxColumn();
second.Name = "FullName";
second.HeaderText = "Full Path";
dataGridView1.Columns.Add(second);
DirectoryInfo dir = new DirectoryInfo(@"d:\documents");
foreach (DirectoryInfo subDir in dir.GetDirectories())
{
dataGridView1.Rows.Add(new string[] { subDir.Name, subDir.FullName });
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
According to the expert across the aisle, I can download and install a free version of C# from Microsoft's website.
I just looked, can't find it.
My friendly expert says that the one I want is Visual C# 2010.
Can someone point me to the right place ?
|
|
|
|
|
You're talking about the Express editions. If you want Visual C# Express 2010 you can find it here[^]. There are more up to date versions available (2012 and 2013).
|
|
|
|
|
Pete to the rescue ! Hooray, nice to know somebody who knows something.
I see the two other versions you mentioned also have "Express Editions" as well.
Can I install all three ?
|
|
|
|
|
They do, but I wouldn't advise trying to install all three. Basically, 2012 introduced .NET 4.5 which you could think of as a patch to .NET 4 (it introduced some new features and fixed some bugs in the .NET 4 assemblies), so while you could develop .NET 4 applications with it, they might not behave on a machine that just has .NET 4 installed on it.
Of course, if you want the features introduced in 4.5, then you need to go for 2012 as a minimum, but if you're doing that you are better off going straight to 2013.
|
|
|
|
|
Here's what's going on.
We have a small box that does magic.
We have an existing minimalist interface that sends commands to it, and tells us what it gets back.
Friday, I learned that we have access to the source code, and I can write my own stuff, and make the thing really smart; i.e.,
If I send X,then wait for him to respond with Y
If he responds with Z instead, then go do Blah, Blah, Blah
Anyway, that kind of smarts.
Should I stick with 2010, or go for the new kid on the block ?
|
|
|
|
|
If it were my project, I would stick with 2010 based on the fact that what you have currently works with this and you don't want to introduce any issues.
|
|
|
|
|
|
|
I didnt ask about the meaning of life, but I guess its not C#?
|
|
|
|