bloritsch    2003/08/28 08:57:39

  Modified:    cscontainer AvalonContainer.build
               cscontainer/bin log4net-net-1.1.dll
               cscontainer/src/cs AvalonComponentFactory.cs
                        ComponentFactory.cs
               cscontainer/src/test AssemblyInfo.cs
  Added:       cscontainer/src/test ComponentFactoryTestCase.cs
                        DummyService.cs IDummyService.cs
  Log:
  add patch from hammett <[EMAIL PROTECTED]> along with a couple build improvements
  
  Revision  Changes    Path
  1.4       +100 -87   avalon-sandbox/cscontainer/AvalonContainer.build
  
  Index: AvalonContainer.build
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/cscontainer/AvalonContainer.build,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AvalonContainer.build     8 Jul 2003 17:18:54 -0000       1.3
  +++ AvalonContainer.build     28 Aug 2003 15:57:38 -0000      1.4
  @@ -1,87 +1,100 @@
  -<project name="Avalon Framework - C#" default="build">
  -  <property name="name" value="AvalonContainer"/>
  -  <property name="version" value="1.0"/>
  -  <property name="library.name" value="${name}-${version}"/>
  -  <property name="build.debug" value="true"/>
  -  <property name="build.dir" value="build"/>
  -
  -  <target name="build" description="Build the AvalonContainer dll">
  -    <csc target="library"
  -         doc="${library.name}.xml"
  -         output="${library.name}.dll"
  -         debug="${build.debug}">
  -       <references basedir="bin">
  -         <includes name="*.dll"/>
  -       </references>
  -       <sources basedir="src/cs">
  -         <includes name="**.cs"/>
  -       </sources>
  -     </csc>
  -  </target>
  -
  -  <target name="build-test" depends="build">
  -    <csc target="library"
  -         output="${library.name}-test.dll"
  -         debug="${build.debug}">
  -       <references>
  -         <includes name="*.dll"/>
  -         <includes name="bin/*.dll"/>
  -         <includes name="${nant.location}/nunit.framework.dll"/>
  -       </references>
  -       <sources basedir="src/test">
  -         <includes name="**.cs"/>
  -       </sources>
  -     </csc>
  -  </target>
  -
  -  <target name="test" depends="build-test" description="Run the NUnit tests">
  -     <nunit2 haltonfailure="true">
  -       <test assemblyname="${library.name}-test.dll"/>
  -     </nunit2>
  -  </target>
  -
  -  <target name="ndocs" depends="build" description="Build the API documentation">
  -    <ndoc verbose="true">
  -      <assemblies>
  -        <includes name="${library.name}.dll"/>
  -      </assemblies>
  -      <summaries>
  -        <includes name="src/cs/NamespaceSummary.xml"/>
  -      </summaries>
  -      <documenters>
  -        <documenter name="MSDN">
  -          <property name="OutputDirectory" value="doc\MSDN" />
  -          <property name="HtmlHelpName" value="AvalonFramework" />
  -          <property name="HtmlHelpCompilerFilename" value="hhc.exe" />
  -          <property name="IncludeFavorites" value="False" />
  -          <property name="Title" value="The Avalon Framework API Docs" />
  -          <property name="SplitTOCs" value="False" />
  -          <property name="DefaulTOC" value="" />
  -          <property name="ShowMissingSummaries" value="True" />
  -          <property name="ShowMissingRemarks" value="True" />
  -          <property name="ShowMissingParams" value="True" />
  -          <property name="ShowMissingReturns" value="True" />
  -          <property name="ShowMissingValues" value="True" />
  -          <property name="DocumentInternals" value="False" />
  -          <property name="DocumentProtected" value="True" />
  -          <property name="DocumentPrivates" value="False" />
  -          <property name="DocumentEmptyNamespaces" value="False" />
  -          <property name="IncludeAssemblyVersion" value="False" />
  -          <property name="CopyrightText" value="" />
  -          <property name="CopyrightHref" value="" />
  -        </documenter>
  -      </documenters> 
  -    </ndoc>
  -  </target>
  -
  -  <target name="clean" description="Clean up after ourselves">
  -    <delete>
  -      <fileset>
  -        <includes name="*.pdb"/>
  -        <includes name="*.dll"/>
  -        <includes name="*.xml"/>
  -        <includes name="doc"/>
  -      </fileset>
  -    </delete>
  -  </target>
  -</project>
  +<project name="Avalon Container - C#" default="build">
  +  <property name="name" value="AvalonContainer"/>
  +  <property name="version" value="1.0"/>
  +  <property name="library.name" value="${name}-${version}"/>
  +  <property name="build.debug" value="true"/>
  +  <property name="build.dir" value="build"/>
  +
  +
  +  <target name="getFramework">
  +    <available type="File" resource="../csframework/AvalonFramework-1.0.dll" 
property="avalon.framework.present"/>
  +
  +    <ifnot propertytrue="avalon.framework.present">
  +      <echo>AvalonFramework not found, building it for you...</echo>
  +      <nant buildfile="../csframework/AvalonFramework.build" target="test"/>
  +      <echo>...done</echo>
  +    </ifnot>
  +  </target>
  +
  +  <target name="build" depends="getFramework" description="Build the 
AvalonContainer dll">
  +    <csc target="library"
  +         doc="${library.name}.xml"
  +         output="${library.name}.dll"
  +         debug="${build.debug}">
  +       <references>
  +         <includes name="bin/*.dll"/>
  +         <includes name="../csframework/*.dll"/>
  +       </references>
  +       <sources basedir="src/cs">
  +         <includes name="**.cs"/>
  +       </sources>
  +     </csc>
  +  </target>
  +
  +  <target name="build-test" depends="build">
  +    <csc target="library"
  +         output="${library.name}-test.dll"
  +         debug="${build.debug}">
  +       <references>
  +         <includes name="*.dll"/>
  +         <includes name="../csframework/*.dll"/>
  +         <includes name="bin/*.dll"/>
  +         <includes name="${nant.location}/nunit.framework.dll"/>
  +       </references>
  +       <sources basedir="src/test">
  +         <includes name="**.cs"/>
  +       </sources>
  +     </csc>
  +  </target>
  +
  +  <target name="test" depends="build-test" description="Run the NUnit tests">
  +     <nunit2 haltonfailure="true">
  +       <test assemblyname="${library.name}-test.dll"/>
  +     </nunit2>
  +  </target>
  +
  +  <target name="ndocs" depends="build" description="Build the API documentation">
  +    <ndoc verbose="true">
  +      <assemblies>
  +        <includes name="${library.name}.dll"/>
  +      </assemblies>
  +      <summaries>
  +        <includes name="src/cs/NamespaceSummary.xml"/>
  +      </summaries>
  +      <documenters>
  +        <documenter name="MSDN">
  +          <property name="OutputDirectory" value="doc\MSDN" />
  +          <property name="HtmlHelpName" value="AvalonContainer" />
  +          <property name="HtmlHelpCompilerFilename" value="hhc.exe" />
  +          <property name="IncludeFavorites" value="False" />
  +          <property name="Title" value="The Avalon Container API Docs" />
  +          <property name="SplitTOCs" value="False" />
  +          <property name="DefaulTOC" value="" />
  +          <property name="ShowMissingSummaries" value="True" />
  +          <property name="ShowMissingRemarks" value="True" />
  +          <property name="ShowMissingParams" value="True" />
  +          <property name="ShowMissingReturns" value="True" />
  +          <property name="ShowMissingValues" value="True" />
  +          <property name="DocumentInternals" value="False" />
  +          <property name="DocumentProtected" value="True" />
  +          <property name="DocumentPrivates" value="False" />
  +          <property name="DocumentEmptyNamespaces" value="False" />
  +          <property name="IncludeAssemblyVersion" value="False" />
  +          <property name="CopyrightText" value="" />
  +          <property name="CopyrightHref" value="" />
  +        </documenter>
  +      </documenters> 
  +    </ndoc>
  +  </target>
  +
  +  <target name="clean" description="Clean up after ourselves">
  +    <delete>
  +      <fileset>
  +        <includes name="*.pdb"/>
  +        <includes name="*.dll"/>
  +        <includes name="*.xml"/>
  +        <includes name="doc"/>
  +      </fileset>
  +    </delete>
  +  </target>
  +</project>
  
  
  
  1.3       +3396 -2   avalon-sandbox/cscontainer/bin/log4net-net-1.1.dll
  
        <<Binary file>>
  
  
  1.2       +48 -14    avalon-sandbox/cscontainer/src/cs/AvalonComponentFactory.cs
  
  Index: AvalonComponentFactory.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/cscontainer/src/cs/AvalonComponentFactory.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AvalonComponentFactory.cs 5 Aug 2003 14:26:47 -0000       1.1
  +++ AvalonComponentFactory.cs 28 Aug 2003 15:57:38 -0000      1.2
  @@ -1,30 +1,64 @@
   using System;
  +using Apache.Avalon.Framework;
   
   namespace Apache.Avalon.Container
   {
  -     /// <summary>
  -     /// Summary description for AvalonComponentFactory.
  -     /// </summary>
  -     public class AvalonComponentFactory : IComponentFactory
  -     {
  +    /// <summary>
  +    /// Summary description for AvalonComponentFactory.
  +    /// </summary>
  +    public class AvalonComponentFactory : IComponentFactory
  +    {
           private Type m_componentType;
   
  -             public AvalonComponentFactory(Type componentType)
  -             {
  -            if (componentType == null) throw new ArgumentNullException( 
"componentType", "We must have a valid component type" );
  +        public AvalonComponentFactory(Type componentType)
  +        {
  +            if (componentType == null)
  +            {
  +                throw new ArgumentNullException(
  +                    "componentType", "We must have a valid component type" );
  +            }
  +            
               m_componentType = componentType;
           }
   
  -        public object create()
  +        #region Implementation of IComponentFactory
  +        public object Create()
           {
  -            object component = m_componentType.TypeInitializer.Invoke( null );
  +            object component = Activator.CreateInstance(m_componentType);
  +            DefaultConfiguration conf = new DefaultConfiguration();
  +
  +            ContainerUtil.Configure(component, conf);
  +            //ContainerUtil.Service(component, null);
  +            ContainerUtil.Initialize(component);
               return component;
           }
   
  -        public void destroy(object component)
  +        public void Destroy(object component)
           {
  -            if ( typeof( component ) != typeof( m_componentType ) )
  -                throw new ArgumentException( "The component passed in to destroy is 
the wrong type", "component" );
  -        }
  +            if ( component.GetType() != m_componentType )
  +            {
  +                throw new ArgumentException(
  +                        "The component passed in to destroy is the wrong type",
  +                        "component" );
  +            }
  +
  +            ContainerUtil.Shutdown(component);
        }
  +
  +        public System.Type ComponentType
  +        {
  +            get
  +            {
  +                return m_componentType;
  +            }
  +        }
  +        #endregion
  +
  +        #region Implementation of IDisposable
  +        public void Dispose()
  +        {
  +            m_componentType = null;
  +        }
  +        #endregion
  +    }
   }
  
  
  
  1.3       +9 -9      avalon-sandbox/cscontainer/src/cs/ComponentFactory.cs
  
  Index: ComponentFactory.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/cscontainer/src/cs/ComponentFactory.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ComponentFactory.cs       5 Aug 2003 14:25:28 -0000       1.2
  +++ ComponentFactory.cs       28 Aug 2003 15:57:38 -0000      1.3
  @@ -50,17 +50,17 @@
   
   namespace Apache.Avalon.Container
   {
  -     /// <summary>
  -     /// Summary description for ComponentFactory.
  -     /// </summary>
  -     public interface IComponentFactory : IDisposable
  -     {
  -        protected Type ComponentType
  +    /// <summary>
  +    /// Summary description for ComponentFactory.
  +    /// </summary>
  +    public interface IComponentFactory : IDisposable
  +    {
  +        Type ComponentType
           {
               get;
           }
   
  -        public object create();
  -        public void destroy(object component);
  -     }
  +        object Create();
  +        void Destroy(object component);
  +    }
   }
  
  
  
  1.2       +1 -1      avalon-sandbox/cscontainer/src/test/AssemblyInfo.cs
  
  Index: AssemblyInfo.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/cscontainer/src/test/AssemblyInfo.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AssemblyInfo.cs   25 Jun 2003 13:43:23 -0000      1.1
  +++ AssemblyInfo.cs   28 Aug 2003 15:57:38 -0000      1.2
  @@ -74,7 +74,7 @@
   // You can specify all the values or you can default the Revision and Build Numbers 
   // by using the '*' as shown below:
   
  -[assembly: AssemblyVersion("1.0.*")]
  +[assembly: AssemblyVersion("1.0.0.0")]
   
   //
   // In order to sign your assembly you must specify a key to use. Refer to the 
  
  
  
  1.1                  avalon-sandbox/cscontainer/src/test/ComponentFactoryTestCase.cs
  
  Index: ComponentFactoryTestCase.cs
  ===================================================================
  // ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    [EMAIL PROTECTED]
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Container.Test
  {
        using System;
        using NUnit.Framework;
        using Apache.Avalon.Framework;
        using Apache.Avalon.Container;

        [TestFixture]
        public class ComponentFactoryTestCase
        {
                [Test]
                public void Creation()
                {
                        AvalonComponentFactory factory = 
                                new AvalonComponentFactory(typeof(DummyService));
  
                        Assertion.AssertEquals(typeof(DummyService), 
factory.ComponentType);
  
                        object component = factory.Create();
  
                        Assertion.AssertNotNull(component);
                        Assertion.AssertNotNull(component as DummyService);
  
                        DummyService dummy = component as DummyService;
  
                        factory.Destroy(dummy);
  
                        Assertion.Assert("Initialize not called", dummy.flags[2]);
                        Assertion.Assert("Configure not called", dummy.flags[0]);
                        Assertion.Assert("Dispose not called", dummy.flags[1]);
                }
        }
  }
  
  
  
  1.1                  avalon-sandbox/cscontainer/src/test/DummyService.cs
  
  Index: DummyService.cs
  ===================================================================
  // ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    [EMAIL PROTECTED]
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Container.Test
  {
        using System;
        using System.Collections;
        using NUnit.Framework;
        using Apache.Avalon.Framework;

        [AvalonService(typeof(IDummyService))]
        public class DummyService : IDummyService, 
                IInitializable, IConfigurable, IDisposable
        {
                public BitArray flags = new BitArray(3);
  
                public DummyService()
                {
                }
  
                #region Implementation of IConfigurable
                public void Configure(Apache.Avalon.Framework.IConfiguration config)
                {
                        flags[0] = true;
                }
                #endregion
  
                #region Implementation of IDisposable
                public void Dispose()
                {
                        flags[1] = true;
                }
                #endregion
  
                #region Implementation of IInitializable
                public void Initialize()
                {
                        flags[2] = true;
                }
                #endregion
  
                #region Implementation of IDummyService
                public void DoSomething()
                {
                }
                #endregion
        }
  }
  
  
  
  1.1                  avalon-sandbox/cscontainer/src/test/IDummyService.cs
  
  Index: IDummyService.cs
  ===================================================================
  namespace Apache.Avalon.Container.Test
  {
        using System;
  
        public interface IDummyService
        {
                void DoSomething();
        }
  }
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to