dimanche 13 octobre 2019

How to call a class method that I initialized as an object?

Code where i inicialized class

PropertyInfo[] props = typeof(TObj).GetProperties();
            foreach (PropertyInfo prop in props)
            {
                var sourceAttrs = prop.GetCustomAttribute<Reference>();
                if (sourceAttrs != null)
                {
                    Type entityType = sourceAttrs.ReferenceType;
                    Type openGenericType = typeof(LinkedEntityProvider<,>);
                    Type closedGenericType = openGenericType.MakeGenericType(typeof(TObj), entityType);
                    object instanceLinkedEntityProvider = Activator.CreateInstance(closedGenericType, new object[] { Database, prop });

                }
            }

I need to call method of instanceLinkedEntityProvider. Is It even possible to do this?





Aucun commentaire:

Enregistrer un commentaire