Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
QuestionI want to communicate with Graphdata from C# Core Pin
anil15087523-Jan-20 7:05
professionalanil15087523-Jan-20 7:05 
AnswerRe: I want to communicate with Graphdata from C# Core Pin
ZurdoDev23-Jan-20 7:35
professionalZurdoDev23-Jan-20 7:35 
GeneralRe: I want to communicate with Graphdata from C# Core Pin
anil15087528-Jan-20 6:55
professionalanil15087528-Jan-20 6:55 
QuestionCAS REST API with C' shared login Ticket with Internet explorer or Edge Pin
MeAndCode23-Jan-20 3:19
MeAndCode23-Jan-20 3:19 
QuestionDialogfenster auf- und zuklappen (Open and close dialog window) Pin
CopWorker23-Jan-20 0:36
CopWorker23-Jan-20 0:36 
AnswerRe: Dialogfenster auf- und zuklappen (Open and close dialog window) Pin
Gerry Schmitz23-Jan-20 4:11
mveGerry Schmitz23-Jan-20 4:11 
QuestionMessage Removed Pin
22-Jan-20 22:24
professionalmeeram3922-Jan-20 22:24 
QuestionGet Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 8:45
professionalKevin Marois22-Jan-20 8:45 
I have a serialized collection of objects, such as
GroupEntity
  - ConfigEntity
     - DefinitionEntity
  - ConfigEntity
     - DefinitionEntity
  - ConfigEntity
     - DefinitionEntity

GroupEntity
  - ConfigEntity
     - DefinitionEntity
  - ConfigEntity
     - DefinitionEntity
  - ConfigEntity
     - DefinitionEntity
Given a generic type parameter T, how would you extract all items from the list for that type? So, if I have a class
public class Parser<T>
{
    public T Data { get; set; }
    public void LoadDataFromFile(string fileName)
    {
        // Deserialize the entire file into the master list ;
        List<GroupEntity> allData = Serialization.DeSerializeObject<List<GroupEntity>>(fileName);     

        // Get the type of the class's Parameter
        Type parameterType = typeof(T);

        // Now get all the objects of type T from the list
        //Data =  ????
    }
}
and I instantiated it as
var parser = new Parser<ConfigEntity>();  // Load only Configurations
parser.LoadDataFromFile(fileName);
or
var parser = new Parser<DefinitionsEntity>();  // Load only Definitions
parser.LoadDataFromFile(fileName);
This should then extract ONLY the type of entities into the Data property defined by the generic parameter.

I could write some looping code, but I would then need conditional code for each type. Is this possible with Linq?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: Get Data From Deserialized List By Type Pin
Richard Deeming22-Jan-20 9:01
mveRichard Deeming22-Jan-20 9:01 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 9:15
professionalKevin Marois22-Jan-20 9:15 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 11:12
professionalKevin Marois22-Jan-20 11:12 
GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 0:48
mveRichard Deeming23-Jan-20 0:48 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 7:35
professionalKevin Marois23-Jan-20 7:35 
GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 9:34
mveRichard Deeming23-Jan-20 9:34 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 7:51
professionalKevin Marois23-Jan-20 7:51 
AnswerRe: Get Data From Deserialized List By Type Pin
BillWoodruff22-Jan-20 21:44
professionalBillWoodruff22-Jan-20 21:44 
AnswerRe: Get Data From Deserialized List By Type Pin
Gerry Schmitz23-Jan-20 4:14
mveGerry Schmitz23-Jan-20 4:14 
QuestionException thrown: 'System.IO.FileNotFoundException' sqlite Pin
Member 1472399222-Jan-20 8:41
Member 1472399222-Jan-20 8:41 
AnswerRe: Exception thrown: 'System.IO.FileNotFoundException' sqlite Pin
Richard Deeming22-Jan-20 8:54
mveRichard Deeming22-Jan-20 8:54 
Questionhow flip the canvas vertically ? Pin
Le@rner22-Jan-20 1:56
Le@rner22-Jan-20 1:56 
AnswerRe: how flip the canvas vertically ? Pin
OriginalGriff22-Jan-20 2:29
mveOriginalGriff22-Jan-20 2:29 
GeneralRe: how flip the canvas vertically ? Pin
Le@rner22-Jan-20 19:19
Le@rner22-Jan-20 19:19 
AnswerRe: how flip the canvas vertically ? Pin
Gerry Schmitz22-Jan-20 7:26
mveGerry Schmitz22-Jan-20 7:26 
QuestionAsp.net Pin
RajaMohammed.A22-Jan-20 1:35
RajaMohammed.A22-Jan-20 1:35 
AnswerRe: Asp.net Pin
OriginalGriff22-Jan-20 2:29
mveOriginalGriff22-Jan-20 2:29 

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.