Create() public static method

Creates an instance of the DynamicTextTransformation class around the passed in TextTransformation shapped instance passed in, or if the passed in instance already is a DynamicTextTransformation, it casts it and sends it back.
public static Create ( object instance ) : DynamicTextTransformation
instance object
return DynamicTextTransformation
        /// <summary>
        /// Initializes an MetadataTools Instance  with the
        /// TextTransformation (T4 generated class) that is currently running
        /// </summary>
        public MetadataTools(object textTransformation)
        {
            if (textTransformation == null)
            {
                throw new ArgumentNullException("textTransformation");
            }

            _textTransformation = DynamicTextTransformation.Create(textTransformation);
        }
        /// <summary>
        /// Initializes an CodeRegion instance with the
        /// TextTransformation (T4 generated class) that is currently running
        /// </summary>
        public CodeRegion(object textTransformation)
        {
            if (textTransformation == null)
            {
                throw new ArgumentNullException("textTransformation");
            }

            _textTransformation = DynamicTextTransformation.Create(textTransformation);
        }
Example #3
0
        /// <summary>
        /// Initializes an EntityFrameworkTemplateFileManager Instance  with the
        /// TextTransformation (T4 generated class) that is currently running
        /// </summary>
        private EntityFrameworkTemplateFileManager(object textTransformation)
        {
            if (textTransformation == null)
            {
                throw new ArgumentNullException("textTransformation");
            }

            _textTransformation    = DynamicTextTransformation.Create(textTransformation);
            _generationEnvironment = _textTransformation.GenerationEnvironment;
        }
Example #4
0
        /// <summary>
        /// Initializes an MetadataLoader Instance  with the
        /// TextTransformation (T4 generated class) that is currently running
        /// </summary>
        public MetadataLoader(object textTransformation)
        {
            DefineMetadata();

            if (textTransformation == null)
            {
                throw new ArgumentNullException("textTransformation");
            }

            _textTransformation = DynamicTextTransformation.Create(textTransformation);
        }
        /// <summary>
        /// Initializes a new CodeGenerationTools object with the TextTransformation (T4 generated class)
        /// that is currently running
        /// </summary>
        public CodeGenerationTools(object textTransformation)
        {
            if (textTransformation == null)
            {
                throw new ArgumentNullException("textTransformation");
            }

            _textTransformation = DynamicTextTransformation.Create(textTransformation);
            _code = new CSharpCodeProvider();
            _ef   = new MetadataTools(_textTransformation);
            FullyQualifySystemTypes = false;
            CamelCaseFields         = true;
        }
Example #6
0
        /// <summary>
        /// Creates the VsEntityFrameworkTemplateFileManager if VS is detected, otherwise
        /// creates the file system version.
        /// </summary>
        public static EntityFrameworkTemplateFileManager Create(object textTransformation)
        {
            DynamicTextTransformation transformation = DynamicTextTransformation.Create(textTransformation);
            IDynamicHost host = transformation.Host;

#if !PREPROCESSED_TEMPLATE
            var hostServiceProvider = host.AsIServiceProvider();

            if (hostServiceProvider != null)
            {
                EnvDTE.DTE dte = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE));

                if (dte != null)
                {
                    return(new VsEntityFrameworkTemplateFileManager(transformation));
                }
            }
#endif
            return(new EntityFrameworkTemplateFileManager(transformation));
        }