Tuesday, February 17, 2015

Visitor pattern


Code:
class MutualFundOrderProvider
{
 private Dictionary<string,string> GetKeyValues(MutualFundOrderInfo info)
 {
  ...
 }
}

class GICOrderProvider
{
 private Dictionary<string,string> GetKeyValues(GICOrderInfo info)
 {
  ...
 }
}

class EquityOrderProvider
{
 private Dictionary<string,string> GetKeyValues(EquityOrderInfo info)
 {
  ...
 }
}

//visitor approach
//Create interface
interface IKeyValueComputer
{
 Dictionary<string,string> GetKeyValues(EquityOrderInfo info);
 Dictionary<string,string> GetKeyValues(GICOrderInfo info);
 Dictionary<string,string> GetKeyValues(MutualFundOrderInfo info)
}

//implementation
class KeyValueComputer:IKeyValueComputer
{
 //all implementations...
}

//another interface
interface IComputeKeyValues
{
 Dictionary<string,string> ComputeKeyValues(IKeyValueComputer keyvalcomp)
}

class EquityOrderInfo: IComputeKeyValues
{
 public Dictionary<string,string> ComputeKeyValues(IKeyValueComputer keyvalcomp)
 {
  return keyvalcomp.GetKeyValues(this);
 }
}

//MutualFundOrderProvider
class MutualFundOrderProvider
{
 public void Translate(MutualFundOrderInfo info)
 {
  IKeyValueComputer keyvalcomp=new KeyValueComputer();
  info.ComputeKeyValues(keyvalcomp);
 }
}

Sunday, February 15, 2015

Tuesday, February 10, 2015

Using Channel Factory

Wrapping CreateChannel for WCF calls:


Code:
//view model
public void GetEmployees()
{
 var emp = ServiceFactory.GetService<IEmployeeService>();
}

//IServiceFactory
public interface IServiceFactory
{
 T GetService<T>();
}

//ServiceFactory class
public static class ServiceFactory: IServiceFactory
{
 public T GetService<T>()
 {
  T svc = default(T);
        ChannelFactory<T> factory = new ChannelFactory<T>(typeof(T).FullName);

        //any other logic or conditions you want
        //...

        svc = factory.CreateChannel();

        return svc; 
 }
}

Thursday, February 5, 2015

Scrap One


WCF:

1. Decide which binding to use.
2. Tracing (why, how)
Use system.servicemodel.messagelogging under then add listener, output it to svclog and open the file in Traceviewer.

http://www.easyvectors.com/browse/design-elements1/design-elements-grey-spiral-free-vector

http://cdn.vectorstock.com/i/composite/71,57/abstract-icons-and-logos-vector-147157.jpg

http://t2.ftcdn.net/jpg/00/68/58/99/240_F_68589944_rV9FN8Iu2jAfl1zu3WghBU5edYYyiXoP.jpg

http://veerle.duoh.com/design/article/illustrator_full_spectrum_spirograph

http://veerle.duoh.com/design/article/photoshop_vintage_effect

http://veerle.duoh.com/design/article/creating_a_geometric_star_in_illustrator

http://veerle.duoh.com/design/article/colorful_pattern_masking_in_illustrator1

Photography ---

http://photography.tutsplus.com/tutorials/7-posing-techniques-for-non-models--photo-15608

http://www.iheartfaces.com/2012/03/photography-posing-mistakes-tutorial/

See Step 8 for colouring:
http://designinstruct.com/drawing-illustration/make-watercolor-and-marker-style-portraits-with-illustrator/

VS Extensions

https://visualstudiogallery.msdn.microsoft.com/5396fa4a-d638-471b-ac3d-671ccd2ea369 -- a must
https://visualstudiogallery.msdn.microsoft.com/d4ab8421-147f-4416-8038-d5f7fdcf6a56
https://visualstudiogallery.msdn.microsoft.com/00ec88c2-1553-47d2-8170-3c5baa0c6e44
https://visualstudiogallery.msdn.microsoft.com/dfcb2438-180c-4f8a-983b-62d89e141fe3
https://visualstudiogallery.msdn.microsoft.com/fb5badda-4ea3-4314-a723-a1975cbdabb4
https://visualstudiogallery.msdn.microsoft.com/0e33cb22-d4ac-4f5a-902f-aff5177cc94d
https://visualstudiogallery.msdn.microsoft.com/ab43a471-b840-4d81-ad6f-c9f350cfcd16

interesting--
https://visualstudiogallery.msdn.microsoft.com/d5cd6aa1-57a5-4aaa-a2be-969c6db7f88a
http://blogs.msdn.com/b/visualstudio/archive/2010/07/29/walkthrough-creating-a-custom-start-page-part-1.aspx

http://stackoverflow.com/questions/4144778/get-properties-and-values-from-unknown-object