Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: Text Won't Show in MessageBox [modified] Pin
Rogenator7-Jul-06 11:15
Rogenator7-Jul-06 11:15 
AnswerRe: Text Won't Show in MessageBox Pin
cje7-Jul-06 11:51
cje7-Jul-06 11:51 
GeneralRe: Text Won't Show in MessageBox Pin
MartyExodus11-Jul-06 9:24
MartyExodus11-Jul-06 9:24 
GeneralRe: Text Won't Show in MessageBox Pin
Dustin Metzgar11-Jul-06 9:50
Dustin Metzgar11-Jul-06 9:50 
QuestionDrawing on Map Pin
Sandy Saroha7-Jul-06 4:51
Sandy Saroha7-Jul-06 4:51 
AnswerRe: Drawing on Map Pin
Jun Du7-Jul-06 5:17
Jun Du7-Jul-06 5:17 
AnswerRe: Drawing on Map [modified] Pin
Shaun Wilde7-Jul-06 5:19
Shaun Wilde7-Jul-06 5:19 
QuestionUsing C# .NET 2 and Generic ReadOnly Collections Pin
satvinder12345677-Jul-06 4:30
satvinder12345677-Jul-06 4:30 
I am developing a Save method in my business Process that allows me to Save the current object (scheme) and all it child collection objects, so that all I need to do is call bp.Save(Scheme) and it saves via reflection the entire tree.

I have a class "Scheme" which contains as properties a number of ReadOnlyCollections e.g. ReadOnlyCollections<milestone> and ReadOnlyCollections<partner>.

"Milestone", "Partner" and "Scheme" have a "Save" method and inherit from the same object (hcdbEntity).

I want use Reflection to call the "Save" method on the Scheme and each Milestone in the collection(becuase I have many other collections hanging off Scheme and Milestone) and don't want to hard code.

When I view the property info for the scheme I have to check for contains "ReadOnlyCollection" as the property.PropertyName holds "ReadOnlyCollection'1".

property.PropertyType = {Name = "ReadOnlyCollection`1" FullName = "System.Collections.ObjectModel.ReadOnlyCollection`1[[Business.Entity.Scheme.SchemeMilestone, Business.Entity.Scheme, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"}

The currentValue that gets returned by calling the Invoke method returns a list of the seperate items in the collection, but gives me no way to process them individually, or get a handle on them to call the Invoke method to call their Save method, or to be able to transverse down the tree to call collections further down as required.

private void DoA(HcdbEntityClass entity)
{
Type t = null;
System.Reflection.PropertyInfo[] properties;
object currentValue = null;
t = entity.GetType();
properties = t.GetProperties();
foreach (PropertyInfo property in properties)
{
Type a = property.GetType();
if (property.PropertyType.Name.Contains("ReadOnlyCollection"))
{
currentValue = t.InvokeMember(property.Name, BindingFlags.GetProperty, null, entity, new object[0], CultureInfo.CurrentCulture);
}
}
}

I am assuming that I need to return a object and use the generic.MakeGenericType to regenerate the collection type for the object. I have spent more than a day trying without sucesss, anybody done this sort of thing before and have a small sample;), or am what I am doing impossible.

nearly bald
Cry | :(( Mad | :mad: Confused | :confused:
Satvinder
AnswerRe: Using C# .NET 2 and Generic ReadOnly Collections Pin
Not Active7-Jul-06 4:51
mentorNot Active7-Jul-06 4:51 
AnswerRe: Using C# .NET 2 and Generic ReadOnly Collections Pin
Josh Smith7-Jul-06 4:52
Josh Smith7-Jul-06 4:52 
AnswerRe: Using C# .NET 2 and Generic ReadOnly Collections Pin
Ennis Ray Lynch, Jr.7-Jul-06 8:19
Ennis Ray Lynch, Jr.7-Jul-06 8:19 
GeneralRe: Using C# .NET 2 and Generic ReadOnly Collections Pin
satvinder12345679-Jul-06 12:07
satvinder12345679-Jul-06 12:07 
QuestionSendKeys problem Pin
psyonara7-Jul-06 4:12
psyonara7-Jul-06 4:12 
AnswerRe: SendKeys problem Pin
Judah Gabriel Himango7-Jul-06 4:42
sponsorJudah Gabriel Himango7-Jul-06 4:42 
Questiondate format in different countries ? help pls... Pin
cmpeng347-Jul-06 4:07
cmpeng347-Jul-06 4:07 
AnswerRe: date format in different countries ? help pls... Pin
Not Active7-Jul-06 4:15
mentorNot Active7-Jul-06 4:15 
AnswerRe: date format in different countries ? help pls... Pin
Dustin Metzgar7-Jul-06 4:17
Dustin Metzgar7-Jul-06 4:17 
Question@ Pin
fmardani7-Jul-06 3:46
fmardani7-Jul-06 3:46 
AnswerRe: @ Pin
AETaylor7-Jul-06 3:51
AETaylor7-Jul-06 3:51 
AnswerRe: @ Pin
Not Active7-Jul-06 3:55
mentorNot Active7-Jul-06 3:55 
AnswerRe: @ Pin
Dustin Metzgar7-Jul-06 4:10
Dustin Metzgar7-Jul-06 4:10 
GeneralRe: @ Pin
fmardani7-Jul-06 4:12
fmardani7-Jul-06 4:12 
Questiontimeout expired.timeout period elapsed prior to completion of the operation or the server is not responding [modified] Pin
ayyp7-Jul-06 3:30
ayyp7-Jul-06 3:30 
AnswerRe: timeout expired.timeout period elapsed prior to completion of the operation or the server is not responding Pin
Judah Gabriel Himango7-Jul-06 4:34
sponsorJudah Gabriel Himango7-Jul-06 4:34 
GeneralRe: timeout expired.timeout period elapsed prior to completion of the operation or the server is not responding Pin
ayyp7-Jul-06 18:41
ayyp7-Jul-06 18:41 

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.