Responsible creating an instance that can be passed to helper classes that need to access the TextTransformation members. It accesses member by name and signature rather than by type. This is necessary when the template is being used in Preprocessed mode and there is no common known type that can be passed instead
Пример #1
0
 /// <summary>
 /// Ctor to setup the ItemCollectionBuilder members
 /// </summary>
 protected ItemCollectionBuilder(DynamicTextTransformation textTransformation, string fileExtension, string edmxSectionName, string rootElementName)
 {
     _textTransformation = textTransformation;
     _fileExtension      = fileExtension;
     _edmxSectionName    = edmxSectionName;
     _rootElementName    = rootElementName;
 }
        /// <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 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);
        }
        /// <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);
        }
        /// <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;
        }
Пример #7
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;
        }
Пример #8
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 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;
        }
        /// <summary>
        /// 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.
        /// </summary>
        public static DynamicTextTransformation Create(object instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            DynamicTextTransformation textTransformation = instance as DynamicTextTransformation;

            if (textTransformation != null)
            {
                return(textTransformation);
            }

            return(new DynamicTextTransformation(instance));
        }
Пример #12
0
        /// <summary>
        /// Returns true if the specified file path is valid
        /// </summary>
        private static bool ValidateInputPath(string sourcePath, DynamicTextTransformation textTransformation)
        {
            if (String.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentException("sourcePath");
            }

            if (sourcePath == "$edmxInputFile$")
            {
                textTransformation.Errors.Add(new CompilerError(textTransformation.Host.TemplateFile ?? CodeGenerationTools.GetResourceString("Template_CurrentlyRunningTemplate"), 0, 0, string.Empty,
                                                                CodeGenerationTools.GetResourceString("Template_ReplaceVsItemTemplateToken")));
                return(false);
            }

            return(true);
        }
Пример #13
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));
        }
        /// <summary>
        /// Returns true if the specified file path is valid
        /// </summary>
        private static bool ValidateInputPath(string sourcePath, DynamicTextTransformation textTransformation)
        {
            if (String.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentException("sourcePath");
            }

            if (sourcePath == "$edmxInputFile$")
            {
                textTransformation.Errors.Add(new CompilerError(textTransformation.Host.TemplateFile ?? CodeGenerationTools.GetResourceString("Template_CurrentlyRunningTemplate"), 0, 0, string.Empty,
                    CodeGenerationTools.GetResourceString("Template_ReplaceVsItemTemplateToken")));
                return false;
            }

            return true;
        }
 /// <summary>
 /// Ctor to setup the ItemCollectionBuilder members
 /// </summary>
 protected ItemCollectionBuilder(DynamicTextTransformation textTransformation, string fileExtension, string edmxSectionName, string rootElementName)
 {
     _textTransformation = textTransformation;
     _fileExtension = fileExtension;
     _edmxSectionName = edmxSectionName;
     _rootElementName = rootElementName;
 }
 public StorageMappingItemCollectionBuilder(DynamicTextTransformation textTransformation, EdmItemCollection edmItemCollection, StoreItemCollection storeItemCollection)
     : base(textTransformation, MetadataConstants.MSL_EXTENSION, MetadataConstants.MSL_EDMX_SECTION_NAME, MetadataConstants.MSL_ROOT_ELEMENT_NAME)
 {
     _edmItemCollection = edmItemCollection;
     _storeItemCollection = storeItemCollection;
 }
Пример #17
0
 public EdmItemCollectionBuilder(DynamicTextTransformation textTransformation, IEnumerable <string> referenceSchemas)
     : this(textTransformation)
 {
     _referenceSchemas.AddRange(referenceSchemas);
 }
Пример #18
0
 public EdmItemCollectionBuilder(DynamicTextTransformation textTransformation)
     : base(textTransformation, MetadataConstants.CSDL_EXTENSION, MetadataConstants.CSDL_EDMX_SECTION_NAME, MetadataConstants.CSDL_ROOT_ELEMENT_NAME)
 {
 }
Пример #19
0
 public StorageMappingItemCollectionBuilder(DynamicTextTransformation textTransformation, EdmItemCollection edmItemCollection, StoreItemCollection storeItemCollection)
     : base(textTransformation, MetadataConstants.MSL_EXTENSION, MetadataConstants.MSL_EDMX_SECTION_NAME, MetadataConstants.MSL_ROOT_ELEMENT_NAME)
 {
     _edmItemCollection   = edmItemCollection;
     _storeItemCollection = storeItemCollection;
 }
 public StoreItemCollectionBuilder(DynamicTextTransformation textTransformation)
     : base(textTransformation, MetadataConstants.SSDL_EXTENSION, MetadataConstants.SSDL_EDMX_SECTION_NAME, MetadataConstants.SSDL_ROOT_ELEMENT_NAME)
 {
 }
 public EdmItemCollectionBuilder(DynamicTextTransformation textTransformation, IEnumerable<string> referenceSchemas)
     : this(textTransformation)
 {
     _referenceSchemas.AddRange(referenceSchemas);
 }