PairBiDirectionalManyToManySidesDelegate

Namespace: FluentNHibernate
We found 10 examples in language CSharp for this search. You will see 35 fragments of code.

        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }

        /// <summary>
        /// Add all fluent mappings in the assembly that contains T.
        /// </summary>
        /// <typeparam name="T">Type from the assembly</typeparam>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssemblyOf<T>()
        {
            return AddFromAssembly(typeof(T).Assembly);
        }

        /// <summary>
        /// Add all fluent mappings in the assembly
        /// </summary>
        /// <param name="assembly">Assembly to add mappings from</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssembly(Assembly assembly)
        {
            assemblies.Add(assembly);
            WasUsed = true;
            return this;
		}

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add<T>()
        {
            return Add(typeof(T));
        }

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add(Type type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            types.Add(type);
            WasUsed = true;
            return this;
        }

		/// <summary>
        /// Sets the export location for generated mappings
        /// </summary>
        /// <param name="path">Path to folder for mappings</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer ExportTo(string path)
        {
            exportPath = path;
            return this;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }

        /// <summary>
        /// Add all fluent mappings in the assembly that contains T.
        /// </summary>
        /// <typeparam name="T">Type from the assembly</typeparam>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssemblyOf<T>()
        {
            return AddFromAssembly(typeof(T).Assembly);
        }

        /// <summary>
        /// Add all fluent mappings in the assembly
        /// </summary>
        /// <param name="assembly">Assembly to add mappings from</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssembly(Assembly assembly)
        {
            assemblies.Add(assembly);
            WasUsed = true;
            return this;
		}

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add<T>()
        {
            return Add(typeof(T));
        }

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add(Type type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            types.Add(type);
            WasUsed = true;
            return this;
        }

		/// <summary>
        /// Sets the export location for generated mappings
        /// </summary>
        /// <param name="path">Path to folder for mappings</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer ExportTo(string path)
        {
            exportPath = path;
            return this;
        }


        public override void Visit(IEnumerable<HibernateMapping> mappings)
        {
            base.Visit(mappings);

            PairManyToManys(manyToManys);
            PairOneToManys(oneToManys, references);
        }

        public override void ProcessCollection(CollectionMapping mapping)
        {
            if (mapping.Relationship is ManyToManyMapping)
                manyToManys.Add(mapping);
            if (mapping.Relationship is OneToManyMapping)
                oneToManys.Add(mapping);
        }

        public override void ProcessManyToOne(ManyToOneMapping manyToOneMapping)
        {
            references.Add(manyToOneMapping);
        }

        static void PairOneToManys(IEnumerable<CollectionMapping> collections, IEnumerable<ManyToOneMapping> refs)
        {
            var orderedCollections = collections.OrderBy(x => x.Name).ToArray();
            var orderedRefs = refs.OrderBy(x => x.Name).ToArray();

            foreach (var collection in orderedCollections)
            {
                var type = collection.ContainingEntityType;
                var reference = orderedRefs.FirstOrDefault(x => x.OtherSide == null && x.Class.GetUnderlyingSystemType() == type);

                if (reference == null) continue;

                collection.OtherSide = reference;
                reference.OtherSide = collection;
            }
        }

        void PairManyToManys(IEnumerable<CollectionMapping> rs)
        {
            if (!rs.Any()) return;

            var current = rs.First();
            var wasResolved = true;

            // get any candidates for the other side of the relationship
            var candidates = rs
                .Where(x => both_collections_point_to_each_others_types(x, current));

            // try to pair the current side with the potential other sides
            var mapping = current;

            var candidatesCount = candidates.Count();
            if (candidatesCount == 1)
                mapping = PairExactMatches(rs, current, candidates);
            else if (candidatesCount > 1)
                mapping = PairFuzzyMatches(rs, current, candidates);

            if (mapping == null)
            {
                // couldn't pair at all, going to defer to the user for this one
                // and if they can't do anything we'll just treat it as uni-directional
                mapping = current;
                wasResolved = false;
            }

            userControlledPair(mapping, rs, wasResolved);

            // both collections have been paired, so remove them
            // from the available collections
            PairManyToManys(rs.Except(mapping, (CollectionMapping)mapping.OtherSide));
        }

        static string GetMemberName(Member member)
        {
            if (member is MethodMember && member.Name.StartsWith("Get"))
                return member.Name.Substring(3);

            return member.Name;
        }


        public override void Visit(IEnumerable<HibernateMapping> mappings)
        {
            base.Visit(mappings);

            PairManyToManys(manyToManys);
            PairOneToManys(oneToManys, references);
        }

        public override void ProcessCollection(CollectionMapping mapping)
        {
            if (mapping.Relationship is ManyToManyMapping)
                manyToManys.Add(mapping);
            if (mapping.Relationship is OneToManyMapping)
                oneToManys.Add(mapping);
        }

        public override void ProcessManyToOne(ManyToOneMapping manyToOneMapping)
        {
            references.Add(manyToOneMapping);
        }

        static void PairOneToManys(IEnumerable<CollectionMapping> collections, IEnumerable<ManyToOneMapping> refs)
        {
            var orderedCollections = collections.OrderBy(x => x.Name).ToArray();
            var orderedRefs = refs.OrderBy(x => x.Name).ToArray();

            foreach (var collection in orderedCollections)
            {
                var type = collection.ContainingEntityType;
                var reference = orderedRefs.FirstOrDefault(x => x.OtherSide == null && x.Class.GetUnderlyingSystemType() == type);

                if (reference == null) continue;

                collection.OtherSide = reference;
                reference.OtherSide = collection;
            }
        }

        void PairManyToManys(IEnumerable<CollectionMapping> rs)
        {
            if (!rs.Any()) return;

            var current = rs.First();
            var wasResolved = true;

            // get any candidates for the other side of the relationship
            var candidates = rs
                .Where(x => both_collections_point_to_each_others_types(x, current));

            // try to pair the current side with the potential other sides
            var mapping = current;

            var candidatesCount = candidates.Count();
            if (candidatesCount == 1)
                mapping = PairExactMatches(rs, current, candidates);
            else if (candidatesCount > 1)
                mapping = PairFuzzyMatches(rs, current, candidates);

            if (mapping == null)
            {
                // couldn't pair at all, going to defer to the user for this one
                // and if they can't do anything we'll just treat it as uni-directional
                mapping = current;
                wasResolved = false;
            }

            userControlledPair(mapping, rs, wasResolved);

            // both collections have been paired, so remove them
            // from the available collections
            PairManyToManys(rs.Except(mapping, (CollectionMapping)mapping.OtherSide));
        }

        static string GetMemberName(Member member)
        {
            if (member is MethodMember && member.Name.StartsWith("Get"))
                return member.Name.Substring(3);

            return member.Name;
        }


        public FluentMappingsContainer OverrideBiDirectionalManyToManyPairing(PairBiDirectionalManyToManySidesDelegate userControlledPairing)
        {
            biDirectionalManyToManyPairer = userControlledPairing;
            return this;
        }

        /// <summary>
        /// Add all fluent mappings in the assembly that contains T.
        /// </summary>
        /// <typeparam name="T">Type from the assembly</typeparam>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssemblyOf<T>()
        {
            return AddFromAssembly(typeof(T).Assembly);
        }

        /// <summary>
        /// Add all fluent mappings in the assembly
        /// </summary>
        /// <param name="assembly">Assembly to add mappings from</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer AddFromAssembly(Assembly assembly)
        {
            assemblies.Add(assembly);
            WasUsed = true;
            return this;
		}

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add<T>()
        {
            return Add(typeof(T));
        }

        /// <summary>
        /// Adds a single <see cref="IMappingProvider" /> represented by the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer Add(Type type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            types.Add(type);
            WasUsed = true;
            return this;
        }

		/// <summary>
        /// Sets the export location for generated mappings
        /// </summary>
        /// <param name="path">Path to folder for mappings</param>
        /// <returns>Fluent mappings configuration</returns>
        public FluentMappingsContainer ExportTo(string path)
        {
            exportPath = path;
            return this;
        }

FluentNHibernate.Visitors.PairBiDirectionalManyToManySidesDelegate : ICloneable, ISerializable

Constructors :

public PairBiDirectionalManyToManySidesDelegate(Object object = , IntPtr method = )

Methods :

public Void Invoke(CollectionMapping current = , IEnumerable<CollectionMapping> possibles = , Boolean wasResolved = )
public IAsyncResult BeginInvoke(CollectionMapping current = , IEnumerable<CollectionMapping> possibles = , Boolean wasResolved = , AsyncCallback callback = , Object object = )
public Void EndInvoke(IAsyncResult result = )
public Void GetObjectData(SerializationInfo info = , StreamingContext context = )
public Boolean Equals(Object obj = )
public Delegate[] GetInvocationList()
public Int32 GetHashCode()
public Object get_Target()
public Object Clone()
public Object DynamicInvoke(Object[] args = )
public MethodInfo get_Method()
public Type GetType()
public String ToString()