public void Merge(Step step) { if (!step._filteringAttributes.Any()) { _doNotFilterAttributes = true; } _filteringAttributes.AddRange(step._filteringAttributes); if (step._preImageAllAttributes) { _preImageAllAttributes = true; _preImageAttributes.Clear(); } else { _preImageAttributes.AddRange(step._preImageAttributes); } if (step._postImageAllAttributes) { _postImageAllAttributes = true; _postImageAttributes.Clear(); } else { _postImageAttributes.AddRange(step._postImageAttributes); } MethodNames.AddRange(step.MethodNames); }
protected MethodCollection(string[] methodNames, Type projectionType, Type aggregateType) { _validArgumentTypes.Add(typeof(CancellationToken)); MethodNames.AddRange(methodNames); ProjectionType = projectionType; AggregateType = aggregateType; projectionType.GetMethods(flags()) .Where(x => MethodNames.Contains(x.Name)) .Where(x => !x.HasAttribute <MartenIgnoreAttribute>()) .Each(method => addMethodSlot(method, false)); if (aggregateType != null) { aggregateType.GetMethods(flags()) .Where(x => MethodNames.Contains(x.Name)) .Where(x => !x.HasAttribute <MartenIgnoreAttribute>()) .Each(method => addMethodSlot(method, true)); } IsAsync = Methods.Select(x => x.Method).OfType <MethodInfo>().Any(x => x.IsAsync()); LambdaName = methodNames.First(); }
public void Create_Builder_Result_Can_Call_Begin_Only() { Check.That(this.HasAllMethodsInReturnedType(MethodNames.CreateBuilder, MethodNames.Begin)) .IsTrue(); Check.That(this.HasAnyMethodsInReturnedType(MethodNames.CreateBuilder, MethodNames.AllBut(MethodNames.Begin))) .IsFalse(); }
/// <summary>Default constructor with operator name.</summary> /// <param name="operatorName">Operator name.</param> public Operator(MethodNames operatorName) : base(operatorName) { if ((operatorName & Call.Operator) != Call.Operator) { throw new ArgumentOutOfRangeException(System.String.Format("Invalid operator '{0}'.", operatorName)); } }
/// <summary>Default constructor with operator name.</summary> /// <param name="operatorName">Operator name.</param> public Operator(MethodNames operatorName) : base(operatorName) { if ((operatorName & Call.Operator) != Call.Operator) { throw new ArgumentOutOfRangeException(System.String.Format("Invalid operator '{0}'.", operatorName)); } }
/// <summary>Default constructor with method name passed.</summary> /// <param name="methodName">Method name.</param> public Call(MethodNames methodName) : base() { ObservableCollection <IExpression> arguments = new ObservableCollection <IExpression>(); arguments.CollectionChanged += OnCollectionChanged; _arguments = arguments; _member = methodName; }
public void Begin_Builder_Result_Can_Call_Build_And_WithParameters_Only() { // Arrange var builder = CreateBuilder(); // Assert Check.That(builder.HasAllMethodsInReturnedType(MethodNames.Begin, MethodNames.Build, MethodNames.WithParameters)) .IsTrue(); Check.That(builder.HasAnyMethodsInReturnedType(MethodNames.Begin, MethodNames.AllBut(MethodNames.Build, MethodNames.WithParameters))) .IsFalse(); }
protected override CodeTypeDeclaration BeginClass() { MethodNames.Clear(); ExtraCodeClasses.Clear(); CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); if (Style == ServiceDescriptionImportStyle.Client) { WebCodeGenerator.AddCustomAttribute(metadata, typeof(DebuggerStepThroughAttribute), new CodeExpression[0]); WebCodeGenerator.AddCustomAttribute(metadata, typeof(DesignerCategoryAttribute), new CodeExpression[] { new CodePrimitiveExpression("code") }); } Type[] requiredTypes = new Type[] { typeof(SoapDocumentMethodAttribute), typeof(XmlAttributeAttribute), typeof(WebService), typeof(Object), typeof(DebuggerStepThroughAttribute), typeof(DesignerCategoryAttribute), typeof(TransactionOption), }; WebCodeGenerator.AddImports(this.CodeNamespace, WebCodeGenerator.GetNamespacesForTypes(requiredTypes)); CodeFlags flags = 0; if (Style == ServiceDescriptionImportStyle.Server) { flags = CodeFlags.IsAbstract; } else if (Style == ServiceDescriptionImportStyle.ServerInterface) { flags = CodeFlags.IsInterface; } CodeTypeDeclaration codeClass = WebCodeGenerator.CreateClass(this.ClassName, BaseClass.FullName, new string[0], metadata, CodeFlags.IsPublic | flags, ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes)); codeClass.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); CodeConstructor ctor = WebCodeGenerator.AddConstructor(codeClass, new string[0], new string[0], null, CodeFlags.IsPublic); ctor.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); HttpAddressBinding httpAddressBinding = Port == null ? null : (HttpAddressBinding)Port.Extensions.Find(typeof(HttpAddressBinding)); string url = (httpAddressBinding != null) ? httpAddressBinding.Location : null; ServiceDescription serviceDescription = Binding.ServiceDescription; ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, serviceDescription.AppSettingUrlKey, serviceDescription.AppSettingBaseUrl, false); codeClasses.Add(codeClass); return(codeClass); }
private static Exceptionless.Models.Data.StackFrame GenerateStackFrame() { return(new Exceptionless.Models.Data.StackFrame { DeclaringNamespace = Namespaces.Random(), DeclaringType = TypeNames.Random(), Name = MethodNames.Random(), Parameters = new ParameterCollection { new Parameter { Type = "String", Name = "path" } } }); }
public StackFrame GenerateStackFrame() { return(new StackFrame { DeclaringNamespace = Namespaces.Random(), DeclaringType = TypeNames.Random(), Name = MethodNames.Random(), Parameters = new ParameterCollection { new Parameter { Type = "String", Name = "path" } } }); }
public void WithOrder_Builder_Result_Can_Call_Build_And_WithPagination_Only() { // Arrange var builder = CreateBuilder(); // Act var tmpBuilder = builder.Begin() .WithParameters(null); // Assert Check.That(tmpBuilder.HasAllMethodsInReturnedType(MethodNames.WithOrder, MethodNames.Build, MethodNames.WithPagination)) .IsTrue(); Check.That(tmpBuilder.HasAnyMethodsInReturnedType(MethodNames.WithOrder, MethodNames.AllBut(MethodNames.Build, MethodNames.WithPagination))) .IsFalse(); }
static void reflect(ref Dictionary <string, MethodInfo> result, Type ifaceReflect, Type ifaceBuild) { PropertyInfo[] properties = ifaceReflect.GetProperties(); foreach (var pi in properties) { MethodNames names = new MethodNames(pi); MethodInfo getter = pi.GetGetMethod(), setter = pi.GetSetMethod(); if (null != getter) { addMethod(ref result, names.getterMethod, getter, ifaceBuild); } if (null != setter) { addMethod(ref result, names.setterMethod, setter, ifaceBuild); } } }
/// <summary> /// MethodClass -> ClassName.IdT(Params) /// </summary> private void MethodCall(Class classEntry) { ClassName(); Match(Tokens.PeriodT); if ((classEntry != null && classEntry.methodNames.Contains(Lexeme)) || MethodNames.Contains(Lexeme)) { string methodName = Lexeme; Match(Tokens.IdT); Match(Tokens.LParenT); Params(); Match(Tokens.RParenT); tacGenerator.GenerateLineOfTAC($"call {methodName}"); } else { ErrorHandler.LogError($"The class \"{classEntry.lexeme}\" does not contain the method \"{Lexeme}\""); } }
/// <summary> /// MethodDecl -> PublicT Type IdT ( FormalList ) { /// VarDecl SeqOfStatements ReturnT Expr ; /// } | /// ε /// </summary> private void MethodDecl() { ITableEntry Eplace = null; if (Token == Tokens.PublicT) { Match(Tokens.PublicT); Type(); TypeReturn = TypeVar; TableEntry entry = symbolTable.CreateTableEntry(); MethodNames.Add(Lexeme); tacGenerator.GenerateLineOfTAC($"proc {entry.lexeme}"); Match(Tokens.IdT); Depth++; ResetMethodGlobals(); Match(Tokens.LParenT); ParameterVarsSize = 4; FormalList(); Offset = 2; tacGenerator.tempVarOffset = 2; Match(Tokens.RParenT); Match(Tokens.LBraceT); VarDecl(); SeqOfStatements(); Match(Tokens.ReturnT); Expr(ref Eplace); if (Eplace != null && Eplace.bpOffsetName != "") { tacGenerator.GenerateLineOfTAC($"_ax = {Eplace.bpOffsetName}"); } Match(Tokens.SemiT); symbolTable.ConvertEntryToMethod(entry); symbolTable.DeleteDepth(Depth); tacGenerator.GenerateLineOfTAC($"endp {entry.lexeme}"); tacGenerator.GenerateLineOfTAC(""); Depth--; Match(Tokens.RBraceT); MethodDecl(); } }
/// <summary> /// MainClass -> FinalT ClassT IdT { /// PublicT StaticT VoidT MainT ( StringT [ ] IdT ) { /// SeqOfStatements /// } /// } /// </summary> private void MainClass() { Match(Tokens.FinalT); Match(Tokens.ClassT); TableEntry finalClassEntry = symbolTable.CreateTableEntry(); Match(Tokens.IdT); Depth++; ResetClassGlobals(); Match(Tokens.LBraceT); Match(Tokens.PublicT); Match(Tokens.StaticT); Match(Tokens.VoidT); TypeReturn = VarType.voidType; TableEntry mainEntry = symbolTable.CreateTableEntry(); MethodNames.Add(Lexeme); tacGenerator.GenerateLineOfTAC("proc main"); AssemblyFile.mainName = Lexeme; Match(Tokens.MainT); Depth++; ResetMethodGlobals(); Match(Tokens.LParenT); Match(Tokens.StringT); Match(Tokens.LBrackT); Match(Tokens.RBrackT); Match(Tokens.IdT); Match(Tokens.RParenT); Match(Tokens.LBraceT); SeqOfStatements(); tacGenerator.GenerateLineOfTAC("endp main"); ParameterVarsSize = 4; symbolTable.ConvertEntryToMethod(mainEntry); symbolTable.DeleteDepth(Depth); Depth--; Match(Tokens.RBraceT); symbolTable.ConvertEntryToClass(finalClassEntry); symbolTable.DeleteDepth(Depth); Depth--; Match(Tokens.RBraceT); }
// protected override CodeMemberMethod GenerateMethod() { HttpOperationBinding httpOperationBinding = (HttpOperationBinding)OperationBinding.Extensions.Find(typeof(HttpOperationBinding)); if (httpOperationBinding == null) { throw OperationBindingSyntaxException(Res.GetString(Res.MissingHttpOperationElement0)); } HttpMethodInfo method = new HttpMethodInfo(); if (hasInputPayload) { method.MimeParameters = ImportMimeParameters(); if (method.MimeParameters == null) { UnsupportedOperationWarning(Res.GetString(Res.NoInputMIMEFormatsWereRecognized0)); return(null); } } else { method.UrlParameters = ImportUrlParameters(); if (method.UrlParameters == null) { UnsupportedOperationWarning(Res.GetString(Res.NoInputHTTPFormatsWereRecognized0)); return(null); } } method.MimeReturn = ImportMimeReturn(); if (method.MimeReturn == null) { UnsupportedOperationWarning(Res.GetString(Res.NoOutputMIMEFormatsWereRecognized0)); return(null); } method.Name = MethodNames.AddUnique(MethodName, method); method.Href = httpOperationBinding.Location; return(GenerateMethod(method)); }
public void SetMethod(string _methodName) { switch (_methodName) { case "StartPage_StartButton": method = MethodNames.StartPage_StartButton; break; case "NumberOfEnzymes_SetButton": method = MethodNames.NumberOfEnzymes_SetButton; break; case "EnzymeNaming_NextButton": method = MethodNames.EnzymeNaming_NextButton; break; case "SingleDigest_SetButton": method = MethodNames.SingleDigest_SetButton; break; case "SingleDigest_NextButton": method = MethodNames.SingleDigest_NextButton; break; case "NumberOfMultiDigests_NextButton": method = MethodNames.NumberOfMultiDigests_NextButton; break; case "MultiDigest_SetButton": method = MethodNames.MultiDigest_SetButton; break; case "MultiDigest_NextButton": method = MethodNames.MultiDigest_NextButton; break; } messageString = _methodName; }
protected MethodCollection(string[] methodNames, Type projectionType, Type aggregateType) { _validArgumentTypes.Add(typeof(CancellationToken)); MethodNames.AddRange(methodNames); ProjectionType = projectionType; Methods = projectionType.GetMethods(flags()) .Where(x => MethodNames.Contains(x.Name)) .Where(x => !x.HasAttribute <MartenIgnoreAttribute>()) .Select(x => new MethodSlot(x, aggregateType) { HandlerType = projectionType }).ToList(); AggregateType = aggregateType; if (aggregateType != null) { var aggregateSlots = aggregateType.GetMethods(flags()) .Where(x => MethodNames.Contains(x.Name)) .Where(x => !x.HasAttribute <MartenIgnoreAttribute>()) .Select(x => new MethodSlot(x, aggregateType) { HandlerType = aggregateType, DeclaredByAggregate = true }); Methods.AddRange(aggregateSlots); } IsAsync = Methods.Select(x => x.Method).OfType <MethodInfo>().Any(x => x.IsAsync()); LambdaName = methodNames.First(); }
/// <summary> /// Get all methods in a class based on Key /// </summary> /// <param name="T">Key : Type of class</param> public virtual void GetMethodNames(IExpireHelper type) { Type T = type.GetType(); Dictionary <int, string> methodDict = new Dictionary <int, string>(); MethodInfo[] methods = T.GetMethods(); if (!MethodNames.ContainsKey(T) || type.Expire) { for (ushort i = 0; i < methods.Length; i++) { methodDict.Add(i, methods[i].Name); } } if (!MethodNames.ContainsKey(T)) { MethodNames.Add(T, methodDict); } else if (methodDict.Count > 0) { MethodNames[T] = methodDict; } }
/// <summary>Constructor with operator name and both operands passed.</summary> /// <param name="operatorName">Operator name.</param> /// <param name="leftOperand">Left operand.</param> /// <param name="rightOperand">Right operand.</param> public BinaryOperator(MethodNames operatorName, IExpression leftOperand, IExpression rightOperand) : base(operatorName, leftOperand) { RightOperand = rightOperand; }
/// <summary>Default constructor with operator name.</summary> /// <param name="operatorName">Operator name.</param> public BinaryOperator(MethodNames operatorName) : base(operatorName) { }
// These overridable methods have no parameters. The subclass uses properties on this // base object to obtain the information. This allows us to grow the set of // information passed to the methods over time w/o breaking anyone. They are protected // instead of public because this object is passed to extensions and we don't want // those calling these methods. /// <include file='doc\ProtocolImporter.uex' path='docs/doc[@for="ProtocolImporter.BeginNamespace"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected virtual void BeginNamespace() { MethodNames.Clear(); }
/// <summary> /// Fors the method. /// </summary> /// <param name="methodName">Name of the method.</param> /// <returns></returns> public InjectableMethodBuilder <T, T2, T3, T4, T5, T6, T7, T8, T9> ForMethod(string methodName) { return(new InjectableMethodBuilder <T, T2, T3, T4, T5, T6, T7, T8, T9>(Container, MethodNames.Add(methodName))); }
/// <summary> /// Fors the method. /// </summary> /// <param name="methodName">Name of the method.</param> /// <returns></returns> public InjectableMethodBuilder <T> ForMethod(string methodName) { return(new InjectableMethodBuilder <T>(Container, MethodNames.Add(methodName))); }
/// <summary>Constructor with operator name and both operands passed.</summary> /// <param name="operatorName">Operator name.</param> /// <param name="leftOperand">Left operand.</param> /// <param name="rightOperand">Right operand.</param> public BinaryOperator(MethodNames operatorName, IExpression leftOperand, IExpression rightOperand) : base(operatorName, leftOperand) { RightOperand = rightOperand; }
public Step(Plugin plugin, Messages message, Stages stage, Modes mode, string entityName, string methodName, params string[] columns) : this(plugin, message, stage, mode, entityName) { Method = plugin.GetType().GetMethod(methodName); if (Method != null) { MethodNames.Add(Method.Name); var filteringAttributes = Method.GetCustomAttribute <FilteringAttributesAttribute>(); if (filteringAttributes != null) { _filteringAttributes.AddRange(filteringAttributes.Attributes); } else if (columns != null) { _filteringAttributes.AddRange(columns); } var preImageAttribute = Method.GetCustomAttribute <PreImageAttribute>(); if (preImageAttribute != null) { _preImageAllAttributes = preImageAttribute.AllColumns; if (!_preImageAllAttributes) { _preImageAttributes.AddRange(preImageAttribute.Columns); } } else if (columns != null) { _preImageAttributes.AddRange(columns); } var postImageAttribute = Method.GetCustomAttribute <PostImageAttribute>(); if (postImageAttribute != null) { _postImageAllAttributes = postImageAttribute.AllColumns; if (!_postImageAllAttributes) { _postImageAttributes.AddRange(postImageAttribute.Columns); } } else if (columns != null) { _postImageAttributes.AddRange(columns); } var executionOrderAttribute = Method.GetCustomAttribute <ExecutionOrderAttribute>(); if (executionOrderAttribute != null) { Order = executionOrderAttribute.Order; } var impersonationUserAttribute = Method.GetCustomAttribute <ImpersonationAttribute>(); if (impersonationUserAttribute != null) { ImpersonationUsername = impersonationUserAttribute.ImpersonationUsername; } var unsecureConfigAttribute = Method.GetCustomAttribute <UnsecureConfigAttribute>(); if (unsecureConfigAttribute != null) { if (!string.IsNullOrEmpty(unsecureConfigAttribute.UnsecureConfig)) { UnsecureConfig = unsecureConfigAttribute.UnsecureConfig; } else { var resourceType = unsecureConfigAttribute.ResourceType; UnsecureConfig = resourceType.GetProperty(unsecureConfigAttribute.PropertyName).GetValue(null) as string; } } } }
/// <summary> /// Fors the method. /// </summary> /// <param name="methodName">Name of the method.</param> /// <returns></returns> public InjectableMethodBuilder ForMethod(string methodName) { return(new InjectableMethodBuilder(Container.AsType(), MethodNames.Add(methodName))); }
/// <summary> /// Expire dictionary for specific key /// </summary> /// <param name="T">Key : Type of class</param> public void ExpireForKey(Type T) { MethodNames.Remove(T); }
/// <summary>Constructor with operator name and both operands passed.</summary> /// <param name="operatorName">Operator name.</param> /// <param name="operand">Operand.</param> public UnaryOperator(MethodNames operatorName, IExpression operand) : base(operatorName) { Operand = operand; }
CodeMemberMethod GenerateMethod(HttpMethodInfo method) { MimeParameterCollection parameters = method.MimeParameters != null ? method.MimeParameters : method.UrlParameters; string[] parameterTypeNames = new string[parameters.Count]; string[] parameterNames = new string[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { MimeParameter param = parameters[i]; parameterNames[i] = param.Name; parameterTypeNames[i] = param.TypeName; } CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); CodeExpression[] formatterTypes = new CodeExpression[2]; if (method.MimeReturn.ReaderType == null) { formatterTypes[0] = new CodeTypeOfExpression(typeof(NopReturnReader).FullName); } else { formatterTypes[0] = new CodeTypeOfExpression(method.MimeReturn.ReaderType.FullName); } if (method.MimeParameters != null) { formatterTypes[1] = new CodeTypeOfExpression(method.MimeParameters.WriterType.FullName); } else { formatterTypes[1] = new CodeTypeOfExpression(typeof(UrlParameterWriter).FullName); } WebCodeGenerator.AddCustomAttribute(metadata, typeof(HttpMethodAttribute), formatterTypes, new string[0], new CodeExpression[0]); CodeMemberMethod mainCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, method.Name, new CodeFlags[parameterTypeNames.Length], parameterTypeNames, parameterNames, method.MimeReturn.TypeName, metadata, CodeFlags.IsPublic | (Style == ServiceDescriptionImportStyle.Client ? 0 : CodeFlags.IsAbstract)); AppendMetadata(method.MimeReturn.Attributes, mainCodeMethod.ReturnTypeCustomAttributes); mainCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); for (int i = 0; i < parameters.Count; i++) { AppendMetadata(parameters[i].Attributes, mainCodeMethod.Parameters[i].CustomAttributes); } if (Style == ServiceDescriptionImportStyle.Client) { bool oldAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateOldAsync) != 0; bool newAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateNewAsync) != 0 && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareEvents) && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareDelegates); CodeExpression[] invokeParams = new CodeExpression[3]; CreateInvokeParams(invokeParams, method, parameterNames); CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "Invoke", invokeParams); if (method.MimeReturn.ReaderType != null) { mainCodeMethod.Statements.Add(new CodeMethodReturnStatement(new CodeCastExpression(method.MimeReturn.TypeName, invoke))); } else { mainCodeMethod.Statements.Add(new CodeExpressionStatement(invoke)); } metadata = new CodeAttributeDeclarationCollection(); string[] asyncParameterTypeNames = new string[parameterTypeNames.Length + 2]; parameterTypeNames.CopyTo(asyncParameterTypeNames, 0); asyncParameterTypeNames[parameterTypeNames.Length] = typeof(AsyncCallback).FullName; asyncParameterTypeNames[parameterTypeNames.Length + 1] = typeof(object).FullName; string[] asyncParameterNames = new string[parameterNames.Length + 2]; parameterNames.CopyTo(asyncParameterNames, 0); asyncParameterNames[parameterNames.Length] = "callback"; asyncParameterNames[parameterNames.Length + 1] = "asyncState"; if (oldAsync) { CodeMemberMethod beginCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, "Begin" + method.Name, new CodeFlags[asyncParameterTypeNames.Length], asyncParameterTypeNames, asyncParameterNames, typeof(IAsyncResult).FullName, metadata, CodeFlags.IsPublic); beginCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); invokeParams = new CodeExpression[5]; CreateInvokeParams(invokeParams, method, parameterNames); invokeParams[3] = new CodeArgumentReferenceExpression("callback"); invokeParams[4] = new CodeArgumentReferenceExpression("asyncState"); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "BeginInvoke", invokeParams); beginCodeMethod.Statements.Add(new CodeMethodReturnStatement(invoke)); CodeMemberMethod endCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, "End" + method.Name, new CodeFlags[1], new string[] { typeof(IAsyncResult).FullName }, new string[] { "asyncResult" }, method.MimeReturn.TypeName, metadata, CodeFlags.IsPublic); endCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); CodeExpression expr = new CodeArgumentReferenceExpression("asyncResult"); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "EndInvoke", new CodeExpression[] { expr }); if (method.MimeReturn.ReaderType != null) { endCodeMethod.Statements.Add(new CodeMethodReturnStatement(new CodeCastExpression(method.MimeReturn.TypeName, invoke))); } else { endCodeMethod.Statements.Add(new CodeExpressionStatement(invoke)); } } if (newAsync) { metadata = new CodeAttributeDeclarationCollection(); string uniqueMethodName = method.Name; string methodKey = MethodSignature(uniqueMethodName, method.MimeReturn.TypeName, new CodeFlags[parameterTypeNames.Length], parameterTypeNames); DelegateInfo delegateInfo = (DelegateInfo)ExportContext[methodKey]; if (delegateInfo == null) { string handlerType = ClassNames.AddUnique(uniqueMethodName + "CompletedEventHandler", uniqueMethodName); string handlerArgs = ClassNames.AddUnique(uniqueMethodName + "CompletedEventArgs", uniqueMethodName); delegateInfo = new DelegateInfo(handlerType, handlerArgs); } string handlerName = MethodNames.AddUnique(uniqueMethodName + "Completed", uniqueMethodName); string asyncName = MethodNames.AddUnique(uniqueMethodName + "Async", uniqueMethodName); string callbackMember = MethodNames.AddUnique(uniqueMethodName + "OperationCompleted", uniqueMethodName); string callbackName = MethodNames.AddUnique("On" + uniqueMethodName + "OperationCompleted", uniqueMethodName); // public event xxxCompletedEventHandler xxxCompleted; WebCodeGenerator.AddEvent(this.CodeTypeDeclaration.Members, delegateInfo.handlerType, handlerName); // private SendOrPostCallback xxxOperationCompleted; WebCodeGenerator.AddCallbackDeclaration(this.CodeTypeDeclaration.Members, callbackMember); // create the pair of xxxAsync methods string userState = UniqueName("userState", parameterNames); CodeMemberMethod asyncCodeMethod = WebCodeGenerator.AddAsyncMethod(this.CodeTypeDeclaration, asyncName, parameterTypeNames, parameterNames, callbackMember, callbackName, userState); // Generate InvokeAsync call invokeParams = new CodeExpression[5]; CreateInvokeParams(invokeParams, method, parameterNames); invokeParams[3] = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), callbackMember); invokeParams[4] = new CodeArgumentReferenceExpression(userState); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "InvokeAsync", invokeParams); asyncCodeMethod.Statements.Add(invoke); // private void On_xxx_OperationCompleted(object arg) {..} bool methodHasReturn = method.MimeReturn.ReaderType != null; WebCodeGenerator.AddCallbackImplementation(this.CodeTypeDeclaration, callbackName, handlerName, delegateInfo.handlerArgs, methodHasReturn); if (ExportContext[methodKey] == null) { // public delegate void xxxCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs args); WebCodeGenerator.AddDelegate(ExtraCodeClasses, delegateInfo.handlerType, methodHasReturn ? delegateInfo.handlerArgs : typeof(AsyncCompletedEventArgs).FullName); if (methodHasReturn) { ExtraCodeClasses.Add(WebCodeGenerator.CreateArgsClass(delegateInfo.handlerArgs, new string[] { method.MimeReturn.TypeName }, new string[] { "Result" }, ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes))); } ExportContext[methodKey] = delegateInfo; } } } return(mainCodeMethod); }
/// <summary>Constructor with operator name and both operands passed.</summary> /// <param name="operatorName">Operator name.</param> /// <param name="operand">Operand.</param> public UnaryOperator(MethodNames operatorName, IExpression operand) : base(operatorName) { Operand = operand; }
/// <summary>Default constructor with operator name.</summary> /// <param name="operatorName">Operator name.</param> public UnaryOperator(MethodNames operatorName) : base(operatorName) { }
/// <summary>Default constructor with method name passed.</summary> /// <param name="methodName">Method name.</param> public Call(MethodNames methodName) : base() { ObservableCollection<IExpression> arguments = new ObservableCollection<IExpression>(); arguments.CollectionChanged += OnCollectionChanged; _arguments = arguments; _member = methodName; }