Пример #1
0
        /// <summary>
        /// Creates a new instance of <see cref="RabbitBus"/>.
        /// </summary>
        /// <param name="connectionConfigurationFactory">
        /// A factory of <see cref="ConnectionConfiguration"/> instance.
        /// </param>
        /// <param name="registerServices">
        /// Override default services. For example, to override the default <see cref="ISerializer"/>:
        /// RabbitHutch.CreateBus("host=localhost", x => x.Register{ISerializer}(mySerializer));
        /// </param>
        /// <returns>
        /// A new <see cref="RabbitBus"/> instance.
        /// </returns>
        public static IBus CreateBus(Func <IServiceResolver, ConnectionConfiguration> connectionConfigurationFactory, Action <IServiceRegister> registerServices)
        {
            var container = new DefaultServiceContainer();

            RegisterBus(container, connectionConfigurationFactory, registerServices);
            return(container.Resolve <IBus>());
        }
Пример #2
0
 private void LoadDesigner()
 {
     //LoggingService.Info("Form Designer: BEGIN INITIALIZE");
     DefaultServiceContainer parentProvider = new DefaultServiceContainer();
     parentProvider.AddService(typeof(IUIService), new UIService());
     parentProvider.AddService(typeof(IToolboxService), new ToolboxService());
     parentProvider.AddService(typeof(IPropertyValueUIService), new PropertyValueUIService());
     AmbientProperties serviceInstance = new AmbientProperties();
     parentProvider.AddService(typeof(AmbientProperties), serviceInstance);
     parentProvider.AddService(typeof(IDesignerEventService), new FormsDesigner.Services.DesignerEventService());
     this.designSurface = new System.ComponentModel.Design.DesignSurface(parentProvider);
     parentProvider.AddService(typeof(IMenuCommandService), new FormsDesigner.Services.MenuCommandService(this.p, this.designSurface));
     parentProvider.AddService(typeof(ITypeResolutionService), new TypeResolutionService());
     DesignerLoader loader = this.loaderProvider.CreateLoader(this.generator);
     //加载XML内容
     this.designSurface.BeginLoad(loader);
     this.generator.Attach(this);
     this.undoEngine = new FormsDesignerUndoEngine(this.Host);
     IComponentChangeService service = (IComponentChangeService) this.designSurface.GetService(typeof(IComponentChangeService));
     service.ComponentChanged += delegate {
         this.viewContent.IsDirty = true;
     };
     service.ComponentAdded += new ComponentEventHandler(this.ComponentListChanged);
     service.ComponentRemoved += new ComponentEventHandler(this.ComponentListChanged);
     service.ComponentRename += new ComponentRenameEventHandler(this.ComponentListChanged);
     this.Host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.TransactionClose);
     ISelectionService service2 = (ISelectionService) this.designSurface.GetService(typeof(ISelectionService));
     service2.SelectionChanged += new EventHandler(this.SelectionChangedHandler);
     if (this.IsTabOrderMode)
     {
         this.tabOrderMode = false;
         this.ShowTabOrder();
     }
     //LoggingService.Info("Form Designer: END INITIALIZE");
 }
Пример #3
0
        static DefaultServiceContainer CreateAndInitServiceContainer()
        {
            LoggingService.Debug("ReportDesigner: CreateAndInitServiceContainer...");
            var serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(IUIService), new UIService());
            serviceContainer.AddService(typeof(IToolboxService), new ICSharpCode.Reporting.Addin.Services.ToolboxService());
            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            return(serviceContainer);
        }
Пример #4
0
        public static IEnumerable <object[]> GetContainerAdapters()
        {
            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new DefaultServiceContainer();
                    c(container);
                    return container.Resolve <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new LightInjectContainer();
                    c(new LightInjectAdapter(container));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new SimpleInjectorContainer {
                        Options = { AllowOverridingRegistrations = true }
                    };
                    c(new SimpleInjectorAdapter(container));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new StructureMapContainer(r => c(new StructureMapAdapter(r)));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var containerBuilder = new ContainerBuilder();
                    c(new AutofacAdapter(containerBuilder));
                    var container = containerBuilder.Build();
                    return container.Resolve <IServiceResolver>();
                }) });

#if NETFX
            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new WindsorContainer();
                    c(new WindsorAdapter(container));
                    return container.Resolve <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new NinjectContainer();
                    c(new NinjectAdapter(container));
                    return container.Get <IServiceResolver>();
                }) });
#endif
        }
Пример #5
0
        void LoadDesigner()
        {
            LoggingService.Info("Form Designer: BEGIN INITIALIZE");

            DefaultServiceContainer serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService);

            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), new DesignerResourceService(this.resourceStore));
            AmbientProperties ambientProperties = new AmbientProperties();

            serviceContainer.AddService(typeof(AmbientProperties), ambientProperties);
            this.typeResolutionService = new TypeResolutionService(this.PrimaryFileName);
            serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService);
            serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService());
            serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());
            serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
            serviceContainer.AddService(typeof(ProjectResourceService), new ProjectResourceService(ParserService.GetParseInformation(this.DesignerCodeFile.FileName).MostRecentCompilationUnit.ProjectContent));

            // Provide the ImageResourceEditor for all Image and Icon properties
            this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));
            this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));

            if (generator.CodeDomProvider != null)
            {
                serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider);
            }

            designSurface            = CreateDesignSurface(serviceContainer);
            designSurface.Loading   += this.DesignerLoading;
            designSurface.Loaded    += this.DesignerLoaded;
            designSurface.Flushed   += this.DesignerFlushed;
            designSurface.Unloading += this.DesignerUnloading;

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this.Control, designSurface));
            ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface);
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);

            this.loader = loaderProvider.CreateLoader(generator);
            designSurface.BeginLoad(this.loader);

            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }

            undoEngine = new FormsDesignerUndoEngine(Host);
            serviceContainer.AddService(typeof(UndoEngine), undoEngine);

            IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentChanged += ComponentChanged;
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            this.Host.TransactionClosed             += TransactionClose;

            ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));

            selectionService.SelectionChanged += SelectionChangedHandler;

            if (IsTabOrderMode)               // fixes SD2-1015
            {
                tabOrderMode = false;         // let ShowTabOrder call the designer command again
                ShowTabOrder();
            }

            UpdatePropertyPad();

            hasUnmergedChanges = false;

            LoggingService.Info("Form Designer: END INITIALIZE");
        }
Пример #6
0
        public void LoadDesigner(string formFile)
        {
            UnloadDesigner();
            DefaultServiceContainer serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService);

            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());

            AmbientProperties ambientProperties = new AmbientProperties();

            serviceContainer.AddService(typeof(AmbientProperties), ambientProperties);
            this.typeResolutionService = new TypeResolutionService();
            serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService);
            serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService());
            serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());
            serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());

            designSurface            = CreateDesignSurface(serviceContainer);
            designSurface.Loading   += this.DesignerLoading;
            designSurface.Loaded    += this.DesignerLoaded;
            designSurface.Flushed   += this.DesignerFlushed;
            designSurface.Unloading += this.DesignerUnloading;

            designerResourceService = new DesignerResourceService(this);//roman//
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService);
            loader = new CodeDomHostLoader(this.Host, formFile, FileName);

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(Host));
            ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(Host);
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);

            designSurface.BeginLoad(loader);

            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }

            undoEngine = new FormsDesignerUndoEngine(Host);
            serviceContainer.AddService(typeof(UndoEngine), undoEngine);

            IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentChanged += ComponentChanged;
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            this.Host.TransactionClosed             += TransactionClose;

            ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));

            selectionService.SelectionChanged += SelectionChangedHandler;

            if (IsTabOrderMode)               // fixes SD2-1015
            {
                tabOrderMode = false;         // let ShowTabOrder call the designer command again
                ShowTabOrder();
            }

            UpdatePropertyPad();

            hasUnmergedChanges = false;
            MakeDirty();

            PropertyGrid grid = PropertyPad.Grid;

            var gridView = (Control)grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(grid);
            var edit     = (Control)gridView.GetType().GetField("edit", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gridView);

            edit.KeyPress   += PropertyPadEditorKeyPress;
            edit.ContextMenu = new ContextMenu();
        }
Пример #7
0
        void LoadDesigner(Stream stream)
        {
            LoggingService.Info("ReportDesigner LoadDesigner_Start");
            panel = CreatePanel();
            defaultServiceContainer = CreateAndInitServiceContainer();

            LoggingService.Info("Create DesignSurface and add event's");
            designSurface = CreateDesignSurface(defaultServiceContainer);
            SetDesignerEvents();

            var ambientProperties = new AmbientProperties();

            defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties);

            defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService());
            defaultServiceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());

            defaultServiceContainer.AddService(typeof(IMenuCommandService),
                                               new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel, designSurface));

            defaultServiceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
            defaultServiceContainer.AddService(typeof(OpenedFile), base.PrimaryFile);

            LoggingService.Info("Load DesignerOptionService");
            var designerOptionService = CreateDesignerOptions();

            defaultServiceContainer.AddService(typeof(DesignerOptionService), designerOptionService);

            LoggingService.Info("Create ReportDesignerLoader");

            loader = new ReportDesignerLoader(generator, stream);
            designSurface.BeginLoad(this.loader);
            if (!designSurface.IsLoaded)
            {
                //				throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
                LoggingService.Error("designer not loaded");
            }
            //-------------

            defaultServiceContainer.AddService(typeof(INameCreationService), new NameCreationService());


            var selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService));

            selectionService.SelectionChanged += SelectionChangedHandler;

            undoEngine = new ReportDesignerUndoEngine(Host);

            var componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService));


            componentChangeService.ComponentChanged += OnComponentChanged;
            componentChangeService.ComponentAdded   += OnComponentListChanged;
            componentChangeService.ComponentRemoved += OnComponentListChanged;
            componentChangeService.ComponentRename  += OnComponentListChanged;

            this.Host.TransactionClosed += TransactionClose;

            UpdatePropertyPad();

            hasUnmergedChanges = false;

            LoggingService.Info("ReportDesigner LoadDesigner_End");
        }