本文整理汇总了C#中CodeGenerationContext类的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerationContext类的具体用法?C# CodeGenerationContext怎么用?C# CodeGenerationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeGenerationContext类属于命名空间,在下文中一共展示了CodeGenerationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSharpGatewayExpressionBinder
private CSharpGatewayExpressionBinder(CodeGenerationContext codeGenerationContext)
{
this.CodeGenerationContext = codeGenerationContext;
this.httpClientType = FickleType.Define(this.CodeGenerationContext.Options.ServiceClientTypeName ?? "HttpClient");
this.httpStreamSerializerType = FickleType.Define("IHttpStreamSerializer");
}
示例2: ElementGenerator
/// <summary>
/// Constructor for the custom code generator
/// </summary>
/// <param name="context">Context of the current code generation operation based on how scaffolder was invoked(such as selected project/folder) </param>
/// <param name="information">Code generation information that is defined in the factory class.</param>
public ElementGenerator(
CodeGenerationContext context,
CodeGeneratorInformation information)
: base(context, information)
{
_viewModel = new ElementViewModel();
}
示例3: CustomCodeGenerator
/// <summary>
/// Constructor for the custom code generator
/// </summary>
/// <param name="context">Context of the current code generation operation based on how scaffolder was invoked(such as selected project/folder) </param>
/// <param name="information">Code generation information that is defined in the factory class.</param>
public CustomCodeGenerator(
CodeGenerationContext context,
CodeGeneratorInformation information)
: base(context, information)
{
_viewModel = new CustomViewModel(Context);
}
示例4: PropertiesToCopyExpressionBinder
protected PropertiesToCopyExpressionBinder(CodeGenerationContext codeGenerationContext, Type type, Expression zone, Expression theCopy)
{
this.codeGenerationContext = codeGenerationContext;
this.type = type;
this.zone = zone;
this.theCopy = theCopy;
}
示例5: CustomViewModel
/// <summary>
/// Constructor
/// </summary>
/// <param name="context">The code generation context</param>
public CustomViewModel(CodeGenerationContext context)
{
this.Context = context;
// we typically name our custom binding handlers like this
this.CustomBindingHandlerName = "yourBindingHandler";
// not sure on this one, we'll set it as a global dependency by default, if for nothing other than convenience
this.IncludeAsGlobalDependency = true;
// normally we dont generate unit tests for a custom binding handler, only if we're being thorough
this.GenerateUnitTests = false;
// we normally don't have less files for a custom binding handler, so set this to off as default
this.GenerateLessFile = false;
// if we do want a less file, we'll probably want that imported
this.ImportLessFile = true;
this.CreateInitCallback = true;
this.CreateUpdateCallback = false;
this.MasterLessFilePath = @"src\css\all-components.less";
this.UnitTestModuleLocation = @"src\test\all-tests.ts";
this.RootPathForBindingHandler = @"src\bindingHandlers\";
this.UnitTestCreationLocation = @"src\test\bindingHandlers\";
this.PathForAmdDependency = @"src/app/startup.ts";
}
示例6: GetInstalledPackages
internal static IEnumerable<IVsPackageMetadata> GetInstalledPackages(CodeGenerationContext context)
{
var packageInstallerServices = context.ServiceProvider
.GetService<IComponentModel, SComponentModel>().GetService<IVsPackageInstallerServices>();
return packageInstallerServices.GetInstalledPackages(context.ActiveProject);
}
示例7: FieldGenerator
/// <summary>
/// Constructor for the custom code generator
/// </summary>
/// <param name="context">Context of the current code generation operation based on how scaffolder was invoked(such as selected project/folder) </param>
/// <param name="information">Code generation information that is defined in the factory class.</param>
public FieldGenerator(
CodeGenerationContext context,
CodeGeneratorInformation information)
: base(context, information)
{
_viewModel = new FieldViewModel();
}
示例8: IsApplicableProject
private static bool IsApplicableProject(CodeGenerationContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if (ProjectLanguage.CSharp == context.ActiveProject.GetCodeLanguage())
{
FrameworkName targetFramework = null;
// GetTargetFramework() may:
// 1) Throw an exception if TargetFramework string is not valid during the internal parsing.
// 2) Return null if the active project is not null but the TargetFrameworkMoniker is null.
//
// Both of them fall into the case in which the mvc scaffolding does not support the target framework.
try
{
targetFramework = context.ActiveProject.GetTargetFramework();
}
catch
{
return false;
}
if (targetFramework != null &&
targetFramework.Identifier == ".NETFramework" && targetFramework.Version >= new Version(4, 5))
{
return true;
}
}
return false;
}
示例9: Bind
public static Expression Bind(CodeGenerationContext codeGenerationContext, TypeDefinitionExpression expression, ParameterExpression zone, ParameterExpression theCopy)
{
var builder = new PropertiesToCopyExpressionBinder(codeGenerationContext, expression.Type, zone, theCopy);
builder.Visit(expression);
return builder.statements.ToStatementisedGroupedExpression();
}
示例10: Build
public static Expression Build(TypeDefinitionExpression expression, CodeGenerationContext context)
{
var builder = new PropertiesToDictionaryExpressionBinder(expression.Type, context);
builder.Visit(expression);
return builder.propertySetterExpressions.ToStatementisedGroupedExpression(GroupedExpressionsExpressionStyle.Wide);
}
示例11: GetWrappedResponseType
public static Type GetWrappedResponseType(CodeGenerationContext context, Type type)
{
if (TypeSystem.IsPrimitiveType(type) || type is FickleListType)
{
return context.ServiceModel.GetServiceType(GetValueResponseWrapperTypeName(type));
}
return type;
}
示例12: IsSupported
/// <summary>
/// Provides a way to check if the custom scaffolder is valid under this context
/// </summary>
/// <param name="codeGenerationContext">The code generation context</param>
/// <returns>True if valid, False otherwise</returns>
public override bool IsSupported(CodeGenerationContext codeGenerationContext)
{
if (codeGenerationContext.ActiveProject.CodeModel.Language != EnvDTE.CodeModelLanguageConstants.vsCMLanguageCSharp)
{
return false;
}
return true;
}
示例13: CustomViewModel
/// <summary>
/// Constructor
/// </summary>
/// <param name="context">The code generation context</param>
public CustomViewModel(CodeGenerationContext context)
{
Context = context;
ICodeTypeService codeTypeService = (ICodeTypeService)Context.ServiceProvider.GetService(typeof(ICodeTypeService));
this.ModelTypes = codeTypeService.GetAllCodeTypes(Context.ActiveProject)
//.Where(codeType => codeType.IsValidWebProjectEntityType())
.Where(codeType => codeType.IsDerivedType("System.Web.Http.ApiController"))
.Select(codeType => new ModelType(codeType));
}
示例14: ScaffolderModel
protected ScaffolderModel(CodeGenerationContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
Context = context;
ServiceProvider = context.ServiceProvider;
}
示例15: EnsureDependencyInstalled
public FrameworkDependencyStatus EnsureDependencyInstalled(CodeGenerationContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
ODataDependencyInstaller dependencyInstaller = new ODataDependencyInstaller(context, VisualStudioIntegration);
return dependencyInstaller.Install();
}