Пример #1
0
        public string getEntityCollectionTransformPath()
        {
            string path;

            path = "..\\..\\Templates\\" + CodeLanguage.ToString() + "\\" + Pattern + "\\" + EntityCollectionTransform;
            return(path);
        }
        public override bool Open()
        {
            CodeLanguage = count % 2 == 0 ? CodeLanguage.XAML : CodeLanguage.CS;
            count++;
            DisplayName = string.Format("File{0}.{1}", count, CodeLanguage.ToString().ToLower());
            Glyph       = new BitmapImage(new Uri("/DockingDemo;component/Images/VS2010Docking/FileCS_16x16.png", UriKind.Relative));
            Description = object.Equals(CodeLanguage, CodeLanguage.XAML) ? "Windows Markup File" : "Visual C# Source file";
            Footer      = string.Format("c:\\...\\DockingDemo\\{0}", DisplayName);
            string filename = "VS2010Docking." + CodeLanguage.ToString().ToLower();

            CodeLanguageText = new CodeLanguageText(CodeLanguage, () => { return(GetCodeText(filename)); });
            return(true);
        }
 public static string GenerateFileName(string scopeName, DirectoryInfo dirInfo, string filePrefix,
                                       string fileSuffix, CodeLanguage option)
 {
     // Check to create the directory if it doesnt exist.
     if (!dirInfo.Exists)
     {
         dirInfo.Create();
     }
     return(Path.Combine(
                dirInfo.FullName,
                string.Format("{0}{1}.{2}", string.IsNullOrEmpty(filePrefix) ? scopeName : filePrefix, fileSuffix,
                              option.ToString().ToLowerInvariant())
                ));
 }
Пример #4
0
        public static void SaveSVCFile(string ns, string syncSvcTypeName, string codeBehindFileName, string fileName, CodeLanguage option)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat(Constants.ServiceSyncServicSVCFileContents, option.ToString().ToLowerInvariant(), ns,
                                 syncSvcTypeName, new FileInfo(codeBehindFileName).Name,
                                 AssemblyName.GetAssemblyName(Assembly.GetCallingAssembly().Location).Version.ToString());
            using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.Write(builder.ToString());
                    writer.Flush();
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Takes the CodeCompileUnit and generates code for the specified language options
        /// and saves it to a file.
        /// </summary>
        /// <param name="cc">Actual CodeCompileUnit</param>
        /// <param name="option">Language Option</param>
        /// <param name="fileName">File name where the code will be saved</param>
        public static void SaveCompileUnitToFile(CodeCompileUnit cc, CodeLanguage option, string fileName)
        {
            CodeDomProvider csprovider = CodeDomProvider.CreateProvider(option.ToString());
            StringWriter    builder    = new StringWriter();

            csprovider.GenerateCodeFromCompileUnit(cc, builder, null);

            using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.Write(builder.ToString());
                    writer.Flush();
                }
            }
        }
Пример #6
0
		public virtual ICodeMap GetCodeMap(CodeLanguage codeLanguage)
		{
			if (IsFixed("GetCodeMap_" + codeLanguage.ToString() ))
			{
				return (ICodeMap) GetFixedValue("GetCodeMap_" + codeLanguage.ToString());
			}
			foreach (ICodeMap codeMap in this.m_CodeMaps)
			{
				if (codeMap.CodeLanguage.Equals(codeLanguage))
				{
					if (IsFixed())
					{
						SetFixedValue("GetCodeMap_" + codeLanguage.ToString(), codeMap);
					}
					return codeMap;
				}
			}
			return null;
		}
Пример #7
0
 public static string GenerateFileName(string scopeName, DirectoryInfo dirInfo, string filePrefix, string fileSuffix, CodeLanguage option)
 {
     // Check to create the directory if it doesnt exist.
     if (!dirInfo.Exists)
     {
         dirInfo.Create();
     }
     return Path.Combine(
         dirInfo.FullName, 
         string.Format("{0}{1}.{2}", string.IsNullOrEmpty(filePrefix) ? scopeName : filePrefix, fileSuffix,  option.ToString().ToLowerInvariant())
         );
 }
Пример #8
0
 public static void SaveSVCFile(string ns, string syncSvcTypeName, string codeBehindFileName, string fileName, CodeLanguage option)
 {
     StringBuilder builder = new StringBuilder();
     builder.AppendFormat(Constants.ServiceSyncServicSVCFileContents, option.ToString().ToLowerInvariant(), ns, 
         syncSvcTypeName, new FileInfo(codeBehindFileName).Name, 
         AssemblyName.GetAssemblyName(Assembly.GetCallingAssembly().Location).Version.ToString());
     using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter writer = new StreamWriter(fs))
         {
             writer.Write(builder.ToString());
             writer.Flush();
         }
     }
 }
Пример #9
0
        /// <summary>
        /// Takes the CodeCompileUnit and generates code for the specified language options
        /// and saves it to a file.
        /// </summary>
        /// <param name="cc">Actual CodeCompileUnit</param>
        /// <param name="option">Language Option</param>
        /// <param name="fileName">File name where the code will be saved</param>
        public static void SaveCompileUnitToFile(CodeCompileUnit cc, CodeLanguage option, string fileName)
        {
            CodeDomProvider csprovider = CodeDomProvider.CreateProvider(option.ToString());
            StringWriter builder = new StringWriter();
            csprovider.GenerateCodeFromCompileUnit(cc, builder, null);

            using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.Write(builder.ToString());
                    writer.Flush();
                }
            }

        }
Пример #10
0
 /// <summary>
 /// Gets the absolute path for the specified relative path using the
 /// specified <see cref="CodeLanguage"/>.
 /// </summary>
 /// <param name="path">The relative path.</param>
 /// <returns>An absolute path from the relative path and <see cref="CodeLanguage"/>.</returns>
 private string Get(CodeLanguage codeLang, string path)
 {
     return(string.Format(VersionInfoPath, codeLang.ToString(), path));
 }