static void Main(string[] args) { //mysql //string tableName = "abpusers"; //var metaTableInfoList = MetaTableInfo.GetMetaTableInfoListForMysql(tableName); //反射程序集的方式生成相应代码 string className = "Order";//跟类名保持一致 var metaTableInfoList = MetaTableInfo.GetMetaTableInfoListForAssembly(className); //得到主键类型 var propertyType = metaTableInfoList.FirstOrDefault(m => m.Name == "Id").PropertyType; // server端生成 CodeGeneratorHelper.SetAppServiceIntercafeClass(className, propertyType); CodeGeneratorHelper.SetAppServiceClass(className, propertyType); CodeGeneratorHelper.SetCreateOrEditInputClass(className, metaTableInfoList); CodeGeneratorHelper.SetGetForEditOutputClass(className); CodeGeneratorHelper.SetGetInputClass(className); CodeGeneratorHelper.SetListDtoClass(className, metaTableInfoList); CodeGeneratorHelper.SetCreateOrEditInputClass(className, metaTableInfoList); CodeGeneratorHelper.SetExportingIntercafeClass(className); CodeGeneratorHelper.SetExportingClass(className, metaTableInfoList); //CodeGeneratorHelper.SetConstsClass(className); 若使用 SetAppPermissions,SetAppAuthorizationProvider,SetZh_CN_LocalizationDictionary_Here 三个方法 就可弃用该方法 CodeGeneratorHelper.SetAppPermissions(className); CodeGeneratorHelper.SetAppAuthorizationProvider(className); CodeGeneratorHelper.SetZh_CN_LocalizationDictionary_Here(className, metaTableInfoList[0].ClassAnnotation); ////client CodeGeneratorHelper.SetControllerClass(className, propertyType); CodeGeneratorHelper.SetCreateOrEditHtmlTemplate(className, metaTableInfoList); CodeGeneratorHelper.SetCreateOrEditJs(className); CodeGeneratorHelper.SetCreateOrEditViewModelClass(className); CodeGeneratorHelper.SetIndexHtmlTemplate(className, metaTableInfoList); CodeGeneratorHelper.SetIndexJsTemplate(className, metaTableInfoList); }
private Dictionary <string, CodePropertyReferenceExpression> CreatePropertiesForResources(IEnumerable <Resource> resources) { return(resources.ToDictionary(resource => resource.Key, resource => { DataTemplateResource dataTemplateResource = resource as DataTemplateResource; Tuple <CodeMemberField, CodeMemberProperty> result; if (dataTemplateResource != null) // in case of data templates { const string type = "Storm.Mvvm.DataTemplate"; result = CodeGeneratorHelper.GenerateProxyProperty(resource.PropertyName, type, fieldReference => new List <CodeStatement> { // _field = new DataTemplate(); new CodeAssignStatement(fieldReference, new CodeObjectCreateExpression(CodeGeneratorHelper.GetTypeReferenceFromName(type))), // _field.ViewId = Resource.Id.*** new CodeAssignStatement(new CodePropertyReferenceExpression(fieldReference, "ViewId"), CodeGeneratorHelper.GetAndroidResourceReference(ResourcePart.Layout, dataTemplateResource.ViewId)), // _field.LayoutInflater = LayoutInflater; new CodeAssignStatement(new CodePropertyReferenceExpression(fieldReference, "LayoutInflater"), GetLayoutInflaterReference()), // _field.ViewHolderType = typeof(viewholder class) new CodeAssignStatement(new CodePropertyReferenceExpression(fieldReference, "ViewHolderType"), new CodeTypeOfExpression(string.Format("{0}.{1}", Configuration.GeneratedNamespace, dataTemplateResource.ViewHolderClassName))), }); } else { // create a proxy property to handle the resource string type = resource.Type; Dictionary <string, string> assignments = resource.Properties; result = CodeGeneratorHelper.GenerateProxyProperty(resource.PropertyName, type, fieldReference => CodeGeneratorHelper.GenerateStatementsCreateAndAssign(fieldReference, type, assignments)); } Fields.Add(result.Item1); Properties.Add(result.Item2); return CodeGeneratorHelper.GetPropertyReference(result.Item2); })); }
protected override CodeMethodReferenceExpression GetFindViewByIdReference(string typeName) { return(new CodeMethodReferenceExpression( new CodeThisReferenceExpression(), "FindViewById", CodeGeneratorHelper.GetTypeReferenceFromName(typeName))); }
public void TestGetStoredProcCodeGenerationMetaData() { //ASSEMBLE database.Refresh(); var storedProcList = CodeGeneratorHelper.GetStoredProcedureList(database, codeGenerationSchemaName); var schemaName = storedProcList[0].SchemaName; var storeProcName = storedProcList[0].StoredProcName; //ACT var codeGenerationTargetMetaData = new CodeGenerationTargetMetaData { ProjectRootPath = projectRootPath, ProjectName = projectName, ConnectionString = connectionString, DatabaseName = databaseName, SchemaName = schemaName, StoredProcName = storeProcName, NameSpace = nameSpace }; var storedProcResultSetMetaData = CodeGeneratorHelper.ProcessStoredProcedure(codeGenerationTargetMetaData); var methodName = storedProcResultSetMetaData.MethodName; //ASSERT Assert.IsTrue(storedProcResultSetMetaData.IsStoredProcValid); Assert.IsNotNull(codeGenerationTargetMetaData); Assert.IsNotNull(storedProcResultSetMetaData); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); // Initialization assignment this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); // Generate loop start label string startLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.Label(startLabel)); // Check condition and jump out if false this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); string outLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.JumpOnFalse(outLabel)); // Loop body this._children[3].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); // Altering assignment this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); // Jump back to condition check fileManager.Output.Append(Macro.Jump(startLabel)); // Generate loop end label fileManager.Output.Append(Macro.Label(outLabel)); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); // Check condition this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); // If the condition is false, jump to the else-statement (exit label if else-statement is null) string elseLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.JumpOnFalse(elseLabel)); // Then-statement this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); // On existing else-statement jump over it string outLabel = null; if (this._children[2] != null) { outLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.Jump(outLabel)); } // Generate else label fileManager.Output.Append(Macro.Label(elseLabel)); // Else-statement and exit label if (this._children[2] != null) { this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); fileManager.Output.Append(Macro.Label(outLabel)); } }
private void GenerateCommandParameterProperties(List <ExpressionContainer> expressionContainers) { foreach (IGrouping <string, ExpressionContainer> expressions in expressionContainers.GroupBy(x => x.TargetObject)) { const string attributeName = "CommandParameter"; Regex commandParameterEventRegex = new Regex("^(?<eventName>[a-zA-Z0-9_]+)\\." + attributeName, RegexOptions.Compiled | RegexOptions.IgnoreCase); List <ExpressionContainer> commandParameterEventExpressions = expressions.Where(x => commandParameterEventRegex.IsMatch(x.TargetField)).ToList(); ExpressionContainer commandParameterExpression = expressions.SingleOrDefault(x => attributeName.Equals(x.TargetField, StringComparison.InvariantCultureIgnoreCase)); commandParameterEventExpressions.ForEach(x => x.IsCommandParameterExpression = true); if (commandParameterExpression != null) { commandParameterExpression.IsCommandParameterExpression = true; } foreach (ExpressionContainer expression in commandParameterEventExpressions) { //find associated event (if exists) string eventName = commandParameterEventRegex.Match(expression.TargetField).Groups["eventName"].Value; ExpressionContainer associatedExpression = expressions.FirstOrDefault(x => eventName.Equals(x.TargetField, StringComparison.InvariantCultureIgnoreCase) && !x.IsCommandParameterExpression); if (associatedExpression != null) { // create proxy property CommandParameterProxy to handle this var result = CodeGeneratorHelper.GenerateProxyProperty(NameGeneratorHelper.GetCommandParameterName(), "CommandParameterProxy"); Properties.Add(result.Item2); Fields.Add(result.Item1); string propertyName = CodeGeneratorHelper.GetPropertyReference(result.Item2).PropertyName; // retarget the binding expression to this new property and to the Value field expression.TargetObject = propertyName; expression.TargetField = "Value"; associatedExpression.CommandParameterTarget = propertyName; } } if (commandParameterExpression != null) { // create proxy property CommandParameterProxy to handle this var result = CodeGeneratorHelper.GenerateProxyProperty(NameGeneratorHelper.GetCommandParameterName(), "CommandParameterProxy"); Properties.Add(result.Item2); Fields.Add(result.Item1); string propertyName = CodeGeneratorHelper.GetPropertyReference(result.Item2).PropertyName; // retarget the binding expression to this new property and to the Value field commandParameterExpression.TargetObject = propertyName; commandParameterExpression.TargetField = "Value"; foreach (ExpressionContainer associatedExpression in expressions.Where(x => string.IsNullOrEmpty(x.CommandParameterTarget) && !x.IsCommandParameterExpression)) { associatedExpression.CommandParameterTarget = propertyName; } } } }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper labelHelper) { AppendNodeComment(fileManager); SyntaxTreeDeclarationNode declNode = symbolTable.GetDeclarationNodeLinkToSymbol(this.Identifier) as SyntaxTreeDeclarationNode; fileManager.Output.Append(Macro.LoadAccu(declNode.GetMemoryAddress())); }
public void SetMemoryAddress(CodeGeneratorHelper storage) { if (!this._addressReserved) { this._memoryAddress = storage.GetAndPushConstantAddress(); this._addressReserved = true; } }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); fileManager.Output.Append(Macro.MonadicOperator(this._opCodeSymbol)); }
public virtual void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper labelHelper) { foreach (var node in this._children) { if (node != null) node.GenerateCode(fileManager, symbolTable, labelHelper); } }
public bool AllocateMemoryForVariables(CodeGeneratorHelper storage) { Logger.Debug("Variable storage allocation..."); return this._rootNode.RunDelegateForType(typeof(SyntaxTreeDeclarationNode), delegate(SyntaxTreeNode node) { SyntaxTreeDeclarationNode declNode = node as SyntaxTreeDeclarationNode; declNode.SetMemoryAddress(storage); return true; }); }
public bool AllocateMemoryForConstants(CodeGeneratorHelper storage) { Logger.Debug("Constant definition..."); return this._rootNode.RunDelegateForType(typeof(SyntaxTreeConstNode), delegate(SyntaxTreeNode node) { SyntaxTreeConstNode constNode = node as SyntaxTreeConstNode; constNode.SetMemoryAddress(storage); return true; }); }
public void TestGetStoredProcedureList() { //ASSEMBLE database.Refresh(); //ACT var storedProcList = CodeGeneratorHelper.GetStoredProcedureList(database, codeGenerationSchemaName); //ASSERT Assert.IsNotNull(storedProcList); }
private CodeStatement SetValueStatement(CodeExpression targetReference, string propertyTargetName, CodeExpression assignExpression) { if (Configuration.CaseSensitivity.GetValueOrDefault()) { //In case CaseSensitivity is enabled, just give the value to the property return(new CodeAssignStatement(new CodePropertyReferenceExpression(targetReference, propertyTargetName), assignExpression)); } //If we are in mode CaseInsensitivity, use reflection to ignore case in property naming (slower execution) return(CodeGeneratorHelper.GetSetValueWithReflectionStatement(targetReference, propertyTargetName, assignExpression)); }
private CodeMethodReferenceExpression CreateSetupResourcesMethod(List <ExpressionContainer> expressions, Dictionary <string, CodePropertyReferenceExpression> resourceReferences) { CodeMemberMethod method = new CodeMemberMethod { Attributes = MemberAttributes.Private, Name = NameGeneratorHelper.ASSIGN_RESOURCE_TO_RESOURCE_METHOD_NAME, }; // Create dependency graph to check for cycle in resource assignment Dictionary <string, DependencyNode> dependencies = resourceReferences.ToDictionary(x => x.Value.PropertyName, x => new DependencyNode(x.Value.PropertyName)); foreach (ExpressionContainer expression in expressions) { string source = expression.TargetObject; string targetKey = expression.Expression.GetValue(ResourceExpression.KEY); string target = resourceReferences[targetKey].PropertyName; dependencies[source].Add(dependencies[target]); } // Check for cycle List <DependencyNode> processedNodes = new List <DependencyNode>(); List <DependencyNode> waitingNodes = dependencies.Values.ToList(); while (waitingNodes.Any()) { DependencyNode node = waitingNodes.FirstOrDefault(x => x.Dependencies.All(o => o.IsMarked)); if (node == null) { Log.LogError("Error : Circular references in Resources"); throw new InvalidOperationException("Cirular references"); } node.IsMarked = true; processedNodes.Add(node); waitingNodes.Remove(node); } // If no cycles, we have the order to assign all resources in correct order Dictionary <DependencyNode, IEnumerable <ExpressionContainer> > orderedExpressions = processedNodes.ToDictionary(x => x, x => expressions.Where(o => o.TargetObject == x.Id)); foreach (DependencyNode node in processedNodes) { foreach (ExpressionContainer expression in orderedExpressions[node]) { string resourceKey = expression.Expression.GetValue(ResourceExpression.KEY); method.Statements.Add(SetValueStatement(CodeGeneratorHelper.GetPropertyReference(expression.TargetObject), expression.TargetField, resourceReferences[resourceKey])); } } Methods.Add(method); return(CodeGeneratorHelper.GetMethodReference(method)); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); SyntaxTreeIdentNode identNode = this._children[0] as SyntaxTreeIdentNode; Symbol identSymbol = identNode.Identifier; SyntaxTreeDeclarationNode declNode = symbolTable.GetDeclarationNodeLinkToSymbol(identSymbol) as SyntaxTreeDeclarationNode; fileManager.Output.Append(Macro.StoreAccu(declNode.GetMemoryAddress())); }
static void Main(string[] args) { string className = "User"; var metaTableInfoList = MetaTableInfo.GetMetaTableInfoList(className); //得到主键类型 var propertyType = metaTableInfoList.FirstOrDefault(m => m.Name == "Id").PropertyType; CodeGeneratorHelper.SetAppServiceIntercafeClass(className, propertyType); CodeGeneratorHelper.SetAppServiceClass(className, propertyType); CodeGeneratorHelper.SetCreateOrEditInputClass(className, metaTableInfoList); }
private CodePropertyReferenceExpression CreateLocalizationServiceProperty() { CodeMethodReferenceExpression resolveMethodReference = new CodeMethodReferenceExpression( new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(CodeGeneratorHelper.GetTypeReferenceFromName("DependencyService")), "Container"), "Resolve", CodeGeneratorHelper.GetTypeReferenceFromName("ILocalizationService") ); CodeMethodInvokeExpression invokeMethod = new CodeMethodInvokeExpression(resolveMethodReference); Tuple <CodeMemberField, CodeMemberProperty> result = CodeGeneratorHelper.GenerateProxyProperty(NameGeneratorHelper.LOCALIZATION_SERVICE_PROPERTY_NAME, "ILocalizationService", invokeMethod); Fields.Add(result.Item1); Properties.Add(result.Item2); return(CodeGeneratorHelper.GetPropertyReference(result.Item2)); }
private CodeMethodReferenceExpression CreateAssignTranslationMethod(List <ExpressionContainer> expressions, CodePropertyReferenceExpression localizationServiceReference) { CodeMemberMethod method = new CodeMemberMethod { Attributes = MemberAttributes.Private, Name = NameGeneratorHelper.ASSIGN_TRANSLATION_METHOD_NAME, }; foreach (ExpressionContainer expression in expressions) { CodeMethodInvokeExpression valueReference = GenerateStatementToGetTranslation(localizationServiceReference, expression.Expression); method.Statements.Add(SetValueStatement(CodeGeneratorHelper.GetPropertyReference(expression.TargetObject), expression.TargetField, valueReference)); } Methods.Add(method); return(CodeGeneratorHelper.GetMethodReference(method)); }
public void TestGetStoredProcCodeGenerationMetaDataByStoredProcName() { //ASSEMBLE database.Refresh(); const string schemaName = "API"; const string storeProcName = "GameByGameId"; const string assemblyPath = @"C:\ProjectStoreGit\Solutia-MobilePatronsApp\Application\Server\MobilePatronsApp.Service\MobilePatronsApp.DataContracts\bin\Debug\MobilePatronsApp.DataContracts.dll"; //var assemblyPath = @"C:\ProjectStoreGit\Solutia-CandidateTracking\Application\Server\CandidateTracking.DataContracts\bin\Debug\CandidateTracking.DataContracts.dll"; byte[] data; using (var fs = System.IO.File.OpenRead(assemblyPath)) { data = new byte[fs.Length]; fs.Read(data, 0, Convert.ToInt32(fs.Length)); } if (data == null || data.Length == 0) { throw new ApplicationException("Failed to load " + assemblyPath); } var interfaceAssembly = System.Reflection.Assembly.Load(data); //ACT var codeGenerationTargetMetaData = new CodeGenerationTargetMetaData { InterfaceAssembly = interfaceAssembly, ProjectRootPath = projectRootPath, ProjectName = projectName, ConnectionString = connectionString, DatabaseName = databaseName, SchemaName = schemaName, StoredProcName = storeProcName, NameSpace = nameSpace }; var storedProcResultSetMetaData = CodeGeneratorHelper.ProcessStoredProcedure(codeGenerationTargetMetaData); var methodName = storedProcResultSetMetaData.MethodName; //ASSERT Assert.IsTrue(storedProcResultSetMetaData.IsStoredProcValid); Assert.IsNotNull(codeGenerationTargetMetaData); Assert.IsNotNull(storedProcResultSetMetaData); }
private CodeMethodReferenceExpression CreateSetupResourceForViewElementMethod(List <ExpressionContainer> expressions, Dictionary <string, CodePropertyReferenceExpression> resourceReferences) { CodeMemberMethod method = new CodeMemberMethod { Attributes = MemberAttributes.Private, Name = NameGeneratorHelper.ASSIGN_RESOURCE_TO_VIEW_METHOD_NAME, }; foreach (ExpressionContainer expression in expressions) { string resourceKey = expression.Expression.GetValue(ResourceExpression.KEY); method.Statements.Add(SetValueStatement(CodeGeneratorHelper.GetPropertyReference(expression.TargetObject), expression.TargetField, resourceReferences[resourceKey])); } Methods.Add(method); return(CodeGeneratorHelper.GetMethodReference(method)); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); string elseLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.JumpOnFalse(elseLabel)); this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); string fiiLabel = codeGeneratorHelper.GenerateNextLabel(); fileManager.Output.Append(Macro.Jump(fiiLabel)); fileManager.Output.Append(Macro.Label(elseLabel)); this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); fileManager.Output.Append(Macro.Label(fiiLabel)); }
static void Main(string[] args) { #region 获取数据源的两种方式mysql和反射程序集 //mysql //string tableName = "abpusers";//表名 //var metaTableInfoList = MetaTableInfo.GetMetaTableInfoListForMysql(tableName); //反射程序集的方式生成相应代码 var metaTableInfoList = MetaTableInfo.GetMetaTableInfoListForAssembly(); foreach (var item in metaTableInfoList) { string className = item.ClassName;//跟类名保持一致 CodeGeneratorHelper.SetAuthorizationProvider(className); CodeGeneratorHelper.SetAuthorizationPermissions(className); //得到主键类型 var propertyType = item.MetaTableInfos.FirstOrDefault(m => m.Name == "Id").PropertyType; // server端生成 CodeGeneratorHelper.SetAppServiceIntercafeClass(className, propertyType); CodeGeneratorHelper.SetAppServiceClass(className, propertyType); CodeGeneratorHelper.SetCreateOrEditInputClass(className, item.MetaTableInfos); CodeGeneratorHelper.SetDeleteInputClass(className, item.MetaTableInfos, propertyType); CodeGeneratorHelper.SetGetAllInputClass(className, item.MetaTableInfos); CodeGeneratorHelper.SetGetInputClass(className, item.MetaTableInfos, propertyType); CodeGeneratorHelper.SetUpdateInputClass(className, item.MetaTableInfos, propertyType); CodeGeneratorHelper.SetDtoOutClass(className, item.MetaTableInfos, propertyType); CodeGeneratorHelper.SetCreateOrEditViewModelClass(className); CodeGeneratorHelper.SetControllerClass(className, propertyType); CodeGeneratorHelper.SetIndexHtmlTemplate(className, item.MetaTableInfos); CodeGeneratorHelper.SetCreateHtmlTemplate(className, item.MetaTableInfos); CodeGeneratorHelper.SetUpdateHtmlTemplate(className, item.MetaTableInfos); CodeGeneratorHelper.SetIndexJsTemplate(className, item.MetaTableInfos); CodeGeneratorHelper.SetUpdateJs(className); } #endregion }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper) { AppendNodeComment(fileManager); this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); ulong tempMemoryAddress = codeGeneratorHelper.GetAndPushVariableAddress(); fileManager.Output.Append(Macro.StoreAccu(tempMemoryAddress)); this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper); fileManager.Output.Append(Macro.DyadicOperator(this._opCodeSymbol, tempMemoryAddress)); codeGeneratorHelper.PopVariableAddress(); }
/// <summary> /// Creates a new instance of <see cref="TypeConstrainedName"/> with the <paramref name="name"/>, /// <paramref name="typeReferences"/> and <paramref name="requiresConstructor"/> provided. /// </summary> /// <param name="name">The name of the <see cref="TypeConstrainedName"/>.</param> /// <param name="typeReferences">The series of <see cref="IType"/>s that are strung /// together into <see cref="ITypeReference"/>s which denote the constraints /// set forth on the <see cref="TypeConstrainedName"/>.</param> /// <param name="requiresConstructor">Whether the <see cref="TypeConstrainedName"/> /// requires an empty-parameter constructor.</param> public TypeConstrainedName(string name, bool requiresConstructor, TypeParameterSpecialCondition specialCondition, params IType[] typeReferences) : this(name, requiresConstructor, specialCondition, CodeGeneratorHelper.GetTypeReferences(typeReferences)) { }
protected override CodePropertyReferenceExpression GetLayoutInflaterReference() { return(CodeGeneratorHelper.GetPropertyReference("LayoutInflater")); }
new public async Task <Guid> CreateAsync(WarehousingForCreationDto creationDto) { var newWarehousing = new WarehousingEntity(); foreach (PropertyInfo propertyInfo in creationDto.GetType().GetProperties()) { if (newWarehousing.GetType().GetProperty(propertyInfo.Name) != null && propertyInfo.Name != "ProductList" && propertyInfo.Name != "SupplierBillList") { newWarehousing.GetType().GetProperty(propertyInfo.Name).SetValue(newWarehousing, propertyInfo.GetValue(creationDto, null)); } } newWarehousing.IsActive = true; newWarehousing.SupplierBillList = JsonConvert.SerializeObject(creationDto.SupplierBillList); newWarehousing.CreatedDateTime = DateTime.Now; var user = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User); newWarehousing.CreatedUserId = user.Id; newWarehousing.ProductList = JsonConvert.SerializeObject(creationDto.ProductList); newWarehousing.SupplierBillList = JsonConvert.SerializeObject(creationDto.SupplierBillList); double productMoney = 0; foreach (var product in creationDto.ProductList) { // calculate product money productMoney += product.InputAmount * product.InputPrice; } newWarehousing.ProductMoney = productMoney; newWarehousing.SummaryMoney = newWarehousing.ProductMoney + newWarehousing.TaxMoney; newWarehousing.DebtMoney = newWarehousing.SummaryMoney - creationDto.PaymentMoney; // generate the code bool isDuplicated = false; do { string lastestCode = _entity.Max(w => w.Code); newWarehousing.Code = CodeGeneratorHelper.GetGeneratedCode(CONSTANT.WAREHOUSING_PREFIX, lastestCode, CONSTANT.GENERATED_NUMBER_LENGTH); isDuplicated = await IsDuplicatedCode(newWarehousing.Code); } while (isDuplicated); await _entity.AddAsync(newWarehousing); // update inventory of ProductStorages foreach (var product in creationDto.ProductList) { var productStorage = await _context.ProductStorages.SingleOrDefaultAsync(p => p.ProductId == product.Id && p.StorageId == newWarehousing.StorageId); _addCapitalTracking(product, newWarehousing.StorageId, newWarehousing.Id, productStorage); _updateInventoryDetail(product, null, productStorage); } var created = await _context.SaveChangesAsync(); if (created < 1) { throw new InvalidOperationException("Database context could not create Warehousing."); } return(newWarehousing.Id); }
private void CreateBindingOverrideMethod(List <ExpressionContainer> bindingExpressions, CodePropertyReferenceExpression localizationServiceReference, Dictionary <string, CodePropertyReferenceExpression> resourceReferences, params CodeMethodReferenceExpression[] preCallMethods) { CodeTypeReference listOfBindingObjectTypeReference = CodeGeneratorHelper.GetTypeReferenceFromName("List<BindingObject>"); CodeTypeReference bindingObjectTypeReference = CodeGeneratorHelper.GetTypeReferenceFromName("BindingObject"); CodeTypeReference bindingExpressionTypeReference = CodeGeneratorHelper.GetTypeReferenceFromName("BindingExpression"); CodeMemberMethod method = new CodeMemberMethod { Attributes = MemberAttributes.Family | MemberAttributes.Override, Name = NameGeneratorHelper.GET_BINDING_METHOD_NAME, ReturnType = listOfBindingObjectTypeReference }; foreach (CodeMethodReferenceExpression preCallMethod in preCallMethods) { method.Statements.Add(new CodeMethodInvokeExpression(preCallMethod)); } var variableCreationResult = CodeGeneratorHelper.CreateVariable(listOfBindingObjectTypeReference, "result"); method.Statements.Add(variableCreationResult.Item1); CodeVariableReferenceExpression resultReference = variableCreationResult.Item2; // group binding expression by target object to simplify foreach (IGrouping <string, ExpressionContainer> groupedExpressions in bindingExpressions.GroupBy(x => x.TargetObject)) { // create a variable for this binding object and build it with the Property of the view element variableCreationResult = CodeGeneratorHelper.CreateVariable(bindingObjectTypeReference, NameGeneratorHelper.GetBindingObjectName(), CodeGeneratorHelper.GetPropertyReference(groupedExpressions.Key)); //viewElementReferences[groupedExpressions.Key]); method.Statements.Add(variableCreationResult.Item1); CodeVariableReferenceExpression objectReference = variableCreationResult.Item2; method.Statements.Add(new CodeMethodInvokeExpression(resultReference, "Add", objectReference)); foreach (ExpressionContainer expressionContainer in groupedExpressions) { Expression expression = expressionContainer.Expression; // create a binding expression for this variableCreationResult = CodeGeneratorHelper.CreateVariable(bindingExpressionTypeReference, NameGeneratorHelper.GetBindingExpressionName(), new CodePrimitiveExpression(expressionContainer.TargetField), new CodePrimitiveExpression(expression.GetValue(BindingExpression.PATH))); method.Statements.Add(variableCreationResult.Item1); CodeVariableReferenceExpression expressionReference = variableCreationResult.Item2; if (expression.Has(BindingExpression.MODE) && expression.Get <ModeExpression>(BindingExpression.MODE).Value != BindingMode.OneWay) { // Expression could only be of type ModeExpression BindingMode mode = expression.Get <ModeExpression>(BindingExpression.MODE).Value; method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "Mode"), new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("BindingMode"), mode.ToString()))); } if (expression.Has(BindingExpression.UPDATE_EVENT) && !string.IsNullOrWhiteSpace(expression.GetValue(BindingExpression.UPDATE_EVENT))) { // Expression could only be of type Text string updateEvent = expression.GetValue(BindingExpression.UPDATE_EVENT); method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "UpdateEvent"), new CodePrimitiveExpression(updateEvent))); } if (expression.Has(BindingExpression.CONVERTER)) { // Expression could be type Resource or (Binding : not implemented for now) Expression converterExpression = expression[BindingExpression.CONVERTER]; if (converterExpression.IsOfType(ExpressionType.Binding)) { Log.LogError("Binding expression for converter is not implemented yet"); throw new NotImplementedException("Binding expression for converter is not implemented yet"); } else if (converterExpression.IsOfType(ExpressionType.Resource)) { string resourceKey = converterExpression.GetValue(ResourceExpression.KEY); CodePropertyReferenceExpression resourceReference = resourceReferences[resourceKey]; method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "Converter"), resourceReference)); } } if (expression.Has(BindingExpression.CONVERTER_PARAMETER)) { // Expression could be of type Resource, Translation, Text or (Binding : not implemented for now) Expression converterParameterExpression = expression[BindingExpression.CONVERTER_PARAMETER]; if (converterParameterExpression.IsOfType(ExpressionType.Binding)) { Log.LogError("Binding expression for converter parameter is not implemented yet"); throw new NotImplementedException("Binding expression for converter parameter is not implemented yet"); } else if (converterParameterExpression.IsOfType(ExpressionType.Resource)) { string resourceKey = converterParameterExpression.GetValue(ResourceExpression.KEY); CodePropertyReferenceExpression resourceReference = resourceReferences[resourceKey]; method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "ConverterParameter"), resourceReference)); } else if (converterParameterExpression.IsOfType(ExpressionType.Translation)) { CodeMethodInvokeExpression valueReference = GenerateStatementToGetTranslation(localizationServiceReference, converterParameterExpression); method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "ConverterParameter"), valueReference)); } else if (converterParameterExpression.IsOfType(ExpressionType.Value)) { TextExpression textExpression = converterParameterExpression as TextExpression; if (textExpression != null) { string converterParameterValue = textExpression.Value; method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "ConverterParameter"), new CodePrimitiveExpression(converterParameterValue))); } else { throw new InvalidOperationException("Can't get a textExpression from a ExpressionType.Value expression..."); } } } if (!string.IsNullOrWhiteSpace(expressionContainer.CommandParameterTarget)) { method.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(expressionReference, "CommandParameter"), CodeGeneratorHelper.GetPropertyReference(expressionContainer.CommandParameterTarget))); } method.Statements.Add(new CodeMethodInvokeExpression(objectReference, "AddExpression", expressionReference)); } } method.Statements.Add(new CodeMethodReturnStatement(resultReference)); Methods.Add(method); }
public IMethodSignatureMember FindBySig(string name, params IType[] parameterTypes) { return(FindBySig(name, CodeGeneratorHelper.GetTypeReferences(parameterTypes))); }
public void Generate(string outputFile) { CodeCompileUnit codeUnit = new CodeCompileUnit(); // for all using statements CodeNamespace globalNamespace = new CodeNamespace(""); // for class declaration CodeNamespace codeNamespace = new CodeNamespace(NamespaceName); codeUnit.Namespaces.AddRange(new [] { globalNamespace, codeNamespace }); // add all using statements globalNamespace.Imports.AddRange(Configuration.Namespaces.Select(x => new CodeNamespaceImport(x)).ToArray()); // create class CodeTypeDeclaration classDeclaration = new CodeTypeDeclaration(ClassName) { IsClass = true, IsPartial = IsPartialClass, TypeAttributes = TypeAttributes.Public, }; if (BaseClassType != null) { classDeclaration.BaseTypes.Add(CodeGeneratorHelper.GetTypeReferenceFromName(BaseClassType)); } codeNamespace.Types.Add(classDeclaration); classDeclaration.Members.AddRange(Events.Select(x => (CodeTypeMember)x).ToArray()); classDeclaration.Members.AddRange(Fields.Select(x => (CodeTypeMember)x).ToArray()); classDeclaration.Members.AddRange(Properties.Select(x => (CodeTypeMember)x).ToArray()); classDeclaration.Members.AddRange(Methods.Select(x => (CodeTypeMember)x).ToArray()); #region File writing CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"); CodeGeneratorOptions options = new CodeGeneratorOptions { BlankLinesBetweenMembers = true, BracingStyle = "C", IndentString = "\t" }; string contentString; using (StringWriter stringWriter = new StringWriter()) { provider.GenerateCodeFromCompileUnit(codeUnit, stringWriter, options); string content = stringWriter.GetStringBuilder().ToString(); Regex commentRegex = new Regex("<auto-generated>.*</auto-generated>", RegexOptions.IgnoreCase | RegexOptions.Singleline); contentString = commentRegex.Replace(content, "This file was generated by binding preprocessing system for Android"); } if (File.Exists(outputFile)) { using (StreamReader reader = new StreamReader(outputFile)) { string actualContent = reader.ReadToEnd(); if (actualContent == contentString) { return; } } File.Delete(outputFile); } using (StreamWriter writer = new StreamWriter(File.OpenWrite(outputFile))) { writer.Write(contentString); } #endregion }
public void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper cdh) { Logger.Debug("Code generation..."); this._rootNode.GenerateCode(fileManager, symbolTable, cdh); }
public static void TestCodeGenerate() { CodeGeneratorHelper.ScanFiles(); }
public static TypeReferenceExpression GetTypeReferenceExpression <TType>() { return(GetTypeReferenceExpression(CodeGeneratorHelper.GetTypeReference <TType>().TypeInstance)); }
new public async Task <Guid> CreateAsync(BillForCreationDto creationDto) { var customer = await _customerEntity.FirstOrDefaultAsync(x => x.Id == creationDto.CustomerId); if (customer == null) { throw new Exception("Can not find any customer with this id"); } if (creationDto.UsedPoints > customer.AccumulationPoint) { throw new Exception("UsedPoints must be less or equal AccumulationPoint"); } var newBill = new BillEntity(); foreach (PropertyInfo propertyInfo in creationDto.GetType().GetProperties()) { if (newBill.GetType().GetProperty(propertyInfo.Name) != null && propertyInfo.Name != "ProductList") { newBill.GetType().GetProperty(propertyInfo.Name).SetValue(newBill, propertyInfo.GetValue(creationDto, null)); } } var settings = _context.Settings.ToList(); var defaultSetting = settings[0]; // we have a lot of data to save! newBill.PointMoney = defaultSetting.PointToMoney * creationDto.UsedPoints; newBill.PointEarning = Math.Round(creationDto.TotalMoney / defaultSetting.MoneyToPoint, 1); newBill.CreatedDateTime = DateTimeHelper.GetVietnamNow(); newBill.IsActive = true; newBill.ProductList = JsonConvert.SerializeObject(creationDto.ProductList); var user = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User); newBill.UserId = user.Id; // generate the code bool isDuplicated = false; do { string lastestCode = _entity.Max(w => w.Code); newBill.Code = CodeGeneratorHelper.GetGeneratedCode(CONSTANT.BILL_PREFIX, lastestCode, CONSTANT.GENERATED_NUMBER_LENGTH); isDuplicated = await _isDuplicatedCode(newBill.Code); } while (isDuplicated); await _entity.AddAsync(newBill); // update accumulation points customer.AccumulationPoint += newBill.PointEarning - creationDto.UsedPoints; customer.AccumulationPoint = Math.Round(customer.AccumulationPoint, 1); if (creationDto.IsUpdatedCustomerShipping) { customer.ShipAddress = newBill.ShipAddress; customer.ShipContactName = newBill.ShipContactName; customer.ShipPhone = newBill.ShipPhone; customer.CompanyName = newBill.CompanyName; customer.CompanyAddress = newBill.CompanyAddress; customer.CompanyTaxCode = newBill.CompanyTaxCode; } _customerEntity.Update(customer); // update inventory for eact saled product foreach (ProductForBillCreationDto product in creationDto.ProductList) { if (product.IsService) // if product is service, we need not update anymore { continue; } var productStorage = _context.ProductStorages.FirstOrDefault(p => p.ProductId == product.Id && p.StorageId == creationDto.StorageId); // if has a ProductStorage, we update inventory number. if (productStorage != null) { if (product.Amount > productStorage.Inventory && !defaultSetting.IsAllowNegativeInventoryBill) { throw new Exception("amount_overcomes_inventory"); } productStorage.Inventory -= product.Amount; // update detail output amount _addOrUpdateProductProductionDate(productStorage, product, true); CapitalPriceTrackingDto capitalPriceTracking = new CapitalPriceTrackingDto { BillId = newBill.Id, Amount = product.Amount, CapitalPrice = productStorage.CapitalPrice, Inventory = productStorage.Inventory }; productStorage.CapitalPriceTrackings = productStorage.CapitalPriceTrackings ?? "[]"; var capitalPriceTrackings = JsonConvert.DeserializeObject <List <CapitalPriceTrackingDto> >(productStorage.CapitalPriceTrackings); capitalPriceTrackings.Add(capitalPriceTracking); productStorage.CapitalPriceTrackings = JsonConvert.SerializeObject(capitalPriceTrackings); _context.ProductStorages.Update(productStorage); } else { throw new Exception("ProductStorage is not exist"); } } var created = await _context.SaveChangesAsync(); if (created < 1) { throw new InvalidOperationException("Database context could not create data."); } return(newBill.Id); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper labelHelper) { AppendNodeComment(fileManager); fileManager.Output.Append(Macro.LoadAccuImmed(this._memoryAddress)); }
public static IHost SeedDatabase(this IHost host) { var productCodes = new List <string>(); var random = new Random(); using (var scope = host.Services.CreateScope()) { using (var context = scope.ServiceProvider.GetRequiredService <ProductContext>()) { codeGenerator = scope.ServiceProvider.GetRequiredService <CodeGeneratorHelper>(); try { if (!context.Products.Any()) { for (int productNo = 0; productNo < 10; productNo++) { var comments = new List <Comment>(); for (int commentNo = 0; commentNo < 10; commentNo++) { var comment = new Comment { PosterName = $"Poster {productNo}{commentNo}", Rating = (byte)random.Next(1, 5), }; comment.Description = $"Produktas {productNo} yra labai {comment.Rating} nes aš juo pasinaudojau ir jis man labai {comment.Rating}"; comments.Add(comment); } string code; do { code = codeGenerator.Generate(6); } while (productCodes.Contains(code)); productCodes.Add(code); context.Products.Add(new Models.Product { Name = $"Produktas nr {productNo}", Description = $"Produktas skirtas {productNo}", Code = code, Comments = comments }); } context.SaveChanges(); } } catch (Exception ex) { //Log errors or do anything you think it's needed throw; } } } return(host); }
IMethodSignatureMember <IMethodSignatureParameterMember, IMethodSignatureTypeParameterMember, CodeMemberMethod, ISignatureMemberParentType> IMethodSignatureMembers <IMethodSignatureParameterMember, IMethodSignatureTypeParameterMember, CodeMemberMethod, ISignatureMemberParentType> .FindBySig(string name, int typeParamCount, params IType[] parameterTypes) { return(this.FindBySig(name, typeParamCount, CodeGeneratorHelper.GetTypeReferences(parameterTypes))); }
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGenerationHelper) { AppendNodeComment(fileManager); this._children[0].GenerateCode(fileManager, symbolTable, codeGenerationHelper); }
public void Preprocess(List <XmlAttribute> expressionAttributes, List <Resource> resources, List <IdViewObject> viewElements) { // Create all properties for viewElements foreach (IdViewObject viewElement in viewElements) { Tuple <CodeMemberField, CodeMemberProperty> result = CodeGeneratorHelper.GenerateProxyProperty(viewElement.Id, viewElement.TypeName, new CodeMethodInvokeExpression(GetFindViewByIdReference(viewElement.TypeName), CodeGeneratorHelper.GetAndroidResourceReference(ResourcePart.Id, viewElement.Id))); Fields.Add(result.Item1); Properties.Add(result.Item2); } // Generate property for ILocalizationService LocalizationService CodePropertyReferenceExpression localizationServiceReference = CreateLocalizationServiceProperty(); // Eval all expressions List <ExpressionContainer> expressions = (from attribute in expressionAttributes let expressionResult = EvaluateExpression(attribute.Value) where expressionResult != null select new ExpressionContainer { Expression = expressionResult, TargetObject = attribute.AttachedId, TargetField = attribute.LocalName, IsTargetingResource = false, }).ToList(); // Affect a property name to all resources and check if some has expression as attribute value foreach (Resource res in resources) { res.PropertyName = NameGeneratorHelper.GetResourceName(); foreach (KeyValuePair <string, string> propertyItem in res.Properties.Where(propertyItem => ParsingHelper.IsExpressionValue(propertyItem.Value)).ToList()) { res.Properties.Remove(propertyItem.Key); Expression expr = EvaluateExpression(propertyItem.Value); if (expr != null) { if (CheckCorrectExpressionInResource(expr)) { Log.LogError("Expression {0} is invalid in a resource context (you cannot use binding)", propertyItem.Value); } else { expressions.Add(new ExpressionContainer { Expression = expr, TargetObject = res.PropertyName, TargetField = propertyItem.Key, IsTargetingResource = true, }); } } } } // Check if all resources are declared and filter those we need Dictionary <string, Resource> neededResource = new Dictionary <string, Resource>(); List <string> resourceKeys = expressions.SelectMany(x => GetUsedResources(x.Expression)).Distinct().ToList(); foreach (string key in resourceKeys) { Resource res = resources.FirstOrDefault(x => key.Equals(x.Key, StringComparison.InvariantCultureIgnoreCase)); if (res == null) { Log.LogError("Resource with key {0} does not exists", key); } else { neededResource.Add(key, res); } } // Go through all binding expression and find those where we need to declare implicit resources // Will also remove all Template & TemplateSelector fields in BindingExpression // to only have a fully prepared adapter foreach (Expression bindingExpression in expressions.SelectMany(expression => GetBindingExpressions(expression.Expression)).ToList()) { if (bindingExpression.Has(BindingExpression.TEMPLATE)) { // create a template selector string templateSelectorKey = NameGeneratorHelper.GetResourceKey(); string templateSelectorPropertyName = NameGeneratorHelper.GetResourceName(); neededResource.Add(templateSelectorKey, new Resource(templateSelectorKey) { PropertyName = templateSelectorPropertyName, ResourceElement = null, Type = Configuration.DefaultTemplateSelector }); expressions.Add(new ExpressionContainer { Expression = bindingExpression[BindingExpression.TEMPLATE], TargetField = Configuration.DefaultTemplateSelectorField, TargetObject = templateSelectorPropertyName, IsTargetingResource = true, }); bindingExpression.Remove(BindingExpression.TEMPLATE); ResourceExpression templateSelectorResourceExpression = new ResourceExpression(); templateSelectorResourceExpression.Add(ResourceExpression.KEY, new TextExpression { Value = templateSelectorKey }); bindingExpression.Add(BindingExpression.TEMPLATE_SELECTOR, templateSelectorResourceExpression); } if (bindingExpression.Has(BindingExpression.TEMPLATE_SELECTOR)) { // create an adapter string adapterKey = NameGeneratorHelper.GetResourceKey(); string adapterName = NameGeneratorHelper.GetResourceName(); neededResource.Add(adapterKey, new Resource(adapterKey) { PropertyName = adapterName, ResourceElement = null, Type = Configuration.DefaultAdapter }); expressions.Add(new ExpressionContainer { Expression = bindingExpression[BindingExpression.TEMPLATE_SELECTOR], TargetField = Configuration.DefaultAdapterField, TargetObject = adapterName, IsTargetingResource = true, }); bindingExpression.Remove(BindingExpression.TEMPLATE_SELECTOR); ResourceExpression adapterResourceExpression = new ResourceExpression(); adapterResourceExpression.Add(ResourceExpression.KEY, new TextExpression { Value = adapterKey }); bindingExpression.Add(BindingExpression.ADAPTER, adapterResourceExpression); } } // In order to check if all adapter are not used more than once since we need them to be unique target Dictionary <string, bool> usedAdapter = new Dictionary <string, bool>(); foreach (ExpressionContainer expression in expressions.Where(x => x.Expression.IsOfType(ExpressionType.Binding)).ToList()) { Expression bindingExpression = expression.Expression; if (bindingExpression.Has(BindingExpression.ADAPTER)) { // expression in Adapter could only be Resource (since it's an android platform specific things, a binding expression would not have any sense) Expression resourceExpression = bindingExpression[BindingExpression.ADAPTER]; string adapterKey = resourceExpression.GetValue(ResourceExpression.KEY); Resource adapterResource = neededResource[adapterKey]; if (usedAdapter.ContainsKey(adapterKey)) { Log.LogError("The adapter with key {0} is used more than once which could lead to issue, you need one adapter per use !", adapterKey); } else { usedAdapter.Add(adapterKey, true); } // remove the adapter property bindingExpression.Remove(BindingExpression.ADAPTER); // store old target info string oldTargetField = expression.TargetField; string oldTargetObject = expression.TargetObject; bool oldTargetType = expression.IsTargetingResource; // retarget the binding expression to be targeted to Adapter.Collection expression.TargetField = "Collection"; expression.TargetObject = adapterResource.PropertyName; expression.IsTargetingResource = false; //TODO : false for debug mode only, need to see what we can do about that ? // add a new expression to target the old object/field couple and affect the adapter with the resource expression expressions.Add(new ExpressionContainer { IsTargetingResource = oldTargetType, TargetField = oldTargetField, TargetObject = oldTargetObject, Expression = resourceExpression, }); } } // Create all properties for resources Dictionary <string, CodePropertyReferenceExpression> resourceReferences = CreatePropertiesForResources(neededResource.Values); // Generate all properties to handle CommandParameter and retarget all expressions if needed GenerateCommandParameterProperties(expressions); // Create a setup resources method to initalize resources with all {Resource ...} and {Translation ...} expressions List <ExpressionContainer> translationExpressions = expressions.Where(x => x.Expression.IsOfType(ExpressionType.Translation)).ToList(); List <ExpressionContainer> expressionsTargetingResources = expressions.Where(x => x.IsTargetingResource && x.Expression.IsOfType(ExpressionType.Resource)).ToList(); List <ExpressionContainer> resourceExpressions = expressions.Where(x => !x.IsTargetingResource && x.Expression.IsOfType(ExpressionType.Resource)).ToList(); List <ExpressionContainer> bindingExpressions = expressions.Where(x => !x.IsTargetingResource && x.Expression.IsOfType(ExpressionType.Binding)).ToList(); CodeMethodReferenceExpression assignTranslationMethodReference = CreateAssignTranslationMethod(translationExpressions, localizationServiceReference); CodeMethodReferenceExpression setupResourcesReference = CreateSetupResourcesMethod(expressionsTargetingResources, resourceReferences); CodeMethodReferenceExpression setupResourceForViewElement = CreateSetupResourceForViewElementMethod(resourceExpressions, resourceReferences); CreateBindingOverrideMethod(bindingExpressions, localizationServiceReference, resourceReferences, assignTranslationMethodReference, setupResourcesReference, setupResourceForViewElement); }
public void Setup() { generator = new CodeGeneratorHelper(); }
public IMethodSignatureMember FindBySig(string name, int typeParamCount, params IType[] parameterTypes) { return(this.FindBySig(name, typeParamCount, CodeGeneratorHelper.GetTypeReferences(parameterTypes))); }