Esempio n. 1
0
        /// <summary>
        /// Function generates the default DataContext name.
        /// </summary>
        public string GenerateDefaultDataContextTypeName()
        {
            Project         project         = ActiveProject;
            string          modelsNamespace = MvcProjectUtil.GetDefaultModelsNamespace(project.GetDefaultNamespace());
            CodeDomProvider provider        = ValidationUtil.GenerateCodeDomProvider(project.GetCodeLanguage());
            // CreateValidIdentifier considers dot as a valid identifier hence replacing the dot explicitly.
            string projectName = provider.CreateValidIdentifier(project.GetDefaultNamespace().Replace(".", String.Empty));

            DataContextName = modelsNamespace + "." + projectName + MvcProjectUtil.DataContextSuffix;

            return(DataContextName);
        }
Esempio n. 2
0
        // TODO: This is a good candidate to get into Core, since this seems like a common thing to do
        public static string GetProjectRelativePath(this ProjectItem projectItem)
        {
            Project project          = projectItem.ContainingProject;
            string  projRelativePath = null;

            string rootProjectDir = project.GetFullPath();

            rootProjectDir = MvcProjectUtil.EnsureTrailingBackSlash(rootProjectDir);
            string fullPath = projectItem.GetFullPath();

            if (!String.IsNullOrEmpty(rootProjectDir) && !String.IsNullOrEmpty(fullPath))
            {
                projRelativePath = CoreScaffoldingUtil.MakeRelativePath(fullPath, rootProjectDir);
            }

            return(projRelativePath);
        }