This is just for my reference
If we face UAC errors in windows 2003 machine
http://social.msdn.microsoft.com/Forums/en/windowssecurity/thread/40dd94a9-2b52-4f60-a3fc-653ddf4bc306
Tuesday, 8 November 2011
UAC - Important settings
Admin Approval Mode for the Built-in Administrator account: Enabled (if UAC needed). Disabled means – full privilege.
Switch to the secure desktop when prompting for elevation: Enabled, can’t select anything in background.
Run all administrators in Admin Approval Mode: Enabled (if UAC needed). Disabled means – full privilege.
Only elevate executable that are signed and validated: Disabled (as it expects exe’s to have PKI certificates).
Detect application installations and prompt for elevation: Enabled, so installation will be prompt for elevation.
Switch to the secure desktop when prompting for elevation: Enabled, can’t select anything in background.
Run all administrators in Admin Approval Mode: Enabled (if UAC needed). Disabled means – full privilege.
Only elevate executable that are signed and validated: Disabled (as it expects exe’s to have PKI certificates).
Detect application installations and prompt for elevation: Enabled, so installation will be prompt for elevation.
Friday, 4 November 2011
Installing SQL Server 2008 R2 Management Studio Express on 64bit machines
This is for my reference - http://tchmiel.wordpress.com/2010/07/01/installing-sql-server-2008-r2-management-studio-express-on-windows-7-64bit-sharepoint-development-box/
Friday, 21 October 2011
Static Reflection
Here is my example on static reflection(i have used INotifyPropertyChanged, but a simple code as i don't pass around the interface)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.ComponentModel;
namespace StaticReflection
{
public class Customer : INotifyPropertyChanged
{
private string employer = String.Empty;
private string mobile = String.Empty;
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public string Employer
{
get { return this.employer; }
set
{
if (value != this.employer)
{
this.employer = value;
NotifyPropertyChanged(this.PropertyName(c => c.Employer));
}
}
}
public string Mobile
{
get { return this.mobile; }
set
{
if (value != this.mobile)
{
this.mobile = value;
NotifyPropertyChanged(this.PropertyName(c => c.Mobile));
}
}
}
}
public static class CustomerExtensions
{
public static string PropertyName(this Customer target, Expression<Func<Customer, object>> expression)
{
return new PropertySpecifier<Customer>(expression).PropertyName;
}
}
public class PropertySpecifier<T>
{
//http://joelabrahamsson.com/entry/getting-property-and-method-names-using-static-reflection-in-c-sharp - Use this article to build a accomplished! PropertySpecifier function
public PropertySpecifier(Expression<Func<T, object>> expression)
{
if (expression == null) return;
if (expression.Body is MemberExpression)
{
this.PropertyName = (expression.Body as MemberExpression).Member.Name;
}
}
public string PropertyName
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.ComponentModel;
namespace StaticReflection
{
public class Customer : INotifyPropertyChanged
{
private string employer = String.Empty;
private string mobile = String.Empty;
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public string Employer
{
get { return this.employer; }
set
{
if (value != this.employer)
{
this.employer = value;
NotifyPropertyChanged(this.PropertyName(c => c.Employer));
}
}
}
public string Mobile
{
get { return this.mobile; }
set
{
if (value != this.mobile)
{
this.mobile = value;
NotifyPropertyChanged(this.PropertyName(c => c.Mobile));
}
}
}
}
public static class CustomerExtensions
{
public static string PropertyName(this Customer target, Expression<Func<Customer, object>> expression)
{
return new PropertySpecifier<Customer>(expression).PropertyName;
}
}
public class PropertySpecifier<T>
{
//http://joelabrahamsson.com/entry/getting-property-and-method-names-using-static-reflection-in-c-sharp - Use this article to build a accomplished! PropertySpecifier function
public PropertySpecifier(Expression<Func<T, object>> expression)
{
if (expression == null) return;
if (expression.Body is MemberExpression)
{
this.PropertyName = (expression.Body as MemberExpression).Member.Name;
}
}
public string PropertyName
{
get;
set;
}
}
}
Wednesday, 28 September 2011
Create PDB always
For my reference
http://blogs.msdn.com/b/yash/archive/2007/10/12/pdb-files-what-are-they-and-how-to-generate-them.aspx
Project > Properties > Build > Advanced > Output > Debug Info
Always create PDB
http://blogs.msdn.com/b/yash/archive/2007/10/12/pdb-files-what-are-they-and-how-to-generate-them.aspx
Project > Properties > Build > Advanced > Output > Debug Info
Always create PDB
Tuesday, 13 September 2011
Events vs Delegates
This rather confused me for a long time, but found a great article
http://blog.monstuff.com/archives/000040.html
Briefly
Events & Interfaces, Events Invocation, Event Signature and Event accessors
1. Events are ALWAYS multi-cast.
2. Events can be done away with delegates, but it is similar to exposing a Public member field than a Property.
3. Helps encapsulation - So interfaces don't support fields, but events - We can't declare delegate fields in Interface.
4. Only defined class can raise the event, but fields(delegates) can be raised outside of the class.
5. Standard signature of (sender, eventargs) - we can use EventHandler.
6. Event accessors - have add and remove - may be used for logging?
So my two cents with an example
public class MoneyWithdrawnEvent : EventArgs
{
public decimal Amount { get; set; }
public MoneyWithdrawnEvent(decimal amount)
{
this.Amount = amount;
}
}
public class BankService
{
public delegate void Notify(EventArgs e);
public event Notify amountWithdrawn;
public void Withdraw(decimal amount)
{
//Business
amountWithdrawn(new MoneyWithdrawnEvent(amount));
}
}
public class ATMService
{
IServiceFactory factory;
public ATMService(IServiceFactory factory)
{
}
public void Withdraw(decimal amount)
{
BankService service = factory.Create();
BankService.Notify notifyUser = new BankService.Notify(this.AlertUser);
notifyUser(new MoneyWithdrawnEvent(amount)); //This is wrong, as we don't the state(outcome) of the transaction, and
// allows this kind of business errors where alert before
// withdrawing money.
//service.amountWithdrawn(); 1. You can't invoke event, so it will be the responsiblity
// of bank to raise the money withdrawn.
service.Withdraw(amount);
}
private void AlertUser(EventArgs alert)
{
}
}
public interface IServiceFactory
{
BankService Create();
}
http://blog.monstuff.com/archives/000040.html
Briefly
Events & Interfaces, Events Invocation, Event Signature and Event accessors
1. Events are ALWAYS multi-cast.
2. Events can be done away with delegates, but it is similar to exposing a Public member field than a Property.
3. Helps encapsulation - So interfaces don't support fields, but events - We can't declare delegate fields in Interface.
interface Temp
{
event EventHandler notify;
EventHandler eventHandler;
}
{
event EventHandler notify;
EventHandler eventHandler;
}
4. Only defined class can raise the event, but fields(delegates) can be raised outside of the class.
5. Standard signature of (sender, eventargs) - we can use EventHandler
6. Event accessors - have add and remove - may be used for logging?
So my two cents with an example
public class MoneyWithdrawnEvent : EventArgs
{
public decimal Amount { get; set; }
public MoneyWithdrawnEvent(decimal amount)
{
this.Amount = amount;
}
}
public class BankService
{
public delegate void Notify(EventArgs e);
public event Notify amountWithdrawn;
public void Withdraw(decimal amount)
{
//Business
amountWithdrawn(new MoneyWithdrawnEvent(amount));
}
}
public class ATMService
{
IServiceFactory factory;
public ATMService(IServiceFactory factory)
{
}
public void Withdraw(decimal amount)
{
BankService service = factory.Create();
BankService.Notify notifyUser = new BankService.Notify(this.AlertUser);
notifyUser(new MoneyWithdrawnEvent(amount)); //This is wrong, as we don't the state(outcome) of the transaction, and
// allows this kind of business errors where alert before
// withdrawing money.
//service.amountWithdrawn(); 1. You can't invoke event, so it will be the responsiblity
// of bank to raise the money withdrawn.
service.Withdraw(amount);
}
private void AlertUser(EventArgs alert)
{
}
}
public interface IServiceFactory
{
BankService Create();
}
Subscribe to:
Posts (Atom)