Esempio n. 1
0
        /// <summary>
        ///     Creates a <see cref="FactoryFile"/>.
        /// </summary>
        /// <param name="ns"></param>
        /// <param name="class"></param>
        /// <param name="innerUsings"></param>
        /// <param name="outerUsings"></param>
        /// <returns></returns>
        public static FactoryFile Create(string ns,
                                         Class @class,
                                         string innerUsings,
                                         string outerUsings)
        {
            var dynamicType = CreateDynamicType(@class);

            var factoryFile = (FactoryFile)Activator.CreateInstance(dynamicType);

            factoryFile.Class = @class;
            factoryFile.Namespace = ns;
            factoryFile.InnerUsings = innerUsings;
            factoryFile.OuterUsings = outerUsings;
            factoryFile.FactoryFor = @class.Inherit;

            return factoryFile;
        }
Esempio n. 2
0
        private static Type CreateDynamicType(Class @class)
        {
            var factoryInterface = @class.Inherit.Replace('.', '_');

            return DynamicTypeBuilderService.CreateDynamicType(string.Format("{0}FactoryFile", factoryInterface), typeof(FactoryFile), factoryInterface);
        }