| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 72 | 2 | 3 | 0.989 | compilation_unit |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 72 | 1 | src/NHibernate/Type/GenericBagType.cs |
| 2 | 72 | 1 | 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 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<T>"/>.</param>
/// <returns>
/// An <see cref="PersistentGenericBag<T>"/> that wraps the non NHibernate <see cref="IList<T>"/>.
/// </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);
}
}
}
|
| ||||
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);
}
}
}
|
| |||
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<T>"/>.</param>
/// <param name="collection">The unwrapped <see cref="IList{T}"/>.</param>
/// <returns>
/// An <see cref="PersistentGenericBag<T>"/> that wraps the non NHibernate <see cref="IList<T>"/>.
/// 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 Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#6cfbfb20]] | GenericBagType |
| 1 | 2 | [[#6cfbfb20]] | GenericListType |
| 2 | 1 | [[#6fda3280]] | BagType |
| 2 | 2 | [[#6fda3280]] | ListType |
| 3 | 1 | [[#6fda3220]] | PersistentGenericBag |
| 3 | 2 | [[#6fda3220]] | PersistentGenericList |