CloneSet227


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
72230.989compilation_unit
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1721
src/NHibernate/Type/GenericBagType.cs
2721
src/NHibernate/Type/GenericListType.cs
Clone Instance
1
Line Count
72
Source Line
1
Source File
src/NHibernate/Type/GenericBagType.cs

using System;
using System.Collections.Generic;
using NHibernate.Collection;
using NHibernate.Collection.Generic;
using NHibernate.Engine;
using NHibernate.Persister.Collection;

namespace NHibernate.Type
{
        /// <summary>
        /// An <see cref="IType"/> that maps an <see cref="IList{T}"/> collection
        /// to the database using bag semantics.
        /// </summary>
        [Serializable]
        public class GenericBagType<T> : BagType
        {
                /// <summary>
                /// Initializes a new instance of a <see cref="GenericBagType{T}"/> class for
                /// a specific role.
                /// </summary>
                /// <param name="role">The role the persistent collection is in.</param>
                /// <param name="propertyRef">The name of the property in the
                /// owner object containing the collection ID, or <see langword="null" /> if it is
                /// the primary key.</param>
                public GenericBagType(string role, string propertyRef)
                        : base(role, propertyRef, false)
                {
                }

                /// <summary>
                /// Instantiates a new <see cref="IPersistentCollection"/> for the bag.
                /// </summary>
                /// <param name="session">The current <see cref="ISessionImplementor"/> for the bag.</param>
                /// <param name="persister">The current <see cref="ICollectionPersister" /> for the bag.</param>
                /// <param name="key"></param>
                public override IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister, object key)
                {
                        return new PersistentGenericBag<T> (session);
                }

                public override System.Type ReturnedClass
                {
                        get { return typeof(IList<T> );
                            }
                }

                /// <summary>
                /// Wraps an <see cref="IList{T}"/> in a <see cref="PersistentGenericBag{T}"/>.
                /// </summary>
                /// <param name="session">The <see cref="ISessionImplementor"/> for the collection to be a part of.</param>
                /// <param name="collection">The unwrapped <see cref="IList&lt;T&gt;"/>.</param>
                /// <returns>
                /// An <see cref="PersistentGenericBag&lt;T&gt;"/> that wraps the non NHibernate <see cref="IList&lt;T&gt;"/>.
                /// </returns>
                public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
                {
                        return new PersistentGenericBag<T> (session, (IList<T> )collection);
                }

                //TODO: Add() & Clear() methods - need to see if these should be refactored back into
                // their own version of Copy or a DoCopy.  The Copy() method used to be spread out amongst
                // the various collections, but since they all had common code Add() and Clear() were made
                // virtual since that was where most of the logic was.  A different/better way might be to
                // have a Copy on the base collection that handles the standard checks and then a DoCopy
                // that performs the actual copy.
                public override object Instantiate(int anticipatedSize)
                {
                        return anticipatedSize <= 0 ? new List<T> (): new List<T> (anticipatedSize + 1);
                }

        }
}


Clone Instance
2
Line Count
72
Source Line
1
Source File
src/NHibernate/Type/GenericListType.cs

using System;
using System.Collections.Generic;
using NHibernate.Collection;
using NHibernate.Collection.Generic;
using NHibernate.Engine;
using NHibernate.Persister.Collection;

namespace NHibernate.Type
{
        /// <summary>
        /// An <see cref="IType"/> that maps an <see cref="IList{T}"/> collection
        /// to the database using list semantics.
        /// </summary>
        [Serializable]
        public class GenericListType<T> : ListType
        {
                /// <summary>
                /// Initializes a new instance of a <see cref="GenericListType{T}"/> class for
                /// a specific role.
                /// </summary>
                /// <param name="role">The role the persistent collection is in.</param>
                /// <param name="propertyRef">The name of the property in the
                /// owner object containing the collection ID, or <see langword="null" /> if it is
                /// the primary key.</param>
                public GenericListType(string role, string propertyRef)
                        : base(role, propertyRef, false)
                {
                }

                /// <summary>
                /// Instantiates a new <see cref="IPersistentCollection"/> for the list.
                /// </summary>
                /// <param name="session">The current <see cref="ISessionImplementor"/> for the list.</param>
                /// <param name="persister">The current <see cref="ICollectionPersister" /> for the list.</param>
                /// <param name="key"></param>
                public override IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister, object key)
                {
                        return new PersistentGenericList<T> (session);
                }

                public override System.Type ReturnedClass
                {
                        get { return typeof(IList<T> );
                            }
                }

                /// <summary>
                /// Wraps an <see cref="IList{T}"/> in a <see cref="PersistentGenericList{T}"/>.
                /// </summary>
                /// <param name="session">The <see cref="ISessionImplementor"/> for the collection to be a part of.</param>
                /// <param name="collection">The unwrapped <see cref="IList{T}"/>.</param>
                /// <returns>
                /// An <see cref="PersistentGenericList{T}"/> that wraps the non NHibernate <see cref="IList{T}"/>.
                /// </returns>
                public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
                {
                        return new PersistentGenericList<T> (session, (IList<T> )collection);
                }

                //TODO: Add() & Clear() methods - need to see if these should be refactored back into
                // their own version of Copy or a DoCopy.  The Copy() method used to be spread out amongst
                // the various collections, but since they all had common code Add() and Clear() were made
                // virtual since that was where most of the logic was.  A different/better way might be to
                // have a Copy on the base collection that handles the standard checks and then a DoCopy
                // that performs the actual copy.
                public override object Instantiate(int anticipatedSize)
                {
                        return anticipatedSize <= 0 ? new List<T> (): new List<T> (anticipatedSize + 1);
                }

        }
}


Clone AbstractionParameter Count: 3Parameter Bindings

using System;
using System.Collections.Generic;
using NHibernate.Collection;
using NHibernate.Collection.Generic;
using NHibernate.Engine;
using NHibernate.Persister.Collection;
namespace NHibernate.Type
{
   /// <summary>
   /// An <see cref="IType"/> that maps an <see cref="IList{T}"/> collection
   /// to the database using bag semantics.
   /// to the database using list semantics.
   /// </summary>
   [Serializable]
   public class [[#variable6cfbfb20]]<T>: [[#variable6fda3280]]
   {
      /// <summary>
      /// Initializes a new instance of a <see cref="GenericBagType{T}"/> class for
      /// Initializes a new instance of a <see cref="GenericListType{T}"/> class for
      /// a specific role.
      /// </summary>
      /// <param name="role">The role the persistent collection is in.</param>
      /// <param name="propertyRef">The name of the property in the
      /// owner object containing the collection ID, or <see langword="null" /> if it is
      /// the primary key.</param>
      public [[#variable6cfbfb20]](string role, string propertyRef): base(role, propertyRef, false)
      {
      }

      /// <summary>
      /// Instantiates a new <see cref="IPersistentCollection"/> for the bag.
      /// Instantiates a new <see cref="IPersistentCollection"/> for the list.
      /// </summary>
      /// <param name="session">The current <see cref="ISessionImplementor"/> for the bag.</param>
      /// <param name="persister">The current <see cref="ICollectionPersister" /> for the bag.</param>
      /// <param name="session">The current <see cref="ISessionImplementor"/> for the list.</param>
      /// <param name="persister">The current <see cref="ICollectionPersister" /> for the list.</param>
      /// <param name="key"></param>
      public override IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister, object key)
      {
         return new [[#variable6fda3220]]<T> (session);
      }

      public override System.Type ReturnedClass
      {
         get
         {
            return typeof(IList<T> );
         }
      }

      /// <summary>
      /// Wraps an <see cref="IList{T}"/> in a <see cref="PersistentGenericBag{T}"/>.
      /// Wraps an <see cref="IList{T}"/> in a <see cref="PersistentGenericList{T}"/>.
      /// </summary>
      /// <param name="session">The <see cref="ISessionImplementor"/> for the collection to be a part of.</param>
      /// <param name="collection">The unwrapped <see cref="IList&lt;T&gt;"/>.</param>
      /// <param name="collection">The unwrapped <see cref="IList{T}"/>.</param>
      /// <returns>
      /// An <see cref="PersistentGenericBag&lt;T&gt;"/> that wraps the non NHibernate <see cref="IList&lt;T&gt;"/>.
      /// An <see cref="PersistentGenericList{T}"/> that wraps the non NHibernate <see cref="IList{T}"/>.
      /// </returns>
      public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
      {
         return new [[#variable6fda3220]]<T> (session, (IList<T> )collection);
      }

      //TODO: Add() & Clear() methods - need to see if these should be refactored back into
      // their own version of Copy or a DoCopy.  The Copy() method used to be spread out amongst
      // the various collections, but since they all had common code Add() and Clear() were made
      // virtual since that was where most of the logic was.  A different/better way might be to
      // have a Copy on the base collection that handles the standard checks and then a DoCopy
      // that performs the actual copy.
      public override object Instantiate(int anticipatedSize)
      {
         return anticipatedSize <= 0 ?
                new List<T> (): new List<T> (anticipatedSize + 1);
      }

   }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#6cfbfb20]]
GenericBagType 
12[[#6cfbfb20]]
GenericListType 
21[[#6fda3280]]
BagType 
22[[#6fda3280]]
ListType 
31[[#6fda3220]]
PersistentGenericBag 
32[[#6fda3220]]
PersistentGenericList