Ejemplo n.º 1
0
        public void ComponentPublishesService()
        {
            ServiceContainer c = new ServiceContainer(true);

            c.Add(new PublishingComponent());
            c.Add(new ConsumingComponent());
        }
Ejemplo n.º 2
0
        public void ComponentPublishesPromotedService()
        {
            ServiceContainer parent = new ServiceContainer(true);
            ServiceContainer child  = new ServiceContainer(true);

            parent.Add(child);
            // Publishing component added to the child container.
            child.Add(new PromotedPublishingComponent());
            // Consuming component on the parent container should see the promoted service.
            parent.Add(new ConsumingComponent());
        }
Ejemplo n.º 3
0
 internal static Microsoft.Practices.ComponentModel.ServiceContainer CreateFilter(IServiceProvider provider, string filterTypeName, StringDictionary attributes, out ICodeModelEditorFilter filter)
 {
     Microsoft.Practices.ComponentModel.ServiceContainer editorServiceProvider = new Microsoft.Practices.ComponentModel.ServiceContainer(true);
     editorServiceProvider.Site = new Site(provider, editorServiceProvider, editorServiceProvider.GetType().FullName);
     editorServiceProvider.AddService(typeof(IDictionaryService), new DictionaryWrapper(attributes));
     if (string.IsNullOrEmpty(filterTypeName))
     {
         filter = null;
     }
     else
     {
         ITypeResolutionService typeResService =
             (ITypeResolutionService)provider.GetService(typeof(ITypeResolutionService));
         Type filterType = typeResService.GetType(filterTypeName);
         if (filterType == null)
         {
             filter = null;
         }
         else
         {
             filter = (ICodeModelEditorFilter)Activator.CreateInstance(filterType);
             if (filter is IComponent)
             {
                 editorServiceProvider.Add((IComponent)filter);
             }
         }
     }
     return(editorServiceProvider);
 }
Ejemplo n.º 4
0
        public void DetectContainerOnSited()
        {
            ServiceContainer            parent = new ServiceContainer();
            DetectOnSitedChildContainer child  = new DetectOnSitedChildContainer();

            parent.Add(child);

            Assert.IsTrue(child.HasDetected, "Child OnSited method not called or Site is null.");
        }
Ejemplo n.º 5
0
        public void TestSitedComponent()
        {
            ServiceContainer c = new ServiceContainer();

            c.AddService(typeof(HelloWorldService), new HelloWorldService());

            c.Add(new MyComponent(), "MyTest");
            MyComponent mc = c.Components["MyTest"] as MyComponent;

            Assert.IsTrue(mc.Run());
        }
Ejemplo n.º 6
0
 internal Microsoft.Practices.ComponentModel.ServiceContainer CreateEditorServiceProvider(IServiceProvider provider, out ISolutionPickerFilter filter)
 {
     Microsoft.Practices.ComponentModel.ServiceContainer editorServiceProvider = new Microsoft.Practices.ComponentModel.ServiceContainer(true);
     editorServiceProvider.Site = new Site(provider, editorServiceProvider, editorServiceProvider.GetType().FullName);
     editorServiceProvider.AddService(typeof(IDictionaryService), new DictionaryWrapper(attributes));
     filter = CreateEditorFilter(provider);
     if (filter is IComponent)
     {
         editorServiceProvider.Add((IComponent)filter);
     }
     return(editorServiceProvider);
 }
Ejemplo n.º 7
0
        public void ServiceContainment()
        {
            ServiceContainer parent = new ServiceContainer();

            parent.AddService(typeof(ContainerComponentTests), this);

            ContainerComponent child = new ContainerComponent();
            SimpleComponent    sc    = new SimpleComponent();

            child.Add(sc);

            Assert.IsNull(((IServiceProvider)child).GetService(
                              typeof(ContainerComponentTests)));

            parent.Add(child);

            Assert.AreSame(this, ((IServiceProvider)parent).GetService(
                               typeof(ContainerComponentTests)));
        }
Ejemplo n.º 8
0
        public void ExecuteWithNullTemplate()
        {
            // fields
            string templateName = null;

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = templateName;
            sc.Add(action);

            // Execute
            action.Execute();
        }
Ejemplo n.º 9
0
		internal Microsoft.Practices.ComponentModel.ServiceContainer CreateEditorServiceProvider(IServiceProvider provider, out ISolutionPickerFilter filter)
		{
			Microsoft.Practices.ComponentModel.ServiceContainer editorServiceProvider = new Microsoft.Practices.ComponentModel.ServiceContainer(true);
			editorServiceProvider.Site = new Site(provider, editorServiceProvider, editorServiceProvider.GetType().FullName);
			editorServiceProvider.AddService(typeof(IDictionaryService), new DictionaryWrapper(attributes));
			filter = CreateEditorFilter(provider);
			if(filter is IComponent)
			{
				editorServiceProvider.Add((IComponent)filter);
			}
			return editorServiceProvider;
		}
Ejemplo n.º 10
0
        public void CheckedDependenciesSpecificException()
        {
            ServiceContainer c = new ServiceContainer();

            c.Add(new SpecificDependencyExceptionComponent());
        }