public void GetOrCreateInstanceThrowsArgumentNullExceptionWhenResolveRequestIsNull() { var lifetimeScope = Mock.Of <ISharingLifetimeScope>(); var resolveOperation = new ResolveOperation(lifetimeScope, new DiagnosticListener("SomeName")); Assert.Throws <ArgumentNullException>(() => resolveOperation.GetOrCreateInstance(lifetimeScope, null !)); }
protected override ResolvedAssembly ParseAssembly( ResolveOperation resolveOperation, FilePath path, PEReader peReader, MetadataReader metadataReader) { var resolvedAssembly = base.ParseAssembly(resolveOperation, path, peReader, metadataReader); foreach (var attrHandle in metadataReader.GetAssemblyDefinition().GetCustomAttributes()) { var attr = metadataReader.GetCustomAttribute(attrHandle); if (attr.Constructor.Kind != HandleKind.MemberReference) { continue; } var ctor = metadataReader.GetMemberReference((MemberReferenceHandle)attr.Constructor); var typeReference = metadataReader.GetTypeReference((TypeReferenceHandle)ctor.Parent); var integrationType = typeof(EvaluationContextManagerIntegrationAttribute); if (metadataReader.GetString(typeReference.Namespace) == integrationType.Namespace && metadataReader.GetString(typeReference.Name) == integrationType.Name) { return(resolvedAssembly.With( hasIntegration: true, externalDependencies: resolvedAssembly.ExternalDependencies)); } } return(resolvedAssembly); }
protected override ResolvedAssembly ParseAssembly( ResolveOperation resolveOperation, FilePath path, PEReader peReader, MetadataReader metadataReader) { var resolvedAssembly = base.ParseAssembly(resolveOperation, path, peReader, metadataReader); var nativeDependencies = new List <ExternalDependency> (); if (AgentType == AgentType.iOS) { nativeDependencies.AddRange( GetEmbeddedFrameworks( resolveOperation, path, peReader, metadataReader)); } // HACK: Hard-code hacks for SkiaSharp. if (path.Name == "SkiaSharp.dll") { nativeDependencies.AddRange(GetSkiaSharpDependencies(path)); } // HACK: Hard-code hacks for UrhoSharp. if (path.Name == "Urho.dll") { nativeDependencies.AddRange(GetUrhoSharpDependencies(path)); } return(resolvedAssembly.WithExternalDependencies(nativeDependencies)); }
public void EmptyInProgessRequestWhenInitializing() { var resolveOperation = new ResolveOperation(Mock.Of <ISharingLifetimeScope>(), new DiagnosticListener("SomeName")); var inProgressStack = resolveOperation.InProgressRequests; Assert.Empty(inProgressStack); }
public object ResolveComponent(IComponentRegistration registration) { var op = new ResolveOperation(registration, this); var instance = op.Resolve(); return(instance); }
public void OperationRaisesFailureTraceEvents() { var builder = new ContainerBuilder(); builder.Register <string>(ctxt => throw new InvalidOperationException()); var container = builder.Build(); var mockTracer = Mocks.GetTracer(); container.SubscribeToDiagnostics(mockTracer); var scope = container.Resolve <ILifetimeScope>() as ISharingLifetimeScope; var resolveOp = new ResolveOperation(scope, container.DiagnosticSource); var raisedEvents = new List <string>(); var request = new ResolveRequest(new TypedService(typeof(string)), scope.ResolvableImplementationFor <string>(), Enumerable.Empty <Parameter>()); mockTracer.OperationStarting += (op, req) => { raisedEvents.Add("opstart"); Assert.Equal(resolveOp, op); Assert.Equal(request, req); }; mockTracer.RequestStarting += (op, ctxt) => { raisedEvents.Add("reqstart"); Assert.Equal(resolveOp, op); Assert.Equal(request.Service, ctxt.Service); }; mockTracer.RequestFailing += (op, ctxt, ex) => { raisedEvents.Add("reqfail"); Assert.Equal(resolveOp, op); Assert.IsType <DependencyResolutionException>(ex); }; mockTracer.OperationFailing += (op, ex) => { raisedEvents.Add("opfail"); Assert.IsType <DependencyResolutionException>(ex); }; try { resolveOp.Execute(request); } catch { } Assert.Equal(new[] { "opstart", "reqstart", "reqfail", "opfail" }, raisedEvents); }
public async Task <IOperationToken> ResolveAsync(string instanceName, string serviceType, string domain, uint interfaceIndex = 0, object context = null) { await CheckConnectionAsync(); var op = new ResolveOperation(instanceName, serviceType, domain, interfaceIndex, context); op.ResolveEvent += (s, e) => ResolveEvent?.Invoke(s, e); await _connection.AddAndExecuteSubordinate(op); return(op.Token); }
public SubResolveOperationViewModel(ResolveOperation resolveOperation) { if (resolveOperation.RootInstanceLookup != null) { _rootInstanceLookup = BuildInstanceLookupTree(resolveOperation.RootInstanceLookup); } if (resolveOperation.CallingMethod != null) { _locationDescription = resolveOperation.CallingMethod.DisplayName; } _isRootOperation = resolveOperation.Parent == null; }
public void OperationRaisesSuccessTraceEvents() { var builder = new ContainerBuilder(); builder.RegisterInstance("Hello"); var container = builder.Build(); var mockTracer = Mocks.GetTracer(); container.SubscribeToDiagnostics(mockTracer); var scope = container.Resolve <ILifetimeScope>() as ISharingLifetimeScope; var resolveOp = new ResolveOperation(scope, container.DiagnosticSource); var raisedEvents = new List <string>(); var request = new ResolveRequest(new TypedService(typeof(string)), scope.ResolvableImplementationFor <string>(), Enumerable.Empty <Parameter>()); mockTracer.OperationStarting += (op, req) => { raisedEvents.Add("opstart"); Assert.Equal(resolveOp, op); Assert.Equal(request, req); }; mockTracer.RequestStarting += (op, ctxt) => { raisedEvents.Add("reqstart"); Assert.Equal(resolveOp, op); Assert.Equal(request.Service, ctxt.Service); }; mockTracer.RequestSucceeding += (op, ctxt) => { raisedEvents.Add("reqsuccess"); Assert.Equal(resolveOp, op); }; mockTracer.OperationSucceeding += (op, instance) => { raisedEvents.Add("opsuccess"); Assert.Equal("Hello", instance); }; resolveOp.Execute(request); Assert.Equal(new[] { "opstart", "reqstart", "reqsuccess", "opsuccess" }, raisedEvents); }
/// <inheritdoc /> public object ResolveComponent(ResolveRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } CheckNotDisposed(); var operation = new ResolveOperation(this); var handler = ResolveOperationBeginning; handler?.Invoke(this, new ResolveOperationBeginningEventArgs(operation)); return(operation.Execute(request)); }
protected override ResolvedAssembly ParseAssembly( ResolveOperation resolveOperation, FilePath path, PEReader peReader, MetadataReader metadataReader) { var resolvedAssembly = base.ParseAssembly(resolveOperation, path, peReader, metadataReader); var jsPath = path.ParentDirectory.Combine(path.NameWithoutExtension + ".js"); var cssPath = path.ParentDirectory.Combine(path.NameWithoutExtension + ".css"); var deps = resolvedAssembly.ExternalDependencies; if (jsPath.FileExists) { deps = deps.Add(new WebDependency(jsPath)); } if (cssPath.FileExists) { deps = deps.Add(new WebDependency(cssPath)); } foreach (var attrHandle in metadataReader.GetAssemblyDefinition().GetCustomAttributes()) { var attr = metadataReader.GetCustomAttribute(attrHandle); if (attr.Constructor.Kind != HandleKind.MemberReference) { continue; } var ctor = metadataReader.GetMemberReference((MemberReferenceHandle)attr.Constructor); var typeReference = metadataReader.GetTypeReference((TypeReferenceHandle)ctor.Parent); var integrationType = typeof(AgentIntegrationAttribute); if (metadataReader.GetString(typeReference.Namespace) == integrationType.Namespace && metadataReader.GetString(typeReference.Name) == integrationType.Name) { return(resolvedAssembly.With( hasIntegration: true, externalDependencies: deps)); } } return(resolvedAssembly); }
/// <summary> /// Resolve an instance of the provided registration within the context. /// </summary> /// <param name="registration">The registration.</param> /// <param name="parameters">Parameters for the instance.</param> /// <returns> /// The component instance. /// </returns> /// <exception cref="Autofac.Core.Registration.ComponentNotRegisteredException"/> /// <exception cref="DependencyResolutionException"/> public object ResolveComponent(IComponentRegistration registration, IEnumerable <Parameter> parameters) { if (registration == null) { throw new ArgumentNullException(nameof(registration)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } CheckNotDisposed(); var operation = new ResolveOperation(this); var handler = ResolveOperationBeginning; handler?.Invoke(this, new ResolveOperationBeginningEventArgs(operation)); return(operation.Execute(registration, parameters)); }
public void UpdateFrom(ResolveOperationBeginningMessage message) { LifetimeScope lifetimeScope; if (!_lifetimeScopes.TryGetItem(message.ResolveOperation.LifetimeScopeId, out lifetimeScope)) { throw new InvalidOperationException("Resolve operation beginning in an unknown lifetime scope."); } Thread thread; if (!_threads.TryGetItem(message.ResolveOperation.ThreadId, out thread)) { thread = new Thread(message.ResolveOperation.ThreadId); _threads.Add(thread); } ResolveOperation parent = null; if (thread.ResolveOperationStack.Count != 0) { parent = thread.ResolveOperationStack.Peek(); } MethodIdentifier callingMethod = null; if (message.ResolveOperation.CallingMethodName != null) { callingMethod = new MethodIdentifier(message.ResolveOperation.CallingMethodName, TypeIdentifier.Parse(message.ResolveOperation.CallingTypeAssemblyQualifiedName)); } var resolveOperation = new ResolveOperation(message.ResolveOperation.Id, lifetimeScope, thread, parent, callingMethod); if (parent != null) { parent.SubOperations.Add(resolveOperation); } _resolveOperations.Add(resolveOperation); thread.ResolveOperationStack.Push(resolveOperation); }
protected override ResolvedAssembly ParseAssembly( ResolveOperation resolveOperation, FilePath path, PEReader peReader, MetadataReader metadataReader) { var resolvedAssembly = base.ParseAssembly(resolveOperation, path, peReader, metadataReader); var nativeDependencies = new List <ExternalDependency> (); if (CompilationConfiguration.Sdk.Is(SdkId.XamarinIos)) { nativeDependencies.AddRange( GetEmbeddedFrameworks( resolveOperation, path, peReader, metadataReader)); } #if false // HACK: Hard-code hacks for SkiaSharp. if (path.Name == "SkiaSharp.dll") { nativeDependencies.AddRange(GetSkiaSharpDependencies(path)); } // HACK: Hard-code hacks for UrhoSharp. if (path.Name == "Urho.dll") { nativeDependencies.AddRange(GetUrhoSharpDependencies(path)); } if (path.Name == "Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.dll") { nativeDependencies.AddRange(GetKestrelLibuvDependencies(path)); } #endif return(resolvedAssembly.WithExternalDependencies(nativeDependencies)); }
public object ResolveComponent(IComponentRegistration registration, IEnumerable <Parameter> parameters) { if (registration == null) { throw new ArgumentNullException("registration"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } this.CheckNotDisposed(); lock (this._synchRoot) { ResolveOperation resolveOperation = new ResolveOperation(this); EventHandler <ResolveOperationBeginningEventArgs> resolveOperationBeginning = this.ResolveOperationBeginning; if (resolveOperationBeginning != null) { resolveOperationBeginning(this, new ResolveOperationBeginningEventArgs(resolveOperation)); } return(resolveOperation.Execute(registration, parameters)); } }
/// <summary> /// Resolve an instance of the provided registration within the context. /// </summary> /// <param name="registration">The registration.</param> /// <param name="parameters">Parameters for the instance.</param> /// <returns> /// The component instance. /// </returns> /// <exception cref="Autofac.Core.Registration.ComponentNotRegisteredException"/> /// <exception cref="DependencyResolutionException"/> public object ResolveComponent(IComponentRegistration registration, IEnumerable <Parameter> parameters) { if (registration == null) { throw new ArgumentNullException("registration"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } CheckNotDisposed(); lock (_synchRoot) { var operation = new ResolveOperation(this); var handler = ResolveOperationBeginning; if (handler != null) { handler(this, new ResolveOperationBeginningEventArgs(operation)); } return(operation.Execute(registration, parameters)); } }
IEnumerable <ExternalDependency> GetEmbeddedFrameworks( ResolveOperation resolveOperation, FilePath path, PEReader peReader, MetadataReader metadataReader) { var resourceNames = metadataReader .GetLinkWithLibraryNames() .ToImmutableHashSet(); var resources = metadataReader .ManifestResources .Select(metadataReader.GetManifestResource) .Where(SrmExtensions.IsExtractable); foreach (var resource in resources) { resolveOperation.CancellationToken.ThrowIfCancellationRequested(); var name = new FilePath(metadataReader.GetString(resource.Name)); if (!resourceNames.Contains(name)) { continue; } var extractPath = new FilePath(path + ".resources").Combine(name); if (extractPath.Extension != ".framework") { Log.Error(TAG, "Unsupported [LinkWith] embedded native resource " + $"'{name}' in assembly '{path}'"); continue; } if (extractPath.DirectoryExists) { Log.Debug(TAG, "Skipping extraction of embedded manifest " + $"resource '{name}' in assembly '{path}'"); } else { Log.Debug(TAG, "Extracting embedded manifest resource " + $"'{name}' in assembly '{path}'"); using (var archive = new ZipArchive(resource.GetStream(peReader))) archive.Extract( extractPath, cancellationToken: resolveOperation.CancellationToken); } // FIXME: need to check Info.plist that CFBundlePackageType is // a framework (FMWK) and then read the actual framework library // name (CFBundleExecutable), but that means we need macdev, etc. var libPath = extractPath.Combine(name.NameWithoutExtension); if (libPath.FileExists) { yield return(new NativeDependency(name, libPath)); } else { Log.Error(TAG, $"Embedded native framework '{name}' in assembly '{path}' " + "has an unconventional structure and is not supported"); } } }
internal static void ResolveDuplicate( Guid duplicateId, ResolveOperation resolveOperation) => DuplicateManager.ResolveDuplicate(duplicateId, resolveOperation);
public PipelineRequestContextStub() { _diagnosticSource = new DiagnosticListener("Autofac"); _resolveRequest = new ResolveRequest(new TypedService(typeof(int)), Mocks.GetResolvableImplementation(), Enumerable.Empty <Parameter>()); Operation = new ResolveOperation(new LifetimeScopeStub(), _diagnosticSource); }
static void Main(string[] args) { InputCorrect correct = new InputCorrect(); ResolveOperation resolve = new ResolveOperation(); string startValue = "0"; string value = ""; Console.WriteLine( "-----------------------------Konsol Hesap Makinesi---------------------------\n" + "[-Çarpma, Bölme, Çıkarma, Toplama ve Üs Alma İşlemleri Gerçekleştirilebilir-]\n" + "[---------Yanyana olacak şekilde ve ya tek tek işlem yaptırılabilir.--------]\n" + "[---------------------[Örneğin = 3 / 2 + 55 - 3 ^ 5]------------------------]\n" + "[------------[x] Solda bulunan sayıya göre işlem devam edecektir.-----------]\n" + "[---------------Çıkış 'e' tuşuna basarak gerçekleştirilir.------------------]\n" + "[----------İşlemi temizleme 'c' tuşuna basarak gerçekleştirilir.------------]\n" + "[---------------------------------------------------------------------------]\n\n"); Console.Write("İşlem ve ya işleme sokulacak sayıyı giriniz-->"); do { value = Console.ReadLine(); if (value == "c") { startValue = "0"; Console.WriteLine("İşlem Temizlendi."); Console.Write("[0]-->"); } else if (value == "e") { Console.WriteLine("Çıkış yapılıyor."); } else { if (startValue == "0" && correct.OnlyDigit(value)) { startValue = value; Console.WriteLine($"[İşleme devam edilecek sayı = [{startValue}]"); Console.Write($"[{startValue}]-->"); } else { if (correct.IsInputValueCorrect(value)) { if (correct.IsOperatorStartChr(value[0])) { startValue = resolve.CalculateOperation(startValue + value); } else { startValue = resolve.CalculateOperation(value); //Console.WriteLine($"[İşleme devam edilecek sayı değişmiştir = [{startValue}]"); } Console.Write($"[{startValue}]-->"); } else { Console.WriteLine($"{correct.ErrorMessage}"); Console.Write($"[{startValue}]-->"); } } } } while (value != "e"); }
public void ResolveDuplicate(Guid duplicateId, ResolveOperation resolveOperation) => Program.ResolveDuplicate(duplicateId, resolveOperation);
private void BtnDeleteRight_Click(object sender, EventArgs e) { ResolveOperation = ResolveOperation.DeleteFile2; DialogResult = DialogResult.OK; }
private void BtnDiscard_Click(object sender, EventArgs e) { ResolveOperation = ResolveOperation.Discard; DialogResult = DialogResult.OK; }
private void BtnSkip_Click(object sender, EventArgs e) { ResolveOperation = ResolveOperation.Skip; DialogResult = DialogResult.OK; }
public void ResolveDuplicate(Guid duplicateId, ResolveOperation resolveOperation) => Channel.ResolveDuplicate(duplicateId, resolveOperation);