本文整理汇总了C#中CodeType类的典型用法代码示例。如果您正苦于以下问题:C# CodeType类的具体用法?C# CodeType怎么用?C# CodeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeType类属于命名空间,在下文中一共展示了CodeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodeExpression
/// <summary>
/// Initializes a new instance of the <see cref="CodeExpression"/> class.
/// </summary>
/// <param name="codeSpan">The literal code to be contained by this expression.</param>
/// <param name="codeType">The semantic usage of this expression.</param>
public CodeExpression(CodeSpan codeSpan, CodeType codeType)
{
if (codeSpan == null)
{
throw new ArgumentNullException("codeSpan");
}
this.codeSpan = codeSpan;
this.codeType = codeType;
}
示例2: btnGenerate_Click
private void btnGenerate_Click(object sender, EventArgs e)
{
lbOutputs.Items.Clear();
ListItem[] items = new ListItem[clbTables.CheckedItems.Count + clbViews.CheckedItems.Count];
int itemIndex = 0;
foreach (object item in clbTables.CheckedItems)
{
items[itemIndex] = item as ListItem;
itemIndex++;
}
foreach (object item in clbViews.CheckedItems)
{
items[itemIndex] = item as ListItem;
itemIndex++;
}
_SelectedItems = items;
_CodeType = rbEntities.Checked ? CodeType.Entities : CodeType.DbContext;
_DbContextName = tbDbContextName.Text;
_DefaultNamespace = tbDefaultNamespace.Text;
_OutputPath = tbPath.Text.EndsWith("\\") ? tbPath.Text : tbPath.Text + "\\";
if (Directory.Exists(_OutputPath) == false)
Directory.CreateDirectory(_OutputPath);
Task.Factory.StartNew(StartToGenerate);
}
示例3: GenerateCode
public void GenerateCode(string modelName,
CodeType baseClassType,
Dictionary<string, string> propertiesCollection,
bool overwriteViews = true)
{
Project project = Project;
string modelNamespace = baseClassType == null ? project.Name + ".Models" : baseClassType.Namespace.FullName;
List<string> properties = propertiesCollection.Keys.ToList<string>();
List<string> propertyTypes = propertiesCollection.Values.ToList<string>();
string outputPath = Path.Combine("Models", "MyModel");
AddProjectItemViaTemplate(outputPath,
templateName: "MyModel",
templateModel: new Hashtable()
{
{"ModelName" , modelName},
{"Namespace" , modelNamespace},
{"BaseClassTypeName", baseClassType == null ? "" : baseClassType.Name},
{"PropertiesCollection",properties},
{"PropertiesTypeCollection",propertyTypes}
}, overwrite: false);
}
示例4: PrepareCode
private string PrepareCode( CodeType codeType, string source )
{
if (CommonHelper.IsNullOrEmptyOrBlank(source))
return null;
string ret = string.Empty;
string[] lines = source.Trim().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines) {
string temp = line.Trim();
if (temp.StartsWith("'"))
continue;
ret += temp + Environment.NewLine;
}
switch (codeType) {
case CodeType.VBasicCodeBlock:
{
break;
}
}
return ret;
}
示例5: CodeFile
public CodeFile(CodeType type, string path, byte[] data, bool missingHeader = false)
{
Type = type;
Path = path;
Data = data;
MissingHeader = missingHeader;
}
示例6: AddStorageContexts
// Generates all of the Web Forms Pages (Default Insert, Edit, Delete),
private void AddStorageContexts(
Project project,
string selectionRelativePath,
string dbContextNamespace,
string dbContextTypeName,
CodeType modelType,
bool useMasterPage,
string masterPage = null,
bool overwriteViews = true
)
{
if (modelType == null)
{
throw new ArgumentNullException("modelType");
}
var webForms = new[] { "StorageContext", "StorageContext.KeyHelpers" };
// Now add each view
foreach (string webForm in webForms)
{
AddStorageContextTemplates(
selectionRelativePath: selectionRelativePath,
modelType: modelType,
dbContextNamespace: dbContextNamespace,
dbContextTypeName: dbContextTypeName,
webFormsName: webForm,
overwrite: overwriteViews);
}
}
示例7: IsProductNamespaceImported
/// <summary>
/// This function is used to verify if the specified <see cref="CodeType"/> is a valid class and if the class
/// contains an import statement for the specified namespace.
/// </summary>
/// <param name="codeType">The specified <see cref="CodeType"/>.</param>
/// <param name="productNamespace">The specified namespace value.</param>
/// <returns><see langword="true" /> if the <see cref="CodeType"/> contains the specified namespace import statement;
/// otherwise, <see langword="false" />
/// </returns>
/// <remarks>
// The function will not identify imports using the type aliases. For example, the function would return false for "System.Web.Mvc"
// if the imports are used as below:
// using A1 = System;
// using A1.Web.Mvc;
/// </remarks>
public static bool IsProductNamespaceImported(CodeType codeType, string productNamespace)
{
if (codeType == null)
{
throw new ArgumentNullException("codeType");
}
if (productNamespace == null)
{
throw new ArgumentNullException("productNamespace");
}
FileCodeModel codeModel = codeType.ProjectItem.FileCodeModel;
if (codeModel != null)
{
foreach (CodeElement codeElement in codeModel.CodeElements)
{
// This is needed to verify if the namespace import is present at the file level.
if (IsNamespaceImportPresent(codeElement, productNamespace))
{
return true;
}
// This is needed to verify if the import is present at the namespace level.
if (codeElement.Kind.Equals(vsCMElement.vsCMElementNamespace) && IsImportPresentUnderNamespace(codeElement, productNamespace))
{
return true;
}
}
}
return false;
}
示例8: CodeDomTypeMetadata
protected CodeDomTypeMetadata(CodeType codeType, bool isNullable, bool isTask, CodeDomFileMetadata file)
{
this.codeType = codeType;
this.isNullable = isNullable;
this.isTask = isTask;
this.file = file;
}
示例9: SetCodes
private void SetCodes(IEnumerable<WasteCodeInfo> codes, CodeType codeType)
{
var newCodes = codes as WasteCodeInfo[] ?? codes.ToArray();
if (codeType != CodeType.CustomsCode
&& !newCodes.Any(c => c.IsNotApplicable)
&& newCodes.Select(p => p.WasteCode.Id).Distinct().Count() != newCodes.Count())
{
throw new InvalidOperationException(
string.Format("The same code cannot be entered twice for notification {0}", Id));
}
if (newCodes.Any(p => p.CodeType != codeType))
{
throw new InvalidOperationException(string.Format("All codes must be of type {0} for notification {1}", codeType, Id));
}
var existingCodes = GetWasteCodes(codeType).ToArray();
foreach (var code in existingCodes)
{
WasteCodeInfoCollection.Remove(code);
}
foreach (var code in newCodes)
{
WasteCodeInfoCollection.Add(code);
}
}
示例10: PrepareCode
private string PrepareCode( CodeType codeType, string source )
{
if (CommonHelper.IsNullOrEmptyOrBlank(source))
return null;
string ret = string.Empty;
string[] lines = source.Trim().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines) {
string temp = line.Trim();
if (temp.StartsWith("//"))
continue;
ret += temp + "\n";
}
switch (codeType) {
case CodeType.CSharpFastCode:{
if (CommonHelper.IsNullOrEmptyOrBlank(ret))
return string.Empty;
if (!ret.EndsWith("/")) {
if (ret.StartsWith("from") && !ret.EndsWith(")"))
ret = "(" + ret + ")";
if (!ret.Contains(".Spool("))
ret += ".Spool();";
}
break;
}
}
return ret;
}
示例11: btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
switch (cbxCodeType.Text)
{
case "拼音":
SelectedCodeType = CodeType.Pinyin;
break;
case "五笔":
SelectedCodeType = CodeType.Wubi;
break;
case "注音":
SelectedCodeType = CodeType.TerraPinyin;
break;
case "仓颉":
SelectedCodeType = CodeType.Cangjie;
break;
case "其他":
SelectedCodeType = CodeType.Unknown;
break;
default:
SelectedCodeType = CodeType.Unknown;
break;
}
DialogResult = DialogResult.OK;
}
示例12: GetExecutionCode
public StringBuilder GetExecutionCode( IEnumerable<string> usingNamespaces, string namespaceName, string baseClassName, string className, CodeType codeType, string execCode )
{
string code = PrepareCode(codeType, execCode);
string endCode = (code ?? "").TrimEnd().ToLower().EndsWith("end sub") ? code.ToLower().Contains("class") ? Environment.NewLine : Environment.NewLine + "End Sub" : Environment.NewLine + "End Sub";
StringBuilder usingNs = new StringBuilder();
foreach (string uns in usingNamespaces)
usingNs.AppendFormat("Imports {0}{1}", uns, Environment.NewLine);
StringBuilder source = new StringBuilder();
source.AppendFormat(@"
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports System.Linq
Imports it.jodan.SpoolPad.DataContext
Imports it.jodan.SpoolPad.Extensions
{0}
namespace {1}
Public Class {2}
Inherits {3}
Protected Overrides Sub InternalRun()
{4}{5}
End Class
End namespace
", usingNs, namespaceName, className, baseClassName, code, endCode);
return source;
}
示例13: GetGenerater
public static IWordCodeGenerater GetGenerater(CodeType codeType)
{
switch (codeType)
{
case CodeType.Pinyin:
return new PinyinGenerater();
case CodeType.Wubi:
return new Wubi86Generater();
case CodeType.QingsongErbi:
return new QingsongErbiGenerater();
case CodeType.ChaoqiangErbi:
return new ChaoqiangErbiGenerater();
case CodeType.XiandaiErbi:
return new XiandaiErbiGenerater();
case CodeType.ChaoqingYinxin:
return new YingxinErbiGenerater();
case CodeType.English:
return new PinyinGenerater();
case CodeType.Yong:
return new PinyinGenerater();
case CodeType.Zhengma:
return new ZhengmaGenerater();
case CodeType.TerraPinyin:
return new TerraPinyinGenerater();
case CodeType.Cangjie:
return new Cangjie5Generater();
case CodeType.UserDefine:
{
return SelfDefiningCodeGenerater();
}
default:
return new SelfDefiningCodeGenerater();
}
}
示例14: btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
switch (cbxCodeType.Text)
{
case "拼音":
SelectedCodeType = CodeType.Pinyin;
break;
case "五笔":
SelectedCodeType = CodeType.Wubi;
break;
case "二笔":
SelectedCodeType = CodeType.Erbi;
break;
case "英语":
SelectedCodeType = CodeType.English;
break;
case "永码":
SelectedCodeType = CodeType.Yong;
break;
case "郑码":
SelectedCodeType = CodeType.Zhengma;
break;
case "内码":
SelectedCodeType = CodeType.InnerCode;
break;
case "其他":
SelectedCodeType = CodeType.Unknown;
break;
default:
SelectedCodeType = CodeType.Unknown;
break;
}
DialogResult = DialogResult.OK;
}
示例15: AddWebFormsPages
// Generates all of the Web Forms Pages (Default Insert, Edit, Delete),
private void AddWebFormsPages(
Project project,
string selectionRelativePath,
string dbContextNamespace,
string dbContextTypeName,
CodeType modelType,
bool overwriteViews = true
)
{
if (modelType == null)
{
throw new ArgumentNullException("modelType");
}
var webForms = new[] { "Index", "Create", "Edit", "Delete", "Details", "Resources" };
// Now add each view
foreach (string webForm in webForms)
{
AddWebFormsViewTemplates(
selectionRelativePath: selectionRelativePath,
modelType: modelType,
dbContextNamespace: dbContextNamespace,
dbContextTypeName: dbContextTypeName,
webFormsName: webForm,
overwrite: overwriteViews);
}
}