Internal.__MessageBuilder CreateBuilderInstance() { Type builderType = precompiledBuilderType; if (builderType == null) { int builderTypeHash = GetMessageBuilderTypeHash(); lock (builderTypesCache) { if (!builderTypesCache.TryGetValue(builderTypeHash, out builderType)) { builderType = CompileUserCodeToTypeInternal(CompilationTargetFx.RunningFx, asmName => Assembly.Load(asmName).Location); builderTypesCache.Add(builderTypeHash, builderType); } } } Internal.__MessageBuilder ret = (Internal.__MessageBuilder)Activator.CreateInstance(builderType); foreach (ExtensionInfo ext in extensions) { ret.SetExtensionByName(ext.ExtensionName, ext.InstanceGetter()); } return(ret); }
Internal.__MessageBuilder CreateBuilderInstance() { Type builderType = precompiledBuilderType; if (builderType == null) { int builderTypeHash = GetMessageBuilderTypeHash(); Task <Type> builderTypeTask; lock (builderTypesCache) { if (!builderTypesCache.TryGetValue(builderTypeHash, out builderTypeTask)) { builderTypeTask = Task.Run(() => { return(CompileUserCodeToTypeInternal(CompilationTargetFx.RunningFx, asmName => Assembly.Load(asmName).Location)); }); builderTypesCache.Add(builderTypeHash, builderTypeTask); } } try { builderType = builderTypeTask.Result; } catch (AggregateException e) { throw e.InnerException; } } Internal.__MessageBuilder ret = (Internal.__MessageBuilder)Activator.CreateInstance(builderType); foreach (ExtensionInfo ext in extensions) { ret.SetExtensionByName(ext.ExtensionName, ext.InstanceGetter()); } return(ret); }