protected ProfileFactory(string sdkPath, string outputPath, ProfilingCluster cluster, Assembly assembly, IColoredWriter output) { Name = this.GetType().Name.Replace("ProfileFactory", string.Empty).ToLowerInvariant(); SdkPath = sdkPath; OutputPath = Path.Combine(outputPath, Name); Cluster = cluster; Assembly = assembly; Output = output; }
public object CreateInstance(ProfilingCluster cluster) { if (_instance == null) { var constructors = 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(Type, cluster) : Activator.CreateInstance(Type); } return(_instance); }