Click here to Skip to main content
15,918,742 members
Home / Discussions / C#
   

C#

 
GeneralRe: Font Dialog Box Pin
jaypatel51224-Mar-09 2:33
jaypatel51224-Mar-09 2:33 
GeneralRe: Font Dialog Box Pin
fungweizz24-Mar-09 21:44
fungweizz24-Mar-09 21:44 
GeneralRe: Font Dialog Box Pin
jaypatel51225-Mar-09 5:58
jaypatel51225-Mar-09 5:58 
GeneralRe: Font Dialog Box Pin
fungweizz25-Mar-09 15:01
fungweizz25-Mar-09 15:01 
GeneralRe: Font Dialog Box Pin
jaypatel51225-Mar-09 20:04
jaypatel51225-Mar-09 20:04 
QuestionTextbox in Microsoft Reporting Services question Pin
Programm3r12-Mar-09 20:38
Programm3r12-Mar-09 20:38 
AnswerRe: Textbox in Microsoft Reporting Services question Pin
Programm3r12-Mar-09 23:50
Programm3r12-Mar-09 23:50 
QuestionHow to diff two versions of same object ? Pin
dkfjdkfjk12-Mar-09 20:35
dkfjdkfjk12-Mar-09 20:35 
I want to compare two objects of different versions and display there differences in UI.

First I call a method to know if there is any difference between the two objects

The method is as -

public bool AreEqual(object object1,object object2, Type comparisionType)

If the above method returns true

I call GetDifferences method to get the differences which is as -

public ObjectDifference[] GetObjectDifferences(object object1, object object2, Type comparisionType)
{

ArrayList memberList = new ArrayList();
ArrayList differences = new ArrayList();

memberList.AddRange(comparisionType.GetProperties());
memberList.AddRange(comparisionType.GetFields());

for (int loopCount = 0; loopCount < memberList.Count; loopCount++)
{
object objVal1 = null;
object objVal2 = null;
MemberInfo member = ((MemberInfo)memberList[loopCount]);
switch (((MemberInfo)memberList[loopCount]).MemberType)
{
case MemberTypes.Field:
objVal1 = object1 != null ?((FieldInfo)memberList[loopCount]).GetValue(object1):null;
objVal2 = object2 != null?((FieldInfo)memberList[loopCount]).GetValue(object2):null;
break;
case MemberTypes.Property:
// object temp = ((PropertyInfo)memberList[loopCount]).
objVal1 = object1!= null ?((PropertyInfo)memberList[loopCount]).GetValue(object1, null) :null;
objVal2 = object2 != null? ((PropertyInfo)memberList[loopCount]).GetValue(object2, null):null;
break;
default:
break;
}

if (AreValuesDifferentForNull(objVal1, objVal2))
{
ObjectDifference obj = new ObjectDifference(objVal1, objVal2, member,member.Name);
differences.Add(obj);
}
else if (AreValuesDifferentForPrimitives(objVal1, objVal2))
{
ObjectDifference obj = new ObjectDifference(objVal1, objVal2, member, member.Name);
differences.Add(obj);
}
else if (AreValuesDifferentForList(objVal1, objVal2))
{
ObjectDifference[] listDifference = GetListDifferences((ICollection)objVal1, (ICollection)objVal2,member);
differences.AddRange(listDifference);
}
else if ((!AreValuesEqual(objVal1, objVal2)) &&( objVal1 != null || objVal2 != null))
{

ObjectDifference obj = new ObjectDifference(objVal1, objVal2, member, member.Name);
differences.Add(obj);
}



}
return (ObjectDifference[])differences.ToArray(typeof(ObjectDifference));
}


public class ObjectDifference
{
private readonly object objectValue1;
private readonly object objectValue2;
private readonly System.Reflection.MemberInfo member;
private readonly string description;

public object ObjectValue1 {
get { return objectValue1; }
}
public object ObjectValue2 {
get { return objectValue2; }
}
public System.Reflection.MemberInfo Member {
get { return member; }
}
public string Description {
get { return description; }
}

public ObjectDifference(object objVal1,object objVal2,System.Reflection.MemberInfo member,string description)
{
this.objectValue1 = objVal1;
this.objectValue2 = objVal2;
this.member = member;
this.description = description;
}

For each difference I create an object of type ObjectDifference and add it to the array. The highlighted portion is the one where I am stuck! If the object contains another complex object, My program does give me the differences but I dont know which type it belonged to

For example I have two objects of type Name

class Name{

string firstName;
string LastName;

List<phonenumber> phNumber;
}

class PhoneNumber{

string officeNo;
string MobileNo;
string HomeNo;
}

while comparing two objects the output I get is plain -

firstname - John Mary
LastName- cooper Lor

officeNo - 22222 44444
MobileNo - 989898 089089
HomeNo-- 4242 43535


The Hierarchy that officeNo is of type PhoneNumber is lost. which is important for me to display

How should I maintain this type of tree while creating differences.

Hope I am able to make my problem understood.
QuestionPass value from .dll to windows application Pin
yesu prakash12-Mar-09 20:34
yesu prakash12-Mar-09 20:34 
AnswerRe: Pass value from .dll to windows application Pin
stancrm12-Mar-09 21:15
stancrm12-Mar-09 21:15 
QuestionHow to all close by clicking the cross? Pin
soulidentities12-Mar-09 20:26
soulidentities12-Mar-09 20:26 
AnswerRe: How to all close by clicking the cross? Pin
jaypatel51212-Mar-09 21:07
jaypatel51212-Mar-09 21:07 
GeneralRe: How to all close by clicking the cross? Pin
soulidentities12-Mar-09 23:13
soulidentities12-Mar-09 23:13 
GeneralRe: How to all close by clicking the cross? Pin
jaypatel51213-Mar-09 3:00
jaypatel51213-Mar-09 3:00 
GeneralRe: How to all close by clicking the cross? Pin
soulidentities13-Mar-09 4:29
soulidentities13-Mar-09 4:29 
GeneralRe: How to all close by clicking the cross? Pin
jaypatel51213-Mar-09 4:33
jaypatel51213-Mar-09 4:33 
QuestionProblem using Environment.OSversion? Pin
Reddy Prakash12-Mar-09 20:24
Reddy Prakash12-Mar-09 20:24 
AnswerRe: Problem using Environment.OSversion? Pin
Spunky Coder12-Mar-09 20:37
Spunky Coder12-Mar-09 20:37 
AnswerRe: Problem using Environment.OSversion? Pin
dan!sh 12-Mar-09 20:40
professional dan!sh 12-Mar-09 20:40 
Questionneed helps,comment system. Pin
peacefulheart12-Mar-09 19:44
peacefulheart12-Mar-09 19:44 
AnswerRe: need helps,comment system. Pin
0x3c012-Mar-09 21:05
0x3c012-Mar-09 21:05 
QuestionGroove-Import files in Issue Tracking tool using any technology (dotnet,java..etc.) Pin
Member 259548812-Mar-09 19:43
Member 259548812-Mar-09 19:43 
QuestionProperties Pin
Illegal Operation12-Mar-09 19:23
Illegal Operation12-Mar-09 19:23 
GeneralImplementing single-sign-on in an asp.net web application Pin
Siffon12-Mar-09 19:07
Siffon12-Mar-09 19:07 
GeneralRe: Implementing single-sign-on in an asp.net web application Pin
Abhijit Jana12-Mar-09 19:18
professionalAbhijit Jana12-Mar-09 19:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.