public static IMethodDeclaration CreateEventInvocator(FileModel fileModel, IEventDeclaration eventDeclaration) { IDelegateDeclaration delegateDeclaration = eventDeclaration.TypeName.Type.As<IDelegateType>().DelegateDeclaration; if (delegateDeclaration.Exists) { var language = eventDeclaration.Language; IModifiers modifiers = language.Modifiers(Modifiers.Protected | Modifiers.Virtual); IList<IParameter> parameters = new List<IParameter>(); IList<IArgument> arguments = new List<IArgument>(); arguments.Add(language.Argument(language.New<IThis>())); IParameter lastParameter = delegateDeclaration.Parameters.Parameters.Last(); GenerateSecondParameterAndArgument(eventDeclaration, lastParameter, language, fileModel, arguments, parameters); if (string.Equals(language.Name, LanguageNames.CSharp, StringComparison.Ordinal)) { return CreateCSInvocator(eventDeclaration, modifiers, arguments, parameters, language); } else if (string.Equals(language.Name, LanguageNames.VisualBasic, StringComparison.Ordinal)) { return CreateVBInvocator(eventDeclaration, modifiers, arguments, parameters, language); } } return eventDeclaration.Language.None<IMethodDeclaration>(); }
private static IMethodDeclaration CreateVBInvocator(IEventDeclaration eventDeclaration, IModifiers modifiers, IList<IArgument> arguments, IList<IParameter> parameters, IConstructLanguage language) { IEventInvocation eventInvocation = language.New<IEventInvocation>(); eventInvocation.DelegateInvocation = language.DelegateInvocation( language.VariableAccess(eventDeclaration.Identifier), language.Arguments(arguments)); IMethodDeclaration method = language.Method( language.None<IDocComment>(), language.None<IAttributes>(), modifiers, language.TypeName(eventDeclaration.VoidTypeAtThisLocation()), language.None<IMethodTypeParameters>(), language.Parameters(parameters), language.Block( language.ExpressionStatement(eventInvocation))); NamingPolicy methodsNamingPolicy = method.PrimaryNamingPolicy(eventDeclaration.FileModel.UserSettings); string methodName = methodsNamingPolicy.ChangeNameAccordingToPolicy("Raise" + eventDeclaration.Identifier.Name + "Event", eventDeclaration.SolutionModel); method.Identifier = language.Identifier(methodName); return method; }
private static IMethodDeclaration CreateCSInvocator(IEventDeclaration eventDeclaration, IModifiers modifiers, IList<IArgument> arguments, IList<IParameter> parameters, IConstructLanguage language) { IVariableDeclaration variable = language.Variable( eventDeclaration.TypeName, language.VariableAccess(eventDeclaration.Identifier)); NamingPolicy variablesNamingPolicy = variable.PrimaryNamingPolicy(eventDeclaration.FileModel.UserSettings); string variableName = variablesNamingPolicy.ChangeNameAccordingToPolicy("on" + eventDeclaration.Identifier.Name, eventDeclaration.SolutionModel); variable.Identifier = language.Identifier(variableName); IIfStatement ifStatement = language.IfStatement( language.BinaryExpression( language.VariableAccess(variable.Identifier), Operator.NotEqual, language.New<INull>()), language.Block( language.ExpressionStatement( language.DelegateInvocation( language.VariableAccess(variable.Identifier), language.Arguments(arguments))))); IMethodDeclaration method = language.Method( language.None<IDocComment>(), language.None<IAttributes>(), modifiers, language.TypeName(eventDeclaration.VoidTypeAtThisLocation()), language.None<IMethodTypeParameters>(), language.Parameters(parameters), language.Block( variable, ifStatement)); NamingPolicy methodsNamingPolicy = method.PrimaryNamingPolicy(eventDeclaration.FileModel.UserSettings); string methodName = methodsNamingPolicy.ChangeNameAccordingToPolicy("on" + eventDeclaration.Identifier.ToUpperFirstLetter().Name, eventDeclaration.SolutionModel); method.Identifier = language.Identifier(methodName); return method; }
public virtual IEventDeclarationCollection TransformEventDeclarationCollection(IEventDeclarationCollection events) { IEventDeclaration[] array = new IEventDeclaration[events.Count]; for (int i = 0; i < events.Count; i++) { array[i] = this.TransformEventDeclaration(events[i]); } IEventDeclarationCollection target = new EventDeclarationCollection(); target.AddRange(array); return target; }
public int Visit(IEventDeclaration decl, int context) { return(1); }
public EventInfo Event(IEventDeclaration eventDeclaration) { if (_eventCorrespondence.ContainsKey(eventDeclaration)) { return _eventCorrespondence[eventDeclaration]; } var addMethod = eventDeclaration.AddMethod.Resolve(); var eventInfo = new EventInfo { Text = eventDeclaration.ToString(), Name = eventDeclaration.Name, FullName = eventDeclaration.Name, IsInternal = addMethod.Visibility == MethodVisibility.Assembly, IsPrivate = addMethod.Visibility == MethodVisibility.Private, IsPublic = addMethod.Visibility == MethodVisibility.Public, IsProtected = addMethod.Visibility == MethodVisibility.Family, IsProtectedAndInternal = addMethod.Visibility == MethodVisibility.FamilyAndAssembly, IsProtectedOrInternal = addMethod.Visibility == MethodVisibility.FamilyOrAssembly, IsStatic = addMethod.Static, MemberReference = eventDeclaration }; _eventCorrespondence.Add(eventDeclaration, eventInfo); eventInfo.Text = eventInfo.Text.Substring(eventInfo.Text.LastIndexOf('.') + 1); eventInfo.Name = eventInfo.Name.Substring(eventInfo.Name.LastIndexOf('.') + 1); eventInfo.Icon = Images.Images.GetEventIcon(eventInfo); return eventInfo; }
public static EventDefinition FindMatchingEvent(TypeDefinition typedef, IEventDeclaration edec) { return typedef.Events.FirstOrDefault(edef => EventMatches(edef, edec)); }
public EventDefinition GetEventDefinition(IEventDeclaration item) { return TryGetOrAdd(_eventcache, item, edef => { var tdef = GetTypeDefinition(item.DeclaringType as ITypeDeclaration); return tdef == null ? null : ReflectorHelper.FindMatchingEvent(tdef, edef); }); }
public void WriteEventDeclaration(IEventDeclaration value) { if ((configuration["ShowCustomAttributes"] == "true") && (value.Attributes.Count != 0)) { this.WriteCustomAttributeList(value, formatter); formatter.WriteLine(); } ITypeDeclaration declaringType = (value.DeclaringType as ITypeReference).Resolve(); if (!declaringType.Interface) { WriteMethodVisibility(Helper.GetVisibility(value), formatter); } if (Helper.IsStatic(value)) { formatter.WriteKeyword("static"); formatter.Write(" "); } formatter.Write("event"); formatter.Write(" "); this.WriteType(value.EventType, formatter); formatter.Write(" "); formatter.WriteKeyword(value.Name); formatter.Write(";"); this.WriteDeclaringType(value.DeclaringType as ITypeReference, formatter); }
public virtual void VisitEventDeclaration(IEventDeclaration value) { this.VisitCustomAttributeCollection(value.Attributes); this.VisitType(value.EventType); }
/// <summary> /// Declares a type with a specific name. /// </summary> /// <param name="name">The name of the declared type.</param> /// <returns>A type declaration.</returns> private ITypeDeclaration CreateTypeDeclaration(string name) { ITypeDeclaration td = builder.TypeDecl(); td.Visibility = TypeVisibility.Public; td.Namespace = "TestNameSpace"; td.Interface = false; td.Name = name; // Derive from an interface td.Interfaces.Add((ITypeReference)builder.TypeRef(typeof(ICloneable))); // Add some methods IParameterDeclaration parm1 = builder.Param("val", typeof(int)); IMethodDeclaration meth1 = builder.MethodDecl(MethodVisibility.Public, "MyMethod", typeof(int), td, parm1); IMethodDeclaration meth2 = builder.MethodDecl(MethodVisibility.Public, "Clone", typeof(object), td); IMethodDeclaration meth3 = builder.MethodDecl(MethodVisibility.Public, "ThrowMethod", typeof(void), td); IBlockStatement im1bs = builder.BlockStmt(); IBlockStatement im2bs = builder.BlockStmt(); IBlockStatement im3bs = builder.BlockStmt(); im1bs.Statements.Add(builder.Return(builder.ParamRef(parm1))); meth1.Body = im1bs; im2bs.Statements.Add(builder.Return(builder.LiteralExpr(null))); meth2.Body = im2bs; im3bs.Statements.Add(builder.ThrowStmt(builder.NewObject(typeof(InferCompilerException)))); meth3.Body = im3bs; td.Methods.Add(meth1); td.Methods.Add(meth2); td.Methods.Add(meth3); IGenericParameter gp1 = builder.GenericTypeParam("T1"); IGenericParameter gp2 = builder.GenericTypeParam("T2"); IList <IGenericParameter> gps = new List <IGenericParameter>(); gps.Add(gp1); gps.Add(gp2); IParameterDeclaration gparm1 = builder.Param("parm1", gp1); IParameterDeclaration gparm2 = builder.Param("parm2", gp2); IMethodDeclaration meth4 = builder.GenericMethodDecl( MethodVisibility.Public, "MyGenericMethod", gp1, td, gps, gparm1, gparm2); IBlockStatement im4bs = builder.BlockStmt(); im4bs.Statements.Add(builder.Return(builder.ParamRef(gparm1))); meth4.Body = im4bs; td.Methods.Add(meth4); // Add some properties IPropertyDeclaration prop1 = builder.PropDecl("MyIntProperty", typeof(int), td, MethodVisibility.Public); IPropertyDeclaration prop2 = builder.PropDecl("MyObjProperty", typeof(object), td, MethodVisibility.Public); IBlockStatement ip1bs = builder.BlockStmt(); IBlockStatement ip2bs = builder.BlockStmt(); ip1bs.Statements.Add(builder.Return(builder.LiteralExpr(1))); ((IMethodDeclaration)prop1.GetMethod).Body = ip1bs; ip2bs.Statements.Add(builder.Return(builder.LiteralExpr(null))); ((IMethodDeclaration)prop2.GetMethod).Body = ip2bs; td.Properties.Add(prop1); td.Properties.Add(prop2); // Add an event IEventDeclaration event1 = builder.EventDecl("MyEvent", (ITypeReference)builder.TypeRef(typeof(Action <object>)), td); td.Events.Add(event1); // Build a wrapper function that allows clients to fire the event IMethodDeclaration fireEventMethod = builder.FireEventDecl(MethodVisibility.Public, "MyEventWrapper", event1); td.Methods.Add(fireEventMethod); return(td); }
public void Visit(IEventDeclaration stmt, SSTPrintingContext c) { c.Indentation() .Keyword("event").Space().Type(stmt.Name.HandlerType).Space().Text(stmt.Name.Name).Text(";"); }
public override void Visit(IEventDeclaration stmt, IKaVESet <IName> context) { context.Add(stmt.Name); base.Visit(stmt, context); }
/// <summary> /// Retrieve the matching field in the Cecil object model /// </summary> /// <param name="fdec">Reflector field declaration</param> /// <returns>Cecil property definition (null if not found)</returns> public static EventDefinition ReflectorEventToCecilEvent(IEventDeclaration edec) { return(ReflectorToCecilMember(edec, (context, item) => context.GetEventDefinition(item))); }
public static IMethodDeclaration GetInvokeMethod(IEventReference value) { IEventDeclaration eventDeclaration = value.Resolve(); return(eventDeclaration.InvokeMethod?.Resolve()); }
public void WriteEventDeclaration(IEventDeclaration value) { visitor.VisitEventDeclaration(value); }
private void Translate() { if (this.Parent != null) { RichTextFormatter formatter = new RichTextFormatter(); ILanguage language = this.languageManager.ActiveLanguage; LanguageWriterConfiguration configuration = new LanguageWriterConfiguration(); configuration.Visibility = this.visibilityConfiguration; configuration["ShowCustomAttributes"] = "true"; configuration["ShowNamespaceImports"] = "true"; configuration["ShowNamespaceBody"] = "true"; configuration["ShowTypeDeclarationBody"] = "true"; configuration["ShowMethodDeclarationBody"] = "false"; ILanguageWriter writer = language.GetWriter(formatter, configuration); object value = this.assemblyBrowser.ActiveItem; ITypeDeclaration typeDeclaration = value as ITypeDeclaration; if (typeDeclaration != null) { configuration["ShowMethodDeclarationBody"] = "false"; if (language.Translate) { typeDeclaration = this.translatorManager.CreateDisassembler(null, null).TranslateTypeDeclaration(typeDeclaration, true, false); } writer.WriteTypeDeclaration(typeDeclaration); } IFieldDeclaration fieldDeclaration = value as IFieldDeclaration; if (fieldDeclaration != null) { configuration["ShowMethodDeclarationBody"] = "true"; if (language.Translate) { fieldDeclaration = this.translatorManager.CreateDisassembler(null, null).TranslateFieldDeclaration(fieldDeclaration); } writer.WriteFieldDeclaration(fieldDeclaration); } IMethodDeclaration methodDeclaration = value as IMethodDeclaration; if (methodDeclaration != null) { configuration["ShowMethodDeclarationBody"] = "true"; if (language.Translate) { methodDeclaration = this.translatorManager.CreateDisassembler(null, null).TranslateMethodDeclaration(methodDeclaration); } writer.WriteMethodDeclaration(methodDeclaration); } IPropertyDeclaration propertyDeclaration = value as IPropertyDeclaration; if (propertyDeclaration != null) { configuration["ShowMethodDeclarationBody"] = "true"; if (language.Translate) { propertyDeclaration = this.translatorManager.CreateDisassembler(null, null).TranslatePropertyDeclaration(propertyDeclaration); } writer.WritePropertyDeclaration(propertyDeclaration); } IEventDeclaration eventDeclaration = value as IEventDeclaration; if (eventDeclaration != null) { configuration["ShowMethodDeclarationBody"] = "true"; if (language.Translate) { eventDeclaration = this.translatorManager.CreateDisassembler(null, null).TranslateEventDeclaration(eventDeclaration); } writer.WriteEventDeclaration(eventDeclaration); } this.Rtf = formatter.ToString(); } }
private static void GenerateSecondParameterAndArgument(IEventDeclaration eventDeclaration, IParameter parameter, IConstructLanguage language, FileModel fileModel, IList<IArgument> arguments, IList<IParameter> parameters) { NamingPolicy parametersNamingPolicy = language.PrimaryNamingPolicyFor<IParameter>(fileModel.UserSettings); IType parameterType = eventDeclaration.TypeName.Type.As<IDelegateType>().ReplaceParameterTypesIn(parameter.Type); IParameter newParameter = language.Parameter( parameter.IsRef, parameter.IsOut, parameter.IsParams, language.TypeName(eventDeclaration.StringTypeAtThisLocation()), parameter.DefaultValue); string parameterName = parametersNamingPolicy.ChangeNameAccordingToPolicy("propertyName", parameter.SolutionModel); newParameter.Identifier = language.Identifier(parameterName); IObjectCreation objectCreation = language.ObjectCreation( language.TypeName(parameterType), language.Arguments( language.Argument( language.VariableAccess(newParameter.Identifier)))); arguments.Add( language.Argument( objectCreation)); parameters.Add(newParameter); }
public EventDeclarationCompiler(IEventDeclaration eventDeclaration, AbstractILCompilerParams @params) : base(@params) { myEventDeclaration = eventDeclaration; }
public string Decompile(int languageIndex, object o) { if (o == null) { return(String.Empty); } IFormatter formatter = CreateFormatter(this.LanguageManager.Languages[languageIndex].Name); ILanguageWriter writer = this.LanguageManager.Languages[languageIndex].GetWriter(formatter, _langurageWriterConfiguration); ITranslator translator = this.TranslatorManager.CreateDisassembler(null, null); if (o is IMethodDeclaration) { IMethodDeclaration m2; if (IsIL(languageIndex)) { m2 = (IMethodDeclaration)o; } else { m2 = translator.TranslateMethodDeclaration((IMethodDeclaration)o); } writer.WriteMethodDeclaration(m2); } else if (o is IPropertyDeclaration) { IPropertyDeclaration p2 = translator.TranslatePropertyDeclaration((IPropertyDeclaration)o); writer.WritePropertyDeclaration(p2); } else if (o is IFieldDeclaration) { IFieldDeclaration f2 = translator.TranslateFieldDeclaration((IFieldDeclaration)o); writer.WriteFieldDeclaration(f2); } else if (o is ITypeDeclaration) { ITypeDeclaration t2 = translator.TranslateTypeDeclaration((ITypeDeclaration)o, true, false); writer.WriteTypeDeclaration(t2); } else if (o is IEventDeclaration) { IEventDeclaration e2 = translator.TranslateEventDeclaration((IEventDeclaration)o); writer.WriteEventDeclaration(e2); } else if (o is IModule) { IModule m2 = translator.TranslateModule((IModule)o, true); writer.WriteModule(m2); } else if (o is IModuleReference) { IModuleReference mr2 = translator.TranslateModuleReference((IModuleReference)o); writer.WriteModuleReference(mr2); } else if (o is IAssembly) { IAssembly a2 = translator.TranslateAssembly((IAssembly)o, true); writer.WriteAssembly(a2); } else if (o is IAssemblyReference) { IAssemblyReference ar2 = translator.TranslateAssemblyReference((IAssemblyReference)o); writer.WriteAssemblyReference(ar2); } else if (o is IResource) { writer.WriteResource((IResource)o); } else if (o is INamespace) { writer.WriteNamespace((INamespace)o); } return(formatter.ToString()); }
public virtual void Visit(IEventDeclaration stmt, TContext context) { }
/// <exception cref="BadSyntaxException"> /// The <paramref name="declaration"/> does not fit to the syntax. /// </exception> public abstract void InitFromDeclaration(IEventDeclaration declaration);
/// <summary> /// Retrieve an Event Definition from the object /// </summary> /// <param name="item">the object</param> /// <returns>The matching Event Definition</returns> public override EventDefinition GetEventDefinition(object item) { IEventDeclaration edec = item as IEventDeclaration; return(ReflectorHelper.ReflectorEventToCecilEvent(edec)); }
private bool CheckEventDecl(IEventDeclaration o, IEventDeclaration n) { throw new NotImplementedException(); //Log.LogMessage(o.ToString()); //return true; }
/// <summary> /// Returns an xml string of the documentation for an element. /// </summary> /// <param name="owner"> /// The owner of the doc comment block. /// </param> /// <param name="docConfig"> /// The config for the current ProjectFile. /// </param> /// <returns> /// A string of the declarations summary text. /// </returns> private static string CreateDocumentationForElement(IDocCommentBlockOwnerNode owner, DocumentationRulesConfiguration docConfig) { ITreeNode element = owner; IDeclaredElement declaredElement = (element is IDeclaration) ? ((IDeclaration)element).DeclaredElement : null; StringBuilder text = new StringBuilder(); text.AppendLine("<summary>"); string summaryText = string.Empty; if (element is IConstructorDeclaration) { summaryText = Utils.CreateSummaryForConstructorDeclaration((IConstructorDeclaration)element); } if (element is IDestructorDeclaration) { summaryText = Utils.CreateSummaryForDestructorDeclaration((IDestructorDeclaration)element); } if (element is IPropertyDeclaration) { summaryText = Utils.CreateSummaryDocumentationForProperty((IPropertyDeclaration)element); } text.AppendLine(summaryText); text.AppendLine("</summary>"); ICSharpParametersOwnerDeclaration declarationWithParameters = element as ICSharpParametersOwnerDeclaration; if (declarationWithParameters != null) { foreach (IRegularParameterDeclaration parameterDeclaration in declarationWithParameters.ParameterDeclarations) { text.AppendLine(Utils.CreateDocumentationForParameter(parameterDeclaration)); } } ICSharpTypeDeclaration typeDeclaration = element as ICSharpTypeDeclaration; if (typeDeclaration != null && (typeDeclaration.TypeParameters.Count > 0)) { foreach (ITypeParameterOfTypeDeclaration typeParameter in typeDeclaration.TypeParameters) { text.AppendLine(Utils.CreateDocumentationForParameter(typeParameter)); } } ITypeParametersOwner typeParametersOwner = element as ITypeParametersOwner; if (typeParametersOwner != null && (typeParametersOwner.TypeParameters.Count > 0)) { foreach (ITypeParameter typeParameter in typeParametersOwner.TypeParameters) { text.AppendLine(Utils.CreateDocumentationForTypeParameterDeclaration((ITypeParameterDeclaration)typeParameter)); } } IMethodDeclaration methodDeclaration = element as IMethodDeclaration; if (methodDeclaration != null && (methodDeclaration.TypeParameterDeclarations.Count > 0)) { foreach (ITypeParameterOfMethodDeclaration typeParameter in methodDeclaration.TypeParameterDeclarations) { text.AppendLine(Utils.CreateDocumentationForParameter(typeParameter)); } } IParametersOwner parametersOwner = declaredElement as IParametersOwner; if ((parametersOwner != null && ((parametersOwner is IMethod) || (parametersOwner is IOperator))) && !parametersOwner.ReturnType.Equals(parametersOwner.Module.GetPredefinedType().Void)) { text.AppendLine("<returns></returns>"); } bool ruleIsEnabled = docConfig.GetStyleCopRuleEnabled("PropertyDocumentationMustHaveValue"); if (element is IPropertyDeclaration && ruleIsEnabled) { text.AppendLine(Utils.CreateValueDocumentationForProperty((IPropertyDeclaration)element)); } List <IType> exceptions = new List <IType>(); ICSharpFunctionDeclaration functionDeclaration = element as ICSharpFunctionDeclaration; if (functionDeclaration != null && functionDeclaration.Body != null) { CollectExceptions(functionDeclaration.Body, exceptions); } IPropertyDeclaration propertyDeclaration = element as IPropertyDeclaration; if (propertyDeclaration != null) { CollectExceptions(propertyDeclaration.AccessorDeclarations, exceptions); } IIndexerDeclaration indexerDeclaration = element as IIndexerDeclaration; if (indexerDeclaration != null) { CollectExceptions(indexerDeclaration.AccessorDeclarations, exceptions); } IEventDeclaration eventDeclaration = element as IEventDeclaration; if (eventDeclaration != null) { CollectExceptions(eventDeclaration.AccessorDeclarations, exceptions); } foreach (IType exception in exceptions) { string presentableName = exception.GetPresentableName(CSharpLanguage.Instance); string a = Utils.StripClassName(presentableName); string b = exception.ToString(); text.AppendLine("<exception cref=\"" + Utils.SwapGenericTypeToDocumentation(a) + "\"></exception>"); } return(text.ToString()); }
private bool CheckEventDecl(IEventDeclaration o, IEventDeclaration n) { //TODO if (!o.Attributes.Compare(n.Attributes, CheckCustomAttribute)) return false; return (o.DeclaringType.ToString() == n.DeclaringType.ToString() && o.EventType.CompareITypeReference(n.EventType) && o.Documentation == n.Documentation && CompareIMethodReference(o.InvokeMethod, n.InvokeMethod) && o.Name == n.Name && CompareIMethodReference(o.RemoveMethod, n.RemoveMethod) && o.RuntimeSpecialName == n.RuntimeSpecialName && o.SpecialName == n.SpecialName ); // return false; // ComareIEventReference(o.GenericEvent, n.GenericEvent) && }
public static EventDefinition FindMatchingEvent(TypeDefinition typedef, IEventDeclaration edec) { return(typedef.Events.FirstOrDefault(edef => EventMatches(edef, edec))); }
private void SetCodeReference(IMemberReference memberReference) { ILHtmlFormattedCodeWriter msilWriter = new ILHtmlFormattedCodeWriter(); CSharpHtmlFormattedCodeWriter cSharpWriter = new CSharpHtmlFormattedCodeWriter(); IAssemblyReference assemblyReference = memberReference as IAssemblyReference; if (assemblyReference != null) { new ILWriter().WriteAssembly(assemblyReference, msilWriter); new CSharpWriter().WriteAssembly(assemblyReference, cSharpWriter); } IModule module = memberReference as IModule; if (module != null) { new ILWriter().WriteModule(module, msilWriter); new CSharpWriter().WriteModule(module, cSharpWriter); } ITypeDeclaration typeDeclaration = memberReference as ITypeDeclaration; if (typeDeclaration != null) { new ILWriter().WriteTypeDeclaration(typeDeclaration, msilWriter); new CSharpWriter().WriteTypeDeclaration(typeDeclaration, cSharpWriter); } IMethodDeclaration methodDeclaration = memberReference as IMethodDeclaration; if (methodDeclaration != null) { new ILWriter().WriteMethodDeclaration(methodDeclaration, msilWriter); _controlFlowGraphView.Graph = methodDeclaration.Body.ControlFlowGraph; new CSharpWriter().WriteMethodDeclaration(methodDeclaration, cSharpWriter); } IEventDeclaration eventDeclaration = memberReference as IEventDeclaration; if (eventDeclaration != null) { new ILWriter().WriteEventDeclaration(eventDeclaration, msilWriter); new CSharpWriter().WriteEventDeclaration(eventDeclaration, cSharpWriter); } IPropertyDeclaration propertyDeclaration = memberReference as IPropertyDeclaration; if (propertyDeclaration != null) { new ILWriter().WritePropertyDeclaration(propertyDeclaration, msilWriter); new CSharpWriter().WritePropertyDeclaration(propertyDeclaration, cSharpWriter); } IFieldDeclaration fieldDeclaration = memberReference as IFieldDeclaration; if (fieldDeclaration != null) { new ILWriter().WriteFieldDeclaration(fieldDeclaration, msilWriter); new CSharpWriter().WriteFieldDeclaration(fieldDeclaration, cSharpWriter); } _msilCodeBrowser.DocumentText = msilWriter.Html; _cSharpBrowser.DocumentText = cSharpWriter.Html; SetViewContext(ViewContext.Code); }
private static bool EventMatches(EventDefinition edef, IEventDeclaration edec) { // Compatible with alteration feature !!! // Called only the first time then in cache, so even if code is altered, this will work // No need to check the declaring type, if we are here, they are in sync if (edef == null || edec == null) return false; if (IsSameName(edef.Name, edec.Name) && TypeMatches(edef.EventType, edec.EventType)) { return MethodMatches(edef.AddMethod, edec.AddMethod as IMethodDeclaration) && MethodMatches(edef.RemoveMethod, edec.RemoveMethod as IMethodDeclaration); } return false; }
public virtual void VisitEventDeclaration(IEventDeclaration value) { VisitCustomAttributeCollection(value.Attributes); VisitType(value.EventType); }
public override void Visit(IEventDeclaration stmt, int context) { Test(stmt.Name, "0F"); Test(stmt.Name.ValueType, "0T"); Test(stmt.Name.DeclaringType, "0T"); }
public virtual IEventDeclaration TransformEventDeclaration(IEventDeclaration value) { this.InsituTransformCustomAttributeCollection(value.Attributes); return value; }