protected ProfileFactory(string sdkPath, string outputPath, ProfilingCluster cluster, Assembly assembly, IColoredWriter output) { this.Name = this.GetType().Name.Replace("ProfileFactory", string.Empty).ToLowerInvariant(); this.SdkPath = sdkPath; this.OutputPath = Path.Combine(outputPath, this.Name); this.Cluster = cluster; this.Assembly = assembly; this.Output = output; }
public object CreateInstance(ProfilingCluster cluster) { if (_instance == null) { var constructors = this.Type.GetTypeInfo().GetConstructors(); var clusterConstructor = constructors.FirstOrDefault(c => { var parameters = c.GetParameters(); return(parameters.Length == 1 && typeof(ProfilingCluster).IsAssignableFrom(parameters[0].ParameterType)); }); _instance = clusterConstructor != null ? Activator.CreateInstance(this.Type, cluster) : Activator.CreateInstance(this.Type); } return(_instance); }