Exemple #1
0
            public void MapingFromType(Type T)
            {
                var res = new ExtensionList();
                var map = (IFluentMap)Activator.CreateInstance(T);

                map.MapTo(res);

                FluentMapHelper.MergeExtensions(res, ref this._extensions);
            }
Exemple #2
0
        /// <summary>
        /// Apply fluent settings to ExtensionList
        /// </summary>
        /// <param name="extensions"></param>
        public void MapTo(ExtensionList extensions)
        {
            var           ext = this._typeExtension;
            TypeExtension oldExt;

            if (extensions.TryGetValue(ext.Name, out oldExt))
            {
                FluentMapHelper.MergeExtensions(ext, ref oldExt);
            }
            else
            {
                extensions.Add(ext);
            }
            this.EachChilds(m => m.MapTo(extensions));
        }
Exemple #3
0
            /// <summary>
            /// Mapping from assembly
            /// </summary>
            /// <param name="assembly"></param>
            /// <returns></returns>
            public void MapingFromAssembly(Assembly assembly)
            {
                ExtensionList res;

                if (_hash.TryGetValue(assembly, out res))
                {
                    FluentMapHelper.MergeExtensions(res, ref _extensions);
                    return;
                }

                lock (_hash)
                {
                    if (!_hash.TryGetValue(assembly, out res))


                    {
                        res = new ExtensionList();
                        _hash.Add(assembly, res);

                        string fluentType = typeof(IFluentMap).FullName;
                        var    mapTypes   = from type in assembly.GetTypes()
                                            where type.IsClass && !type.IsAbstract && !type.IsGenericType &&
                                            (null != type.GetInterface(fluentType)) &&               // Is IFluentMap
                                            (null != type.GetConstructor(new Type[0]))
                                            // Is defaut ctor
                                            select type;
                        foreach (var fluentMapType in mapTypes)
                        {
                            MapingFromType(fluentMapType);
                        }
                        FluentMapHelper.MergeExtensions(_extensions, ref res);
                    }
                    else
                    {
                        FluentMapHelper.MergeExtensions(res, ref _extensions);
                    }
                }
            }