TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
priya gopi
NA
2
2.3k
Decorator pattern
Jul 20 2012 1:00 AM
Hi,
I have a class like this
public class OrgChartBasicInfo
{
public int UserId { get; set; }
public int ManagerUserId { get; set; }
public string FullName { get; set; }
public string CompanyName { get; set; }
public string CurrentPosition { get; set; }
public string PhotoUrl { get; set; }
public string Location { get; set; }
}
Am adding these values to a List like this
private static List<OrgChartSuccessor> GetSuccessors()
{
List<OrgChartSuccessor> Successors = new List<OrgChartSuccessor>();
OrgChartSuccessor SuccessorInfo = new OrgChartSuccessor();
SuccessorInfo.UserId = 1;
SuccessorInfo.RiskOfLossLabel = "Images/orgchart-icon-lowrisk.png";
SuccessorInfo.RiskOfLossTitle = "Risk of Loss Title";
SuccessorInfo.RiskOfLossReason = "RiskOfLossReason";
SuccessorInfo.PhotoUrl = "../Images/orgchart-mondrian-medium.jpg";
SuccessorInfo.FullName = "Successor1";
SuccessorInfo.CurrentPosition = "Reg. Director of Sales ";
SuccessorInfo.Location = "Atlanta, GA";
Successors.Add(SuccessorInfo);
return Employees;
}
I want to add ChildInfo=1 also in to my list without modifying my class
I did it like this,
public class OrgChartBasicInfoEx : OrgChartBasicInfo
{
public int Collapsed {ger;set;}
}
private static List<OrgChartBasicInfo> GetEmployees()
{
List<OrgChartBasicInfo> Employees = new List<OrgChartBasicInfo>();
OrgChartBasicInfoEx ChildInfo = new OrgChartBasicInfoEx();
ChildInfo.UserId = 1;
ChildInfo.ManagerUserId = 0;
ChildInfo.FullName = "Employee1";
ChildInfo.CompanyName = "Abc Company";
ChildInfo.CurrentPosition = "Reg. Director of Sales ";
ChildInfo.Collapsed = 1;
Employees.Add(ChildInfo);
return Employees;
}
But its not adding that value to my collection as the collection is taking from "OrgChartBasicInfo" I cant modify these classes as it is given by my client
Please give me any other solution to add an additional property to my collection without modifying my class..I heard about Decorator class and something like Factory class .Can anybody tell me how can i solve my issue?
Thanks,
Priya
Reply
Answers (
0
)
How to create empty folder in UNC path
how to return string with out using global variable in C#.net