本文整理汇总了C#中CodeLanguage.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CodeLanguage.ToString方法的具体用法?C# CodeLanguage.ToString怎么用?C# CodeLanguage.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeLanguage
的用法示例。
在下文中一共展示了CodeLanguage.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCodeMap
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;
}
示例2: SaveSVCFile
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();
}
}
}
示例3: GenerateFileName
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: SaveCompileUnitToFile
/// <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();
}
}
}