/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here container.RegisterType<ILogger, Logger>(); container.RegisterType<IAuthorService, AuthorServiceClient>(new InjectionConstructor()); container.RegisterType<IBookService, BookServiceClient>(new InjectionConstructor()); container.RegisterType<AuthorWebServiceSoap, AuthorWebServiceSoapClient>(new InjectionConstructor()); container.RegisterType<BookWebServiceSoap, BookWebServiceSoapClient>(new InjectionConstructor()); var _child = new ContainerWrapper(container.CreateChildContainer()); switch (ConfigurationManager.AppSettings["service"]) { case ServiceOptions.Web: container.RegisterType<IAuthorServiceWrapper, WebAuthorServiceWrapper>(new InjectionConstructor(_child.Container.Resolve(typeof(AuthorWebServiceSoap)))); container.RegisterType<IBookServiceWrapper, WebBookServiceWrapper>(new InjectionConstructor(_child.Container.Resolve(typeof(BookWebServiceSoap)))); break; case ServiceOptions.Wcf: default: container.RegisterType<IAuthorServiceWrapper, WcfAuthorServiceWrapper>(new InjectionConstructor(_child.Container.Resolve(typeof(IAuthorService)))); container.RegisterType<IBookServiceWrapper, WcfBookServiceWrapper>(new InjectionConstructor(_child.Container.Resolve(typeof(IBookService)))); break; } }
public ContainerSelectPage(ContainerWrapper containerWrapper, Action callOnFinished, List <StorageContainer> containers, List <int> idsToSkip = null) { this.BackgroundColor = PageColors.secondaryColor; this.Content = mainScrollLayout; mainScrollLayout.Content = mainLayout; this.Title = "Choose a location"; foreach (StorageContainer container in containers) { if (idsToSkip != null && idsToSkip.Contains(container.GetId())) { } else { Action onTap = () => { containerWrapper.Container = container; callOnFinished.Invoke(); Navigation.PopAsync(); }; mainLayout.Children.Add(new ContainerPanelView(container, LocationsView.LocationImageWidth, LocationsView.LocationImageWidth, onTap)); } } }
public ScriptTaskWrapper(ContainerWrapper containerWrapper, string scriptProjectName, bool hasReference, ScriptTaskScope scope) : base(containerWrapper, "STOCK:ScriptTask") { ScriptTask = Convert.ChangeType(TaskHost.InnerObject, scriptTaskType); ScriptTask.ScriptLanguage = cSharpDisplayName; if (hasReference) { ScriptingEngine.VstaHelper.LoadProjectFromStorage(scriptStorages[scriptProjectName]); } else { try { ScriptingEngine.VstaHelper.LoadNewProject(ScriptTask.ProjectTemplatePath, null, scriptProjectName); } catch (System.IO.FileNotFoundException ex) { throw new InvalidOperationException($"Failed to load dependency {ex.FileName}. Ensure that you have installed the required SSIS components for your version of SQL Server.", ex); } // Add the ScriptStorage to the global list so it can be accessed later by a ScriptTaskReference. if (scope == ScriptTaskScope.Project) { scriptStorages[scriptProjectName] = ScriptStorage; } } ScriptingEngine.SaveProjectToStorage(); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory()); var container = new ContainerWrapper(); container.InitializeContainer(); }
public static void OrganizeFileOnDisk(VCFileWrapper file) { string root = file.ContainingProject.GetProjectRoot(); if (root == null) { throw new InvalidOperationException("project root not set"); } string filePath = PathHelper.GetAbsolutePath(root, file.FilterPath); if (filePath == file.FullPath) { return; } try { Directory.CreateDirectory(Path.GetDirectoryName(filePath)); File.Move(file.FullPath, filePath); ContainerWrapper parent = file.Parent; file.Remove(); parent.AddFile(filePath); } catch (Exception e) { MessageBox.Show("Could not move file: " + e.Message, "VC File Utilities", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IActionResult ListContainersAndContents( [FromServices] ILogger <StorageAccountContainerController> logger, [FromQuery] string storageAccountName, [FromQuery] string sharedAccessSignatureToken ) { ContainerWrapper storageAccountContainerWrapper = new ContainerWrapper(storageAccountName, sharedAccessSignatureToken); Pageable <Azure.Storage.Blobs.Models.BlobContainerItem> blobs = storageAccountContainerWrapper.BlobContainerItems; List <dynamic> container = new List <dynamic>(); foreach (var item in blobs) { var containerItems = storageAccountContainerWrapper.GetContainerContents(item.Name); List <dynamic> containerItemsList = new List <dynamic>(); foreach (var containerItem in containerItems) { containerItemsList.Add(new { containerItem.Name, containerItem.Properties.LastModified, containerItem.Properties.ContentLength }); } container.Add(new { item.Name, item.Properties, Blobs = containerItemsList }); logger.LogInformation($"{item.Name} found"); } return(new JsonResult(container)); }
private static void BuildControl(ContainerWrapper wrapper) { var controlAssemblies = new[] { typeof(IGateway).GetTypeInfo().Assembly }; wrapper.Container .RegisterSingleton <IRequestDispatcher>(() => new DefaultRequestDispatcher(wrapper)); wrapper.Container .Register(typeof(IQueryHandler <,>), controlAssemblies); wrapper.Container .Register(typeof(IAsyncQueryHandler <,>), controlAssemblies); wrapper.Container .Register(typeof(ICommandHandler <>), controlAssemblies); wrapper.Container .Register(typeof(IAsyncCommandHandler <>), controlAssemblies); wrapper.Container .RegisterSingleton <IEventDispatcher>(() => new EventDispatcher(wrapper.Container)); // We don't register blindly all event handlers here, // only presenters are registered as event handlers later in BuildPresentation #if DEBUG wrapper.Container .RegisterDecorator(typeof(IRequestDispatcher), typeof(DebugRequestDispatcher), Lifestyle.Singleton); #endif }
public static VCFileWrapper ReAddFile(VCFileWrapper file) { ContainerWrapper parent = file.Parent; string path = file.FullPath; file.Remove(); return(parent.AddFile(path)); }
public void Test_CalculateMethod_ContaierWrapper() { int itemsCount = 1000000; ICalculator <int, ContainerWrapper> calculator = new ContainerNodesReflectionCalculator <ContainerWrapper>(); ContainerWrapper container = new ContainerWrapper(itemsCount); Assert.AreEqual(itemsCount, calculator.Calculate(container)); }
public void Dispose() { if (this._container != null) { this._container.Dispose(); } this._container = null; }
private static void BuildManagement(ContainerWrapper wrapper, Frame presentationFrame) { wrapper.Container .RegisterSingleton <INavigationService>( () => new FrameNavigationService(presentationFrame, navigationStackName: "AppFrame")); wrapper.Container .RegisterSingleton <ICredentialManager, CredentialManager>(); wrapper.Container .RegisterSingleton <IUpdateManager, UpdateManager>(); }
private static void AddExpressions(ContainerWrapper containerWrapper, List <PropertyExpression> expressions) { if (expressions == null) { return; } foreach (PropertyExpression expression in expressions) { containerWrapper.SetExpression(expression.PropertyName, expression.Value); } }
private static void BuildPresentation(ContainerWrapper wrapper) { var presentationAssembly = typeof(PresenterLocator).GetTypeInfo().Assembly; var excludedServiceTypes = new[] { typeof(IDisposable), typeof(INotifyPropertyChanged), typeof(INavigable), typeof(ITombstone) }; var registrations = (from presenterType in presentationAssembly.GetExportedTypes() let isPagePresenter = presenterType.GetTypeInfo().IsSubclassOf(typeof(NavigablePresenter)) let isDialogPresenter = presenterType.GetTypeInfo().IsSubclassOf(typeof(DialogPresenter)) where presenterType.GetTypeInfo().IsAbstract == false && (isPagePresenter || isDialogPresenter) select new { Services = presenterType.GetInterfaces().Except(excludedServiceTypes).ToArray(), Implementation = presenterType, Registration = isPagePresenter ? Lifestyle.Singleton.CreateRegistration(presenterType, wrapper.Container) : Lifestyle.Transient.CreateRegistration(presenterType, wrapper.Container), IsTransient = isDialogPresenter, }).ToArray(); foreach (var reg in registrations) { wrapper.Container.AddRegistration(reg.Implementation, reg.Registration); if (reg.IsTransient) { reg.Registration.SuppressDiagnosticWarning(DiagnosticType.DisposableTransientComponent, justification: "Dialog presenter lifetime is handled by DialogManager."); } } // Mostly these are event handler interfaces var serviceTypes = registrations.SelectMany(reg => reg.Services).Distinct(); foreach (var item in serviceTypes) { var serviceType = item; var implRegistrations = from reg in registrations where reg.Services.Contains(serviceType) select reg.Registration; foreach (var reg in implRegistrations) { wrapper.Container.AddRegistration(serviceType, reg); } } wrapper.Container .RegisterSingleton <IDialogManager, DialogManager>(); wrapper.Container .RegisterSingleton(() => new PresenterLocator(wrapper)); }
public MainWindowViewModel() { var initializer = new ExampleStructGrammar(); Grammar = initializer.GetGrammar(); InputData = initializer.GetData(); foreach (var item in actionsContainer.Actions) { ContainerWrapper.Add(new ActionContainerWrapper(actionsContainer, item.Key)); } }
public static void RemoveEmptyFilters(ContainerWrapper container) { foreach (VCFilterWrapper child in container.Filters) { RemoveEmptyFilters(child); } if (!container.Filters.Any() && !container.Files.Any() && container is VCFilterWrapper) { (container as VCFilterWrapper).Remove(); } }
public static IServiceProvider Build(Frame presentationFrame) { var wrapper = new ContainerWrapper(new Container()); BuildData(wrapper); BuildManagement(wrapper, presentationFrame); BuildControl(wrapper); BuildPresentation(wrapper); #if DEBUG wrapper.Container.Verify(); #endif return(wrapper); }
protected override void CreateTestObjectInstance(params object[] args) { base.CreateTestObjectInstance(ContainerWrapper.GetContainer()); var routes = new RouteCollection(); ControllerContext .Setup(x => x.HttpContext) .Returns(ContextBase.Object); TestObject.ControllerContext = ControllerContext.Object; TestObject.Url = new UrlHelper(new RequestContext(ContextBase.Object, new RouteData()), routes); TestObject.Session.Clear(); }
public static ExpressionTaskWrapper CreateTask(Expression expression, ContainerWrapper containerWrapper) { ExpressionTaskWrapper expressionTaskWrapper = new ExpressionTaskWrapper(containerWrapper) { Name = expression.Name, DelayValidation = expression.DelayValidation, ForceExecutionResult = expression.ForceExecutionResult.ToString(), Expression = expression.ExpressionValue }; expressionTaskWrapper.PropagateErrors(expression.PropagateErrors); AddExpressions(expressionTaskWrapper, expression.PropertyExpressions); return(expressionTaskWrapper); }
private static IServiceContainer GetContainer(Type type) { var containerWrapper = (ContainerWrapper)CallContext.LogicalGetData(Key); if (containerWrapper == null) { containerWrapper = new ContainerWrapper { Value = new ServiceContainer() }; InvokeConfigureMethodIfPresent(type, containerWrapper.Value); CallContext.LogicalSetData(Key, containerWrapper); } return(containerWrapper.Value); }
private Container SetupContainer(Action<IContainer> typeRegistration) { var container = new Container(); var wrapper = new ContainerWrapper(container); typeRegistration(wrapper); var registeredServices = wrapper.GetRegisteredServices(); wrapper.RegisterWhenNotExists<IMockExpressionProvider, CastleMockProvider>(); wrapper.RegisterWhenNotExists<IValueExpressionProvider, ValueExpressionProvider>(); wrapper.RegisterWhenNotExists<IExpressionBuilder, ExpressionBuilder>(); wrapper.RegisterWhenNotExists<IIdentifierValidator, CSharpIdentifierValidator>(); wrapper.RegisterWhenNotExists<INullArgumentConstructorTestMethodSourceCodeGenerator, NullArgumentConstructorTestMethodSourceCodeGenerator>(); wrapper.RegisterWhenNotExists<INullArgumentMethodTestMethodSourceCodeGenerator, NullArgumentMethodTestMethodSourceCodeGenerator>(); wrapper.RegisterWhenNotExists<ITestMethodValueProvider>(configurator.GetTestMethodValueProvider()); return container; }
/// <summary> /// 注册DbContext对象,服务对象,插件对象等 /// </summary> internal static void RegisterServiceDependency() { //注册Service and Repository var container = new Container(); var containerWrapper = ContainerWrapper.Wrapper(container); ServiceContainerManager.RegisterService(container, containerWrapper); HttpContext.Current.Items[_webApiMainContainer] = container; HttpContext.Current.Items[_webApiMainContainerWrapper] = containerWrapper; //注册plugin container var compContainer = PluginManager.Register(); var pluginContainerWrapper = CompositionContainerWrapper.Wrapper(compContainer); HttpContext.Current.Items[_webApiPluginContainerWrapper] = pluginContainerWrapper; }
public static void Initialize(bool globalFallbackToLocal = true, string rootPath = "") { Local = new ContainerWrapper(new FileConfigurationContainer(), new FederationConfigurationContainer(rootPath)); bool useAzureConfiguration = bool.Parse(ConfigurationManager.AppSettings["UseAzureConfiguration"] ?? "false"); if (useAzureConfiguration) { AppDomain.CurrentDomain.Load("WindowsServer.Azure.Common"); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { var cloudServiceType = assembly.GetType("WindowsServer.Azure.Configuration.CloudServiceConfigurationContainer", false, false); if (cloudServiceType != null) { var container = assembly.CreateInstance(cloudServiceType.FullName) as BaseConfigurationContainer; if (container == null) { var error = "Cannot convert CloudServiceConfigurationContainer to BaseConfigurationContainer"; _logger.Error(error); throw new Exception(error); } else { if (globalFallbackToLocal) { Global = new ContainerWrapper(container, new FileConfigurationContainer(), new FederationConfigurationContainer(rootPath)); } else { Global = new ContainerWrapper(container, new FederationConfigurationContainer(rootPath)); } } break; } } } if (Global == null) { Global = new ContainerWrapper(new FileConfigurationContainer(), new FederationConfigurationContainer(rootPath)); } _logger.Info("ConfigurationCenter.Global is " + Global.ToString()); }
public IActionResult CreateContainer( [FromServices] ILogger <StorageAccountContainerController> logger, [FromQuery] string storageAccountName, [FromQuery] string sharedAccessSignatureToken, [FromQuery] string containerName ) { try { ContainerWrapper storageAccountContainerWrapper = new ContainerWrapper(storageAccountName, sharedAccessSignatureToken); var result = storageAccountContainerWrapper.CreateContainer(containerName); return(new CreatedResult(containerName, result)); } catch (Exception ex) { logger.LogError($"Error creating container {containerName}, {ex.Message}"); throw ex; } }
/// <summary> /// Create a new Container Scope with the specified Container Key /// </summary> /// <param name="key">Key is used to aces a logical call context data slot for an IContainer</param> public ContainerScope(string key) { _key = key; var wrapper = (ContainerWrapper)CallContext.LogicalGetData(_key); if (wrapper != null && wrapper.Container != null) { _container = wrapper.Container; _owner = false; return; } _container = Ioc.GetDisposableContainer(); _owner = true; wrapper = new ContainerWrapper(_container); CallContext.LogicalSetData(CurrentContainerKey, wrapper); }
private static void AddPrecedenceConstraints(ContainerWrapper taskContainer, ExecutableWrapper task, PrecedenceConstraintList constraints) { if (constraints != null) { foreach (InputPath input in constraints.Inputs) { ExecutableWrapper sourceTask = taskContainer.FindTask(input.OutputPathName); if (sourceTask == null) { throw new Exception($"Failed to find task {input.OutputPathName}, referenced by {task.Name} in container {taskContainer.Name}!"); } string evaluationValue = input.EvaluationValue.ToString(); string evaluationOperation = input.EvaluationOperation.ToString(); bool logicalAnd = constraints.LogicalType == LogicalOperationEnum.And; taskContainer.AddPrecedenceConstraint(sourceTask, task, input.Expression, evaluationValue, evaluationOperation, logicalAnd); } } }
private static void BuildData(ContainerWrapper wrapper) { var dataAccessAssembly = typeof(Gateway).GetTypeInfo().Assembly; var baseGatewayIface = typeof(IGateway); var registrations = from type in dataAccessAssembly.GetExportedTypes() where type.GetTypeInfo().IsAbstract == false && type.GetInterfaces().Contains(baseGatewayIface) select new { Service = type.GetInterfaces().Single(iface => iface != baseGatewayIface && baseGatewayIface.IsAssignableFrom(iface)), Implementation = type }; foreach (var reg in registrations) { wrapper.Container.Register(reg.Service, reg.Implementation, Lifestyle.Singleton); } }
public ExecuteSqlTask(ExecuteSql executeSql, ContainerWrapper containerWrapper) { ExecuteSqlTaskWrapper = new ExecuteSqlTaskWrapper(containerWrapper) { Name = executeSql.Name, DelayValidation = executeSql.DelayValidation, ForceExecutionResult = executeSql.ForceExecutionResult.ToString(), BypassPrepare = executeSql.BypassPrepare, CodePage = executeSql.CodePage, ConnectionName = executeSql.ConnectionName, ResultSetType = (int)executeSql.ResultSet, SqlStatementSource = executeSql.SqlStatement.Value, TimeOut = executeSql.TimeOut, TypeConversionMode = (int)executeSql.TypeConversionMode }; ExecuteSqlTaskWrapper.PropagateErrors(executeSql.PropagateErrors); AddExpressions(ExecuteSqlTaskWrapper, executeSql.PropertyExpressions); AddResultSetBindings(executeSql.ResultSet, executeSql.Results); AddParameterBindings(executeSql.SqlParameters); }
private void Analyze() { bool result = false; if (Splitter == "" || Or == "" || Range == "" || Empty == "") { MessageBox.Show("Заполните все поля специальных символов."); return; } if (ContainerWrapper.Where(c => c.Name == "").Any()) { MessageBox.Show("Заполните все идентификаторы действий."); return; } actionsContainer.Clear(); try { Grammar gram = new Grammar(Grammar, new SpecialSymbols(Splitter, Empty.First(), Or.First(), Range.First()), actionsContainer); result = gram.Validate(InputData); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (result) { Result = "Разбор завершен успешно."; } else { Result = "Во время разбора возникла ошибка."; } OnPropertyChanged(nameof(Result)); }
//makes the menu page to open private PopupPageMenu MakeMenuPage() { PopupPageMenu menu = new PopupPageMenu(); //move container menu button Grid moveContainerGrid = menu.AddLabelAndImage("Move Container", "move_to_container"); TapGestureRecognizer moveContainerGesture = new TapGestureRecognizer(); ContainerWrapper containerWrapper = new ContainerWrapper(); //to call when the container is selected Action callOnMoveSelected = () => { if (containerWrapper.Container != null) { MoveHighlightedItems(containerWrapper.Container); PopupNavigation.Instance.PushAsync(new PopupTextNotification("Items moved")); container = DatabaseHandler.GetDatabase().GetContainer(container.GetId(), container.GetLocation()); MasterNavigationPage.current.Refresh(); } }; moveContainerGesture.Tapped += (sen, e) => { PopupNavigation.Instance.PopAsync(); if (container.GetLocation().GetContainers().Count <= 1) //if there arent enough locations to move, display an error { PopupNavigation.Instance.PushAsync(new PopupErrorNotification("You need more containers to do that")); } else { Navigation.PushAsync(new ContainerSelectPage(containerWrapper, callOnMoveSelected, container.GetLocation().GetContainers(), new List <int>() { container.GetId() })); } }; moveContainerGrid.GestureRecognizers.Add(moveContainerGesture); //delete item menu button Grid deleteItemGrid = menu.AddLabelAndImage("Delete Items", "trash"); TapGestureRecognizer deleteItemGesture = new TapGestureRecognizer(); deleteItemGesture.Tapped += (sen, e) => { if (CanDelete()) //if can delete - delete, else give error messxage { Delete(); PopupNavigation.Instance.PopAsync(); } else { PopupNavigation.Instance.PushAsync(new PopupErrorNotification("Unable to delete")); } }; deleteItemGrid.GestureRecognizers.Add(deleteItemGesture); return(menu); }
protected TaskWrapper(ContainerWrapper containerWrapper, string moniker) : base(containerWrapper, moniker) { TaskHost = Convert.ChangeType(InnerObject, taskHostType); }
public DataFlowTask(DataFlow dataFlow, ProjectWrapper projectWrapper, PackageWrapper packageWrapper, ContainerWrapper containerWrapper) { DataFlowTaskWrapper = new DataFlowTaskWrapper(containerWrapper) { Name = dataFlow.Name, DelayValidation = dataFlow.DelayValidation, ForceExecutionResult = dataFlow.ForceExecutionResult.ToString(), AutoAdjustBufferSize = dataFlow.AutoAdjustBufferSize, DefaultBufferMaxRows = int.Parse(dataFlow.DefaultBufferMaxRows, CultureInfo.InvariantCulture), DefaultBufferSize = int.Parse(dataFlow.DefaultBufferSize, CultureInfo.InvariantCulture) }; DataFlowTaskWrapper.PropagateErrors(dataFlow.PropagateErrors); AddComponents(dataFlow.Components, packageWrapper, projectWrapper); }
private static IServiceContainer GetContainer(Type type) { var containerWrapper = (ContainerWrapper)CallContext.LogicalGetData(Key); if (containerWrapper == null) { containerWrapper = new ContainerWrapper { Value = new ServiceContainer() }; InvokeConfigureMethodIfPresent(type, containerWrapper.Value); CallContext.LogicalSetData(Key, containerWrapper); } return containerWrapper.Value; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _containerWrapper.Dispose(); _containerWrapper = null; }
/// <summary> /// Initializes a new instance of the <see cref="ContainerFactory"/> class. /// </summary> /// <param name="container">The container.</param> public ContainerFactory(Container container) { _containerWrapper = new ContainerWrapper(container); }
static ConfigurationCenter() { Local = new ContainerWrapper(new FileConfigurationContainer(), new MachineConfigurationContainer()); Global = new ContainerWrapper(new FileConfigurationContainer(), new MachineConfigurationContainer(), new WebApiConfigurationContainer()); }