Tuesday, February 28, 2017


Adding XML config files along with package using Installshield 2016

> Installation Designer Tab> Left panel -> System Configuration

* Create a component for your existing development XML file and include the XML file in it. Set all of the attributes for the file properly (key file, target location, etc.)

*  Switch to XML view and use the import wizard. Only import the keys you want to change

* Once the wizard is done, select the file itself and set the XML File Destination to match the XML file you're modifying.

* Change the search patterns for the keys you want to modify. For some reason, the IDE shows this as the Element Name - this is actually the XPath query to find the element. 

* Delete anything in the attributes section that you aren't trying to change

*  Set the Value of your attribute as necessary  and set the operation to Append Value.

* Switch to advanced view and make sure that only "Update first matching element only" is checked (unless you want to replace multiple, identical elements )

Tuesday, January 17, 2012

Delegates Real Example.....

static void Main()
{
var mycar = new Car(20, 100, "baachi");
mycar.RegisterWithCarEngine(OnCarEngineEvent);
//NOW SPEED UP THE CAR
for (int i = 0; i < 6; i++)
{
mycar.AccelerateSpeed(20);
Console.ReadLine();
}
}
public class Car
{
#region Properties
public string PetName { get; set; }
public int MaximumSpeed { get; set; }
public int CurrentSpeed { get; set; }
#endregion
public Car()
{
MaximumSpeed = 100;
}
public Car(int currentSpeed, int maximumSpeed, string petName)
{
CurrentSpeed = currentSpeed;
MaximumSpeed = maximumSpeed;
PetName = petName;
}
//Define delegate
public delegate void CarEngineHandler(string msgForCaller);
private CarEngineHandler _listOfHandlers;
private bool carIsDead;
//registration function for the caller
public void RegisterWithCarEngine(CarEngineHandler methodToCall)
{
_listOfHandlers = methodToCall;
}
public void AccelerateSpeed(int speed)
{
//If this car is dead Send dead message.......
if (carIsDead)
{
if (_listOfHandlers != null)
{
_listOfHandlers("Sorry BOSS : Car Is Dead: OOOOPS");
}
}
else
{
CurrentSpeed += speed;
// If this car is almost dead,
if (MaximumSpeed - CurrentSpeed == 10 && _listOfHandlers != null)
{
_listOfHandlers("Carefull Buddy: Gonna Blow:::");
}
}
if (CurrentSpeed > MaximumSpeed)
{
carIsDead = true;
}
else
{
Console.WriteLine("Current Speed is :{0}", CurrentSpeed);
}
}
}

Call back functions

A callback method is one which is passed as an argument from another method which is invoked due to some kind of event. The 'call back' nature of the argument is that it returns it's result to the method that provided it as an argument - that is to say that it 'calls back' with the return value of the callback method.//An innocuous looking method which will become known as a callback method
//because of the way in which we will invoke it.
int meaningOfLife(void) {
return 42;
}
//An innocuous looking method which just takes an int and prints it to screen
void Print_A_Number(int a_Number) {
System.out.print(a_Number);
}
//invoking a method which passes another method as an argument in reaction to an event (the 'another' method - meaningOfLife - is therefore called a callback method) and the event - main() - is that the program is starting
void main() {
Print_A_Number(meaningOfLife);
}
Callbacks are so-called due to their usage with pointer languages. If you don't use one of those, don't labour over the name 'callback'. Just understand that it is just a name to describe a method that's supplied as an argument to another method, such that when that method is called (whatever condition, such as a button click, a timer tick etc) the callback method is therefore invoked, which returns a result to the calling method, which in turn returns a result to the event.

Call back functions

A callback method is one which is passed as an argument from another method which is invoked due to some kind of event. The 'call back' nature of the argument is that it returns it's result to the method that provided it as an argument - that is to say that it 'calls back' with the return value of the callback method.//An innocuous looking method which will become known as a callback method
//because of the way in which we will invoke it.
int meaningOfLife(void) {
return 42;
}
//An innocuous looking method which just takes an int and prints it to screen
void Print_A_Number(int a_Number) {
System.out.print(a_Number);
}
//invoking a method which passes another method as an argument in reaction to an event (the 'another' method - meaningOfLife - is therefore called a callback method) and the event - main() - is that the program is starting
void main() {
Print_A_Number(meaningOfLife);
}
Callbacks are so-called due to their usage with pointer languages. If you don't use one of those, don't labour over the name 'callback'. Just understand that it is just a name to describe a method that's supplied as an argument to another method, such that when that method is called (whatever condition, such as a button click, a timer tick etc) the callback method is therefore invoked, which returns a result to the calling method, which in turn returns a result to the event.

Wednesday, July 28, 2010

Best Example for StringBuilder

protected string GetRandomString(int numChars)
{
StringBuilder sb = new StringBuilder();
Random rand = new Random();
for (int i = 0; i < numChars; i++)
{
sb.Append(Convert.ToChar(rand.Next(32, 127)));
}
return (sb.ToString());
}

Tuesday, July 27, 2010

Attributes and Custom Attributes .Net

Why Attributes? and Custom attributes
Attributes are elements that allow you to add declarative information to your programs. This declarative information is used for various purposes during runtime and can be used at design time by application development tools. For example, there are attributes such as DllImportAttribute that allow a program to communicate with the Win32 libraries. Another attribute, ObsoleteAttribute, causes a compile-time warning to appear, letting the developer know that a method should no longer be used. When building Windows forms applications, there are several attributes that allow visual components to be drag-n-dropped onto a visual form builder and have their information appear in the properties grid. Attributes are also used extensively in securing .NET assemblies, forcing calling code to be evaluated against pre-defined security constraints. These are just a few descriptions of how attributes are used in C# programs.
The reason attributes are necessary is because many of the services they provide would be very difficult to accomplish with normal code. You see, attributes add what is called metadata to your programs. When your C# program is compiled, it creates a file called an assembly, which is normally an executable or DLL library. Assemblies are self-describing because they have metadata written to them when they are compiled. Via a process known as reflection, a program's attributes can be retrieved from its assembly metadata. Attributes are classes that can be written in C# and used to decorate your code with declarative information. This is a very powerful concept because it means that you can extend your language by creating customized declarative syntax with attributes.
This tutorial will show how to use pre-existing attributes in C# programs. Understanding the concepts and how to use a few attributes, will help in finding the multitude of other pre-existing attributes in the .NET class libraries and use them also.

Monday, April 5, 2010

get the permissions of your sql sevrer

SELECT * FROM fn_my_permissions(NULL, 'SERVER');USE AdventureWorks;SELECT * FROM fn_my_permissions (NULL, 'DATABASE');GO