/// <summary>
/st-header">
Flyweight Pattern
Flyweight allows you to share bulky data which are common to each object. In other words, if you think that same data is repeating for every object, you can use this pattern to point to the single object and hence can easily save space.
/// </summary>
public
class
FlyWeight
{
public
string
Company {
get
;
set
; }
public
string
CompanyLocation {
get
;
set
; }
public
string
CompanyWebSite {
get
;
set
; }
//Bulky Data
public
byte
[] CompanyLogo {
get
;
set
; }
}
public
static
class
FlyWeightPointer
{
public
static
FlyWeight Company =
new
FlyWeight
{
Company =
"Abc"
,
CompanyLocation =
"XYZ"
,
CompanyWebSite =
"www.abc.com"
};
}
public
class
MyObject
{
public
string
Name {
get
;
set
; }
public
FlyWeight Company
{
get
ing
Name {
get
{
return
FlyWeightPointer.Company;
}
}
}
Here the FlyweightPointer creates a static member Company, which is used for every object of MyObject.