Files
BeWoPlaner/Service/Plugins/PluginLoader.cs

457 lines
21 KiB
C#
Raw Normal View History

2016-06-27 01:45:38 +02:00
using System;
2021-02-21 19:01:51 +01:00
using System.Configuration;
2016-06-27 01:45:38 +02:00
using System.IO;
using System.Linq;
using System.Reflection;
using BeWo.Data;
using BS.Shared.Core;
2017-06-08 14:56:01 +02:00
using NHibernate.Mapping;
2016-06-27 01:45:38 +02:00
namespace BeWo.Service.Plugins
{
public class PluginLoader
{
public static String Tenant
{
get
{
#if DEBUG
var t = "demo";
//t = "irgendwaswasesnichtgibt";
//t = "5473568546"; //Interner Chat
// t = "2356097460"; // Lebenshilfe Würzburg
2017-02-01 13:53:59 +01:00
//t = "1234567890"; // Präsentationsdatenbank
2021-05-30 16:31:45 +02:00
//t = "5687373602"; // LH Duisburg
2017-09-14 19:03:26 +02:00
//t = "5509064354"; // LH Duisburg Service Plus
2021-05-24 21:40:02 +02:00
//t = "5620636022"; // GPZ Biberach
2017-02-01 13:53:59 +01:00
//t = "8562233401"; // Sozialwirkstatt Schmitz
//t = "1076891970"; // Assistenza
2017-06-28 09:00:09 +02:00
//t = "0216265667"; // LH Hannover
2021-08-04 14:30:26 +02:00
//t = "1774789565"; // LH Essen
2017-02-01 13:53:59 +01:00
//t = "9342168675"; // ABC Betreuungen
//t = "1193188501"; // Aids Hilfe Dortmund
//t = "7860351957"; // SKF Alsdorf
//t = "3311520228"; // Die Düne
2017-02-01 13:53:59 +01:00
//t = "1352143437"; // Sewo
//t = "7107514623"; // BeWo Neuss
//t = "9098141768"; // Fib e.V. Marburg
//t = "1505148718"; // VSD Hamm
//t = "5926081834"; // Spektrum
2020-04-08 14:25:01 +02:00
//t = "1378137009"; // BeWo Direkt+
2017-02-01 13:53:59 +01:00
//t = "3010479871"; // Aachener Verein
2021-05-30 16:31:45 +02:00
//t = "3849764093"; // Club 74
2019-09-17 17:44:57 +02:00
//t = "5805202339"; // Wegweiser Betreuungsdienst
2017-02-01 13:53:59 +01:00
//t = "2301474784"; // Hauskrankenpflege Leiendecker
//t = "8243565510"; // Der Karren
2017-11-17 22:24:00 +01:00
//t = "7709306800"; // Der Karren SBD
2017-02-01 13:53:59 +01:00
//t = "2499262621"; // HPH Bersenbrück
//t = "4950382346"; // Holsinger
//t = "5973016645"; // Verein Lebensgestaltung Hanau
2021-11-08 16:43:43 +01:00
//t = "7375324044"; // Diakonie KK Kleve
2017-02-01 13:53:59 +01:00
//t = "1441747891"; // BeWo Mobil Köln
2021-11-05 11:57:09 +01:00
t = "5120047701"; // Trialog
2017-02-01 13:53:59 +01:00
//t = "3629696651"; // Soziale Dienste Niederrhein
//t = "9893557471"; // Caritas Frankfurt
2017-02-01 13:53:59 +01:00
//t = "2918696314"; // Caritas Frankfurt 2
//t = "6923790936"; // Integra e.V.
//t = "2392153512"; // Christopherus Haus
2021-04-19 01:15:53 +02:00
//t = "9495336024"; // VKM Aachen
2017-02-01 13:53:59 +01:00
//t = "5237724939"; // Indro ABW
//t = "7635986435"; // Köln Ring
2021-04-28 22:50:08 +02:00
//t = "4074176860"; // Soziale Dienstleistung Gessner
2017-02-01 13:53:59 +01:00
//t = "2542550178"; // LWVEingliederungshilfe
//t = "3963982016"; // Convoi
//t = "1600408120"; // BeWo Amrath
//t = "3886054624"; // Brücke ABW
//t = "2028095630"; // Integra Heinsberg
//t = "5351926758"; // Viva a Vida
2017-07-25 10:52:20 +02:00
//t = "2215396183"; // Diakonie Remscheid Lennep
2019-08-09 16:44:13 +02:00
//t = "5157599087"; // SHG Schwerte
//t = "4526293996"; // Fortis
2017-02-01 13:53:59 +01:00
//t = "3647969417"; // Caritas Bottrop
//t = "3963982016"; // Convoi
2021-10-18 00:43:47 +02:00
//t = "3057313346"; // SSB Mainz
2017-02-01 13:53:59 +01:00
//t = "6246287823"; // BeWo Alsdorf
//t = "1420341656"; // Vibb Essen
//t = "4941141927"; // Signcom
//t = "8897605322"; // SPZ Ratingen
//t = "6483870127"; // Wigonetz
//t = "9482484652"; // Blömeling und Teckhaus
//t = "8001550599"; // Biallas BeWo
2019-12-09 11:38:52 +01:00
//t = "7282396774"; // Caritas Unna
2017-02-01 13:53:59 +01:00
//t = "6884855402"; // IBP
2021-02-23 10:23:22 +01:00
//t = "4867997795"; // ADiK Kleve
2017-02-01 13:53:59 +01:00
//t = "3184859776"; // Sergej Becker
//t = "7752610643"; // BWK Gbr
//t = "3785623125"; // Betreuwo
2017-02-01 13:53:59 +01:00
//t = "7130228334"; // LH Borken
2019-07-12 17:36:37 +02:00
//t = "4209820830"; // VKM Hamm
2019-10-10 22:07:42 +02:00
//t = "5700328131"; // Betreutes Wohnen St. Ludgerus Essen-Werden
2017-02-01 13:53:59 +01:00
//t = "1907984777"; // Soziale Dienste Katrin Schmidt
//t = "9033246467"; // SKM Menden
2021-08-17 11:58:11 +02:00
//t = "9290510010"; // Soziale Dienste Schilling (ehemals BeWo Schilling)
2017-02-01 13:53:59 +01:00
//t = "5251218094"; // KOMO e.V.
//t = "3529871747"; // Vivat gemeinnützige GmbH
2021-04-22 00:56:10 +02:00
//t = "8561513464"; // Caritasverband Wuppertal/Solingen
2017-02-01 13:53:59 +01:00
//t = "2727001973"; // SD Julia Schönberg
2021-05-30 16:31:45 +02:00
//t = "5653806613"; // Feid und Kollegen
2021-08-17 11:58:11 +02:00
//t = "3830114427"; // FiZ Familie im Zentrum Hof
2019-07-10 10:11:10 +02:00
//t = "7138297573"; // Tagwerk betreutes wohnen
2017-02-01 13:53:59 +01:00
//t = "1008896531"; // BeWo Auxilio
2019-09-17 17:44:57 +02:00
//t = "9383760246"; // Die Kette
2021-02-24 08:28:12 +01:00
//t = "5915565037"; // Lebenshilfe Remscheid
2017-02-01 13:53:59 +01:00
//t = "3350425974"; // BeWo Rückenwind
//t = "9447917179"; // LH Rodenkirchen
//t = "4690407894"; // Bleib im Leben
//t = "2509786400"; // LH Stade
2018-01-08 22:29:10 +01:00
//t = "8677523325"; // BeWo Richartz
2017-02-01 13:53:59 +01:00
//t = "1765854593"; // Mein Betreutes Wohnen
//t = "6802909544"; // Lebenshilfe Coburg
//t = "9417634361"; // Synprax
2017-02-01 13:53:59 +01:00
//t = "5761861730"; // Lebenshilfe Warendorf
//t = "6712648331"; // BeWo Färber
2019-12-19 14:27:03 +01:00
//t = "4982295287"; // ASB Hamm
2017-02-01 13:53:59 +01:00
//t = "3890031575"; // Die Wohnhelfer Kuhrau
//t = "3536719736"; // BeWo Stefanie Schäfer (BeWoKerpen)
2017-08-14 11:59:31 +02:00
//t = "7739670213"; // SPZ Leverkusen
//t = "3341456098"; // Hilfe Daheim (früher BeWo Schillinger)
2017-02-01 13:53:59 +01:00
//t = "4271389563"; // Komm Mit
//t = "5430005891"; // Marienhospital Eickel
2021-09-07 15:51:34 +02:00
//t = "3265049248"; // Gerdas Pflegedienst
2018-05-21 16:39:24 +02:00
//t = "1549622397"; // Kontakt und Krisenhilfe
//t = "4782194565"; // Skm Rheydt
2017-02-01 13:53:59 +01:00
//t = "7535795843"; // Sozialwerk Dürener Christen
//t = "6388340414"; // Weitblick
//t = "0288588964"; // BeWo Marin
//t = "8872796313"; // WMB
//t = "6297638711"; // ASB Bergisch Gladbach
//t = "5553641242"; // RheinSupport (ehem. Aids und Drogenberatung)
2018-06-29 16:35:19 +02:00
//t = "1218057423"; // LH Koblenz
2017-02-01 13:53:59 +01:00
//t = "3517812158"; // Haus Theresia
//t = "7058292376"; // BeWo Heinsberg
//t = "3227700467"; // Psychosozialer Trägerverein
//t = "4378753169"; // Die Wohnhelfer Köln
//t = "2214258555"; // Betreuungsbüro Baak
//t = "4525013596"; // Hph Bersenbrück Freizeit und Reisen
//t = "1609455614"; // Hph Bersenbrück Aph
//t = "7852961459"; // B&B Betreutes Wohnen
2017-06-08 14:56:01 +02:00
//t = "8719930557"; // Lebenshilfe Rhein-Sieg
2017-02-01 13:53:59 +01:00
//t = "8947336185"; // Lebenshilfe Ahrweiler
//t = "5712358157"; // FINDUS
//t = "8828216586"; // Caritas Aachen
2021-08-19 09:54:50 +02:00
//t = "7062943632"; // ABW Elsebrock
2021-11-08 16:43:43 +01:00
//t = "3956369664"; // LH Wetterau
2021-01-12 01:12:03 +01:00
//t = "3984525482"; // API Berlin
2017-09-14 19:03:26 +02:00
//t = "9975231461"; // Selwo
2020-09-15 13:23:34 +02:00
//t = "8181286349"; // BeWo am Rhein
2017-09-14 19:03:26 +02:00
//t = "4595275645"; // Eigenständig
2021-09-23 18:44:18 +02:00
//t = "7912635399"; // Prof. Dr. Eggers Stiftung
2017-09-14 19:03:26 +02:00
//t = "3549726254"; // Socia
//t = "1992495802"; // Monvita
//t = "7381352241"; // Ressource e.V.
//t = "3607551608"; // Betreuungsbüro Scholz
//t = "3104936392"; // B.A.P. Bielefelder Ambulante Pflege
//t = "1106039294"; // Hph Bersenbrück ATZ
//t = "5562845955"; // Praunheimer Werkstätten
//t = "4801617798"; // Severin
//t = "1172092025"; // Flingern
2018-10-08 11:57:16 +02:00
//t = "3852198843"; // LH Mannheim
2017-09-14 19:03:26 +02:00
//t = "9800364930"; // BeWo Leverkusen
//t = "4439874912"; // BeWo Sahin
2017-09-14 19:03:26 +02:00
//t = "1873138856"; // BUG e.V.
//t = "6463422907"; // Caritas Leverkusen
2017-10-20 11:41:39 +02:00
//t = "6149463003"; // Diakonisches Werk Bad Windsheim Neustadt a. d. Aisch
2020-10-12 13:03:05 +02:00
//t = "6548202677"; // VKM Aachen SBD
2017-10-20 11:41:39 +02:00
//t = "7803602698"; // Taubblindendienst
2021-10-13 14:38:51 +02:00
//t = "5518600303"; // Wetterleuchten e.V.
2017-10-20 11:41:39 +02:00
//t = "4096649015"; // AWO Dortmund
2021-10-28 12:07:51 +02:00
//t = "3614251071"; // Pusteblume
2018-06-26 17:18:59 +02:00
//t = "7755740484"; // Sawo
//t = "8275654834"; // Twg Jonathan
//t = "6586058528"; // Freundeskreis Suchtkrankenhilfe e.V.
//t = "2632162696"; // Pro BeWo Düren
2018-06-26 17:18:59 +02:00
//t = "6340891020"; // Caritas Ahlen
2019-08-29 15:43:23 +02:00
//t = "3659854106"; // alpha e.V.
//t = "5809130435"; // Lebenshilfe Kusel
2018-06-26 17:18:59 +02:00
//t = "3367947706"; // PaS Mönchengladbach
//t = "2331203795"; // BeWo für dich
//t = "5426234256"; // SKM Leverkusen
//t = "4137042939"; // MLG Lebengestalten / Haus Müllestumpe
2021-08-17 11:58:11 +02:00
//t = "5260936181"; // LORI
2018-06-26 17:18:59 +02:00
//t = "1931553444"; // HIBA
//t = "7185338722"; // BeWo Walz & Paiva
//t = "3196643272"; // Betreutes Wohnen Lisa Wöll
2018-10-08 11:57:16 +02:00
//t = "3432911735"; // Caritas Günzburg - Neu Ulm
2021-08-17 11:58:11 +02:00
//t = "2591682148"; // Humanitas
2018-06-26 17:18:59 +02:00
//t = "9805564204"; // LeWo Aachen
//t = "7215356798"; // Triathlon
2019-02-12 19:22:22 +01:00
//t = "3664416736"; // LH Mönchengladbach
//t = "4290816992"; // BeWo im flow
//t = "3612443220"; // ABW Weeger
//t = "6265842607"; // BeWo Dienstleistungen Pougin und Klaasen
//t = "9273332501"; // Pflegedienst Wessel
//t = "4693476852"; // HSH Netzwerk
2020-10-12 13:03:05 +02:00
//t = "3884496709"; // Wahl e.V.
2019-02-12 19:22:22 +01:00
//t = "9883255779"; // VKM Menden
2021-05-24 21:40:02 +02:00
//t = "9556218062"; // Diakonie Landshut
2021-02-23 10:23:22 +01:00
//t = "2279593936"; // Diakonie Mülheim
2021-10-18 00:43:47 +02:00
//t = "3623837005"; // Betreuwo Wesel
2019-02-12 19:22:22 +01:00
//t = "8407321888"; // AWO Wesel
2019-07-12 17:36:37 +02:00
//t = "8454426692"; // Mit-Menschen Wuppertal
2021-05-24 21:40:02 +02:00
//t = "0629004412"; // BeWo-Colonia Basaran (Projekt
2020-04-08 14:25:01 +02:00
//t = "7668701607"; // Wohnstätten Essen
//t = "3833058951"; // Aids Hilfe Duisburg (Self)
//t = "9463879250"; // ABW Dziallas und Muhrin
//t = "7964339639"; // Lebenshilfe Trier
//t = "1477928721"; // ASB Regionalverband Rhein-Erft/Dueren e.V.
//t = "6178990609"; // Johannes-Diakonie Mosbach
2020-04-15 18:24:01 +02:00
//t = "7185105541"; // Nous GmbH
2020-04-08 14:25:01 +02:00
//t = "5022131330"; // Tabula Rasa
//t = "4189934785"; // Landshuter Netzwerke
2021-03-11 12:09:38 +01:00
//t = "4290816992"; // BeWo Imflow
2021-02-19 13:21:30 +01:00
//t = "7584236951"; // Aachener Betreuungsbüro Kirschbaum und Manz GbR
2020-04-08 14:25:01 +02:00
//t = "3678599942"; // VKM Rietberg
//t = "4069072369"; // BeWo Dreilich&Pastor (Pastor)
2019-08-29 15:43:23 +02:00
//t = "4160851689"; // BeWo Dreilich&Pastor (Dreilich)
2020-04-08 14:25:01 +02:00
//t = "9970072066"; // Bussmannshof
2021-01-12 01:12:03 +01:00
//t = "2993745954"; // Kollegium für freie Jugendarbeit und Berufsbildung e.V.
2021-09-23 18:44:18 +02:00
//t = "5495240031"; // Christian Luft
//t = "6922762575"; // BHS Solingen
//t = "3472573348"; // ASB Mönchengladbach
2019-12-09 11:38:52 +01:00
//t = "8831599797"; // SeHT Münster
//t = "7817461089"; // FAB e.V. (Familienarbeit und Beratung e.V.)
//t = "5207911843"; // Pro Balance
//t = "8619663355"; // HSH Cologne
2021-09-28 19:03:51 +02:00
//t = "1652658918"; // LH Frankfurt Oder
//t = "7696927868"; // Kuhring Betreuung
//t = "6251348980"; // BeWo Gün
//t = "6782533512"; // LH Dorsten
//t = "5890882255"; // Fortis Nova
//t = "2422863972"; // Diakonisches Werk Mülheim (Therapeutische Wohngemeinschaft)
//t = "2141858509"; // INKOMM GmbH
//t = "8975059766"; // Quer-Fällt-Ein
2020-10-29 11:20:37 +01:00
//t = "8928179244"; // ASB Ruhr e.V. Regionalverband
2021-02-02 23:23:05 +01:00
//t = "4423043131"; // Die Perspektive e.V.
//t = "5263375280"; // LH Wolfsburg
//t = "4900722829"; // Evangelische Kirchengemeinde Bottrop
2021-11-08 16:43:43 +01:00
t = "9853685258"; // Input
//t = "7622428090"; // Freie gemeinnützige Beratungsstelle für Psychotherapie e.V. (BfpDus) (Panama)
//t = "0206140343"; // Lebenswelt Gabriel
//t = "6916712798"; // LH Rodenkirchen Bewo
2021-06-20 23:11:01 +02:00
//t = "6255521162"; // KCM GmbH
//t = "2697528233"; // Diakonisches Werk Wesel
//t = "2547623489"; // Sprungbrett
//t = "5076807716"; // Psychosoziale Hilfen Bochum e.V.
//t = "1601313225"; // Bella Donna
//t = "5098825926"; // SAB GmbH
//t = "7808149226"; // BeWo Flex
//t = "7419804320"; // Gender Bewo
//t = "4500422855"; // BeWo Nordeifel
//t = "3565931805"; // Betreuungsbüro Frank Röhrig
//t = "4152581290"; // MVZ Medikus GmbH (Stoffwechsel Betreutes wohnen)
//t = "4529320405"; // BeWo Stelzel
//t = "2594047883"; // KOMM Ambulante Dienste e. V.
//t = "1558685648"; // KIMM
//t = "3460972350"; // Caritas Kleve I
//t = "2623845876"; // Passgenau Hildesheim
2021-08-19 09:54:50 +02:00
//t = "4368361336"; // Kompass BeWo Wesel
//t = "3257905806"; // Diakonisches Werk Herne
//t = "2535794597"; // Mobilo Ambulant
//t = "7114701269"; // Die Brücke Hilfe und Halt
//t = "6447060239"; // Empathie Fachassistenz
//t = "6919016656"; // Leben und Wohnen Christian Wilke
//t = "8281327384"; // Caritasverband Düren-Jülich e.V. (Eingliederungshilfe)
//t = "6023735102"; // Kölner BeWo (Selbstbestimmt Leben)
//t = "2998118179"; // BeWo Plus
//t = "9254115251"; // Praunheimer Werkstätten 2.DB
//t = "5880845152"; // Bewegt Systemische Beratung und Begleitung (Kathrin Lilly)
//t = "5798370140"; // Team Pfeil
//t = "8242644560"; // Bewolonia - Fr. Sultan Schulz
//t = "4817284046"; // Verein für Sozialmedizin Stade e.V.
//t = "6323001211"; // ASB Faßbacher Hof gGmbH
2021-08-17 11:58:11 +02:00
//t = "9389386079"; // VARO Sozialagentur
//t = "7951718431"; // Ambulant Betreutes Wohnen Astrid Pulm
//t = "5850903700"; // Alzey Teilhabe
//t = "5929601293"; // Lebenshilfe Duisburg Frühförderung (Projekt heißt LebenshilfeDuisburgAtz)
2021-10-05 13:30:20 +02:00
//t = "6860475645"; // Lebenshilfe Duisburg ATZ (Projekt heißt LebenshilfeDuisburgAtz6860475645)
2021-07-07 15:05:45 +02:00
//t = "4823067940"; // Die Kette 2
2021-05-24 21:40:02 +02:00
//t = "8283849714"; // Forum e.V. (proviel GmbH)
2021-07-07 15:05:45 +02:00
//t = "3915346496"; // Sprungbrett 2. DB (Haus Theresia)
2021-10-05 15:00:54 +02:00
//t = "2387527289"; // Lebenshilfe Duisburg HPFH
//t = "5595701056"; // Domiziel Ansbach
2021-07-07 15:05:45 +02:00
//t = "4823067940"; // Die Kette 2
2021-05-24 21:40:02 +02:00
//t = "8283849714"; // Forum e.V. (proviel GmbH)
2021-07-07 15:05:45 +02:00
//t = "3915346496"; // Sprungbrett 2. DB (Haus Theresia)
//t = "2387527289"; // Lebenshilfe Duisburg HPFH
2021-10-01 16:49:37 +02:00
//t = "5595701056"; // Domiziel Ansbach
2021-08-11 12:06:56 +02:00
//t = "9430188510"; // Pro INTEGRA
//t = "4820371076"; // Zuhause Wohnen Iris Thimm
//t = "1078667960"; // FAM Rhein-Sieg Gbr
2021-08-09 14:11:57 +02:00
//t = "9388871209"; // Sozialwerk Aachener Christen e.V.
2021-08-17 11:58:11 +02:00
//t = "1566251835"; // Sicherleben Michael Voß
2021-08-12 11:02:10 +02:00
//t = "4947061147"; // Diakonisches Werk Passau
2021-10-29 14:40:10 +02:00
//t = "9064234785"; // BeWo Rimbach
2021-09-07 15:51:34 +02:00
//t = "9433783300"; // Wichernhaus gGmbH
2021-09-22 15:34:38 +02:00
//t = "6282665941"; // Diakonisches Werk Regensburg
//t = "7712740386"; // Heimstatt St. Marien e.V. (Carl-Sonnenscheinhaus)
2021-10-13 14:38:51 +02:00
//t = "5537187628"; // Verband Ev. Kirchengemeinden Dorsten
//t = "8375099271"; // Neustart - Ambulant Betreutes Wohnen
2021-10-08 14:51:28 +02:00
//t = "5478434972"; // LebensWert - Kai Lippel
//t = "5381886394"; // PZDDuesseldorf
//t = "3640152169"; // Claudia Charisius
//t = "3884496709"; // Wahl e.V.
//t = "3536079480"; // Behindertenhilfe Menden
//t = "5427523619"; // ChristopherusHausFamilienhilfe
//t = "8251343124"; //Rat Plus Tat
2021-10-28 12:07:51 +02:00
2016-06-27 01:45:38 +02:00
return t;
#else
2019-08-29 15:43:23 +02:00
if (MultitenancyOperationContextExt.Current != null)
2016-06-27 01:45:38 +02:00
return MultitenancyOperationContextExt.Current.Tenant;
return SessionFacade.Tenant;
#endif
}
}
private static String CustomerPluginPath()
{
2021-02-21 19:01:51 +01:00
var path = ConfigurationManager.AppSettings.Get("PluginPath");
if (path != null)
{
return Path.Combine(path, Tenant + "_reports.dll");
}
2016-06-27 01:45:38 +02:00
#if DEBUG
2021-02-21 19:01:51 +01:00
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\" + Tenant + "_reports.dll");
2016-06-27 01:45:38 +02:00
#else
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Customer\" + Tenant + "_reports.dll");
#endif
}
public static T FindClass<T>() where T : new()
{
var t = FindClass<T>(null, null);
if (t == null)
{
t = new T();
}
return t;
}
public static T FindClass<T>(string specificId)
{
return FindClass<T>(specificId, null);
}
public static T FindClass<T>(string specificId, string typename)
{
Type[] lAllTypes = null;
2020-08-31 17:44:05 +02:00
var type = typeof(T);
2016-06-27 01:45:38 +02:00
if (Tenant != null)
{
if (File.Exists(CustomerPluginPath()))
lAllTypes = Assembly.LoadFrom(CustomerPluginPath()).GetTypes();
}
T result = default(T);
if (lAllTypes != null)
result = FindClass<T>(lAllTypes, specificId, typename);
return result;
}
public static T FindClass<T>(Type[] lAllTypes, string specificId, string typename)
{
T result = default(T);
if (!string.IsNullOrEmpty(specificId) && !string.IsNullOrEmpty(typename))
{
var cbSpecific = lAllTypes
.Where(i => typeof(T).IsAssignableFrom(i))
.FirstOrDefault(t => t.GetCustomAttributes(typeof(IDSpecificClassAttribute), true)
.ToList()
.Exists(i =>
{
var attr = (IDSpecificClassAttribute)i;
if (attr.Identifiers != null)
return attr.Identifiers.Contains(specificId);
if (!String.IsNullOrEmpty(attr.Identifier))
return attr.Identifier.Equals(specificId);
return false;
}
) && t.FullName == typename);
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
}
if (!string.IsNullOrEmpty(typename))
{
var cbSpecific = lAllTypes.FirstOrDefault(t => t.FullName == typename);
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
}
if (!string.IsNullOrEmpty(specificId))
{
var cbSpecific = lAllTypes
.Where(i => typeof(T).IsAssignableFrom(i))
.FirstOrDefault(t => t.GetCustomAttributes(typeof(IDSpecificClassAttribute), true)
.ToList()
.Exists(i =>
{
var attr = (IDSpecificClassAttribute)i;
if (attr.Identifiers != null)
return attr.Identifiers.Contains(specificId);
if (!String.IsNullOrEmpty(attr.Identifier))
return attr.Identifier.Equals(specificId);
return false;
}
));
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
if (result == null)
{
foreach (var iType in lAllTypes)
if (typeof(T).IsAssignableFrom(iType))
if (iType.Name == specificId)
result = (T)Activator.CreateInstance(iType);
}
}
2017-06-08 14:56:01 +02:00
2016-06-27 01:45:38 +02:00
2017-06-08 14:56:01 +02:00
if (result == null)
{
var list2 = lAllTypes.Where(t => typeof (T).IsAssignableFrom(t)).ToList();
2016-06-27 01:45:38 +02:00
2017-06-08 14:56:01 +02:00
var list = list2.Where(t => t.GetCustomAttributes(typeof (IgnoreAutoPluginAttribute), true).Length == 0).ToList();
2016-06-27 01:45:38 +02:00
2017-02-01 13:53:59 +01:00
if (list.Count == 1)
2017-06-08 14:56:01 +02:00
result = (T)Activator.CreateInstance(list[0]);
else if (list.Count > 1)
{
foreach (var type in list)
{
var attrs = type.GetCustomAttributes(typeof(IDSpecificClassAttribute), true);
if (attrs.Length == 0)
return (T)Activator.CreateInstance(type);
}
2016-06-27 01:45:38 +02:00
2017-06-08 14:56:01 +02:00
result = (T)Activator.CreateInstance(list[0]);
}
2017-02-01 13:53:59 +01:00
2017-06-08 14:56:01 +02:00
}
2017-02-01 13:53:59 +01:00
2017-06-08 14:56:01 +02:00
return result;
2016-06-27 01:45:38 +02:00
}
}
}