Click here to Skip to main content
14,447,309 members
   

C#

 
AnswerRe: Get Data From Deserialized List By Type Pin
Richard Deeming22-Jan-20 10:01
communityengineerRichard Deeming22-Jan-20 10:01 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 10:15
professionalKevin Marois22-Jan-20 10:15 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 12:12
professionalKevin Marois22-Jan-20 12:12 
GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 1:48
communityengineerRichard Deeming23-Jan-20 1:48 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 8:35
professionalKevin Marois23-Jan-20 8:35 
GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 10:34
communityengineerRichard Deeming23-Jan-20 10:34 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 8:51
professionalKevin Marois23-Jan-20 8:51 
AnswerRe: Get Data From Deserialized List By Type Pin
BillWoodruff22-Jan-20 22:44
mveBillWoodruff22-Jan-20 22:44 
example of generic return filter ... you write the Linq version Smile | :)

... usage example in some method:
required: using GRFExample;    

    var gevalues = Example.GetByType<GroupEntity>(Example.Test1().ToArray()).Cast<GroupEntity>();
            
    var cevalues = Example.GetByType<ConfigEntity>(Example.Test1().ToArray()).Cast<ConfigEntity>();
    
    var devalues = Example.GetByType<DefinitionEntity>(Example.Test1().ToArray()).Cast<DefinitionEntity>();
using System.Collections.Generic;

namespace GRFExample
{
    public static class Example
    {
        private static int id = 0;

        public static IEnumerable<GroupEntity> Test1()
        {
            for (var i = 0; i < 5; i++)
            {
                var ge = new GroupEntity();

                for (var j = 0; j < 4; j++)
                {
                    var ce = new ConfigEntity();
                    ce.dee = new DefinitionEntity(id++);
                    ge.cees.Add(ce);
                }

                yield return ge;
            }
        }

        public static IEnumerable<TheBase> GetByType<T>(params GroupEntity[] bees)
        {
            var pType = typeof(T).Name;

            foreach (var b in bees)
            {
                switch (pType)
                {
                    case "B":
                        yield return b;
                        break;

                    case "C":
                        foreach (var c in b.cees) yield return c;
                        break;

                    case "D":
                        foreach (var c in b.cees) yield return c.dee;
                        break;
                }
            }
        }
    }

    public class TheBase
    {
    }

    public class GroupEntity : TheBase
    {
        public List<ConfigEntity> cees = new List<ConfigEntity>();
    }

    public class ConfigEntity : TheBase
    {
        public DefinitionEntity dee;
    }

    public class DefinitionEntity : TheBase
    {
        public int id;

        public DefinitionEntity(int id)
        {
            this.id = id;
        }
    }
}

«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali

AnswerRe: Get Data From Deserialized List By Type Pin
Gerry Schmitz23-Jan-20 5:14
mveGerry Schmitz23-Jan-20 5:14 
QuestionException thrown: 'System.IO.FileNotFoundException' sqlite Pin
Member 1472399222-Jan-20 9:41
MemberMember 1472399222-Jan-20 9:41 
AnswerRe: Exception thrown: 'System.IO.FileNotFoundException' sqlite Pin
Richard Deeming22-Jan-20 9:54
communityengineerRichard Deeming22-Jan-20 9:54 
Questionhow flip the canvas vertically ? Pin
Le@rner22-Jan-20 2:56
MemberLe@rner22-Jan-20 2:56 
AnswerRe: how flip the canvas vertically ? Pin
OriginalGriff22-Jan-20 3:29
communityengineerOriginalGriff22-Jan-20 3:29 
GeneralRe: how flip the canvas vertically ? Pin
Le@rner22-Jan-20 20:19
MemberLe@rner22-Jan-20 20:19 
AnswerRe: how flip the canvas vertically ? Pin
Gerry Schmitz22-Jan-20 8:26
mveGerry Schmitz22-Jan-20 8:26 
QuestionAsp.net Pin
RajaMohammed.A22-Jan-20 2:35
MemberRajaMohammed.A22-Jan-20 2:35 
AnswerRe: Asp.net Pin
OriginalGriff22-Jan-20 3:29
communityengineerOriginalGriff22-Jan-20 3:29 
AnswerRe: Asp.net Pin
Richard Deeming22-Jan-20 4:11
communityengineerRichard Deeming22-Jan-20 4:11 
AnswerRe: Asp.net Pin
Gerry Schmitz22-Jan-20 8:37
mveGerry Schmitz22-Jan-20 8:37 
QuestionConvert the data intered by the user to integer number Pin
Member 906313820-Jan-20 23:37
MemberMember 906313820-Jan-20 23:37 
AnswerRe: Convert the data intered by the user to integer number Pin
OriginalGriff20-Jan-20 23:47
communityengineerOriginalGriff20-Jan-20 23:47 
AnswerRe: Convert the data intered by the user to integer number Pin
ZurdoDev21-Jan-20 4:09
mveZurdoDev21-Jan-20 4:09 
QuestionClear comments and rename var/method names at compile time Pin
Lupu5R3x18-Jan-20 1:49
MemberLupu5R3x18-Jan-20 1:49 
AnswerRe: Clear comments and rename var/method names at compile time Pin
OriginalGriff18-Jan-20 2:45
communityengineerOriginalGriff18-Jan-20 2:45 
GeneralRe: Clear comments and rename var/method names at compile time Pin
Lupu5R3x18-Jan-20 5:17
MemberLupu5R3x18-Jan-20 5:17 

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.