private void WriteEventDefinition(IEventDefinition evnt)
        {
            // Adder and Remover modifiers should be same.
            IMethodDefinition accessor = evnt.Accessors.First().ResolvedMethod;

            if (!evnt.ContainingTypeDefinition.IsInterface)
            {
                WriteAttributes(evnt.Attributes);
                if (!accessor.IsExplicitInterfaceMethod())
                    WriteVisibility(evnt.Visibility);
                WriteMethodModifiers(accessor);
            }

            if (evnt.GetHiddenBaseEvent(_filter) != Dummy.Event)
                WriteKeyword("new");
            WriteKeyword("event");
            WriteTypeName(evnt.Type);
            WriteIdentifier(evnt.Name);

            if (_forCompilation && !evnt.IsAbstract())
            {
                WriteSpace();
                WriteSymbol("{", addSpace: true);
                WriteEventBody("add");
                WriteEventBody("remove");
                WriteSymbol("}");
            }
            else
            {
                WriteSymbol(";");
            }
        }
Exemplo n.º 2
0
        public override void Visit(IEventDefinition evnt)
        {
            AddMemberReference(evnt.Adder.ResolvedMethod);
            AddMemberReference(evnt.Remover.ResolvedMethod);

            base.Visit(evnt);
        }
Exemplo n.º 3
0
        public override void TraverseChildren(IEventDefinition eventDefinition)
        {
            if (!MemberHelper.IsVisibleOutsideAssembly(eventDefinition))
                return;

            _assembly.EnrollApi(eventDefinition);
        }
 internal override bool TryGetEvent(IEventDefinition def, out uint index)
 {
     TypeFromMetadata type;
     if (this.TryGetTypeDefinition(def.ContainingTypeDefinition, out type))
     {
         EventHandle handle;
         if (type.TryGetEvent(def.Name, out handle))
         {
             index = (uint)handle.GetRowNumber();
             return true;
         }
     }
     index = 0;
     return false;
 }
Exemplo n.º 5
0
 public override void TraverseChildren(IEventDefinition eventDefinition)
 {
     PrintAttributes(eventDefinition);
       PrintToken(CSharpToken.Indent);
       IMethodDefinition eventMeth = eventDefinition.Adder == null ?
     eventDefinition.Remover.ResolvedMethod :
     eventDefinition.Adder.ResolvedMethod;
       if (!eventDefinition.ContainingTypeDefinition.IsInterface &&
     IteratorHelper.EnumerableIsEmpty(MemberHelper.GetExplicitlyOverriddenMethods(eventMeth)))
       PrintEventDefinitionVisibility(eventDefinition);
       PrintMethodDefinitionModifiers(eventMeth);
       PrintToken(CSharpToken.Event);
       PrintEventDefinitionDelegateType(eventDefinition);
       PrintToken(CSharpToken.Space);
       PrintEventDefinitionName(eventDefinition);
       PrintToken(CSharpToken.Semicolon);
 }
Exemplo n.º 6
0
        void source_EventChanged(IEventDefinition ev, IEventState state)
        {
            if (!_isConnected && !(state is FreeSCADA.Common.Events.States.StartedEventState))
            {
                return;
            }
            try
            {
                SmsSubmitPdu[] pdus = _settings.TelNumbers.Cast <TelNumElement>().Select(t => new SmsSubmitPdu(state.FormatText(ev.Text), t.TelNum, (byte)DataCodingScheme.GeneralCoding.Alpha16Bit)).ToArray();

                _comm.SendMessages(pdus);
            }
            catch (Exception e)
            {
                Env.Current.Logger.LogInfo(e.Message);
            }
        }
        public bool TestGCClearCacheEvent()
        {
            ITypeDefinition     type          = Helper.GetNamespaceType(Helper.GetNamespace(this.ModuleReaderTest.MscorlibAssembly, this.System), this.GC);
            IEventDefinition    eventDef      = Helper.GetEventNamed(type, this.ClearCache);
            StringILDasmPaper   stringPaper   = new StringILDasmPaper(2);
            ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.MscorlibAssembly);

            prettyPrinter.EventDefinition(eventDef);
            string result =
                @".event assembly System.Reflection.Cache.ClearCacheHandler ClearCache
{
  .addon static void System.GC::add_ClearCache(System.Reflection.Cache.ClearCacheHandler)
  .removeon static void System.GC::remove_ClearCache(System.Reflection.Cache.ClearCacheHandler)
}
";

            return(result.Equals(stringPaper.Content));
        }
        public bool TestGeneric1Event()
        {
            ITypeDefinition     genType       = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Generic1);
            IEventDefinition    eventDef      = Helper.GetEventNamed(genType, this.GenericEvent);
            StringILDasmPaper   stringPaper   = new StringILDasmPaper(2);
            ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);

            prettyPrinter.EventDefinition(eventDef);
            string result =
                @".event public[MRW_Assembly]GenericDelegate`1<!0>GenericEvent
{
  .addon instance void[MRW_Assembly]Generic1`1::add_GenericEvent([MRW_Assembly]GenericDelegate`1<!0>)
  .removeon instance void[MRW_Assembly]Generic1`1::remove_GenericEvent([MRW_Assembly]GenericDelegate`1<!0>)
}
";

            return(result.Equals(stringPaper.Content));
        }
Exemplo n.º 9
0
        internal static string TypeDefinitionMember(IUnit currentUnit, ITypeDefinitionMember typeDefinitionMember)
        {
            INestedTypeDefinition nestedTypeDefinition = typeDefinitionMember as INestedTypeDefinition;

            if (nestedTypeDefinition != null)
            {
                StringBuilder sb = new StringBuilder(".class ");
                sb.Append(nestedTypeDefinition.Name.Value);
                return(sb.ToString());
            }
            IMethodDefinition methodDefinition = typeDefinitionMember as IMethodDefinition;

            if (methodDefinition != null)
            {
                StringBuilder sb = new StringBuilder(".method ");
                sb.AppendFormat("{0} : {1}", methodDefinition.Name.Value, Helper.SignatureDefinition(currentUnit, methodDefinition));
                return(sb.ToString());
            }
            IFieldDefinition fieldDefinition = typeDefinitionMember as IFieldDefinition;

            if (fieldDefinition != null)
            {
                StringBuilder sb = new StringBuilder(".field ");
                sb.AppendFormat("{0} : {1}", fieldDefinition.Name.Value, Helper.TypeDefinition(currentUnit, fieldDefinition.Type.ResolvedType));
                return(sb.ToString());
            }
            IEventDefinition eventDefinition = typeDefinitionMember as IEventDefinition;

            if (eventDefinition != null)
            {
                StringBuilder sb = new StringBuilder(".event ");
                sb.AppendFormat("{0} : {1}", eventDefinition.Name.Value, Helper.TypeDefinition(currentUnit, eventDefinition.Type.ResolvedType));
                return(sb.ToString());
            }
            IPropertyDefinition propertyDefinition = typeDefinitionMember as IPropertyDefinition;

            if (propertyDefinition != null)
            {
                StringBuilder sb = new StringBuilder(".property ");
                sb.AppendFormat("{0} : {1}", propertyDefinition.Name.Value, Helper.SignatureDefinition(currentUnit, propertyDefinition));
                return(sb.ToString());
            }
            return("!?!Error-TypeMember!?!");
        }
Exemplo n.º 10
0
        public void UpdateEvent(IEventDefinition def, IEventState state)
        {
            var ev = _events.Where(evm => evm.Definition.Id == def.Id).SingleOrDefault();

            if (ev == null)
            {
                _events.Insert(0, ev = new Event(def, this));
            }
            state.UpdateEvent(ev);

            if (!ev.IsActive)
            {
                _events.Remove(ev);
            }
            if (EventChanged != null)
            {
                EventChanged(ev.Definition, state);
            }
        }
Exemplo n.º 11
0
        private EventCommunicationSettings ComposeEventCommunicationSettings(IEventDefinition definition, bool forceExternal = false)
        {
            var settings = new EventCommunicationSettings
            {
                Deduplicate = true,
                Resilient   = true
            };

            var configuration = _communicationModelConfiguration.GetEventConfiguration(definition, null, forceExternal);

            configuration.Bind(settings);

            settings.CommunicationType =
                _communicationModelConfiguration
                .GetEventConfiguration(definition, CommunicationSectionName, forceExternal)
                .GetSection("type").Value;

            return(settings);
        }
Exemplo n.º 12
0
        private void WriteEventDefinition(IEventDefinition evnt)
        {
            // Adder and Remover modifiers should be same.
            IMethodDefinition accessor = evnt.Accessors.First().ResolvedMethod;

            if (!evnt.ContainingTypeDefinition.IsInterface)
            {
                WriteAttributes(evnt.Attributes);
                if (!accessor.IsExplicitInterfaceMethod())
                {
                    WriteVisibility(evnt.Visibility);
                }
                WriteMethodModifiers(accessor);
            }

            if (evnt.GetHiddenBaseEvent(_filter) != Dummy.Event)
            {
                WriteKeyword("new");
            }

            if (accessor.Attributes.HasIsReadOnlyAttribute() && (LangVersion >= LangVersion8_0))
            {
                WriteKeyword("readonly");
            }

            WriteKeyword("event");
            WriteTypeName(evnt.Type, evnt.Attributes);
            WriteIdentifier(evnt.Name);

            if (_forCompilation && !evnt.IsAbstract())
            {
                WriteSpace();
                WriteSymbol("{", addSpace: true);
                WriteEventBody("add");
                WriteEventBody("remove");
                WriteSymbol("}");
            }
            else
            {
                WriteSymbol(";");
            }
        }
Exemplo n.º 13
0
        private static void WriteMember(ITypeDefinitionMember member, TextWriter writer)
        {
            Contract.Requires(member != null);
            Contract.Requires(writer != null);

            IMethodDefinition method = member as IMethodDefinition;

            if (method != null)
            {
                writer.Write("M:");
                WriteMethod(method, writer);
                return;
            }

            IFieldDefinition field = member as IFieldDefinition;

            if (field != null)
            {
                writer.Write("F:");
                WriteField(field, writer);
                return;
            }

            IPropertyDefinition property = member as IPropertyDefinition;

            if (property != null)
            {
                writer.Write("P:");
                WriteProperty(property, writer);
                return;
            }

            IEventDefinition eventdef = member as IEventDefinition;

            if (eventdef != null)
            {
                writer.Write("E:");
                WriteEvent(eventdef, writer);
                return;
            }
            throw new NotImplementedException("missing case");
        }
        public bool TestGenericTypeEvent()
        {
            ITypeDefinition     assemType     = Helper.GetNamespaceType(this.ModuleReaderTest.AssemblyAssembly.UnitNamespaceRoot, this.Assem);
            IFieldDefinition    fld           = Helper.GetFieldNamed(assemType, this.Generic1);
            ITypeDefinition     type          = fld.Type.ResolvedType;
            IEventDefinition    eventDef      = Helper.GetEventNamed(type, this.GenericEvent);
            StringILDasmPaper   stringPaper   = new StringILDasmPaper(2);
            ILDasmPrettyPrinter prettyPrinter = new ILDasmPrettyPrinter(stringPaper, this.ModuleReaderTest.TestAssembly);

            prettyPrinter.EventDefinition(eventDef);
            string result =
                @".event public[MRW_Assembly]GenericDelegate`1<int32>GenericEvent
{
  .addon instance void[MRW_Assembly]Generic1`1<int32>::add_GenericEvent([MRW_Assembly]GenericDelegate`1<int32>)
  .removeon instance void[MRW_Assembly]Generic1`1<int32>::remove_GenericEvent([MRW_Assembly]GenericDelegate`1<int32>)
}
";

            return(result.Equals(stringPaper.Content));
        }
Exemplo n.º 15
0
        public override void TraverseChildren(IEventDefinition eventDefinition)
        {
            PrintAttributes(eventDefinition);
            PrintToken(CSharpToken.Indent);
            IMethodDefinition eventMeth = eventDefinition.Adder == null ?
                                          eventDefinition.Remover.ResolvedMethod :
                                          eventDefinition.Adder.ResolvedMethod;

            if (!eventDefinition.ContainingTypeDefinition.IsInterface &&
                IteratorHelper.EnumerableIsEmpty(MemberHelper.GetExplicitlyOverriddenMethods(eventMeth)))
            {
                PrintEventDefinitionVisibility(eventDefinition);
            }
            PrintMethodDefinitionModifiers(eventMeth);
            PrintToken(CSharpToken.Event);
            PrintEventDefinitionDelegateType(eventDefinition);
            PrintToken(CSharpToken.Space);
            PrintEventDefinitionName(eventDefinition);
            PrintToken(CSharpToken.Semicolon);
        }
Exemplo n.º 16
0
        internal static IEvent Convert(this IEventDefinition eventDefinition, ParsedStatenode source, ServiceDefinition serviceDefinition, int serviceIndex)
        {
            switch (eventDefinition)
            {
            case INamedDataEvent definition: return(new NamedDataEvent <object>(definition.Name, definition.Data));   // TODO: check this

            case INamedEvent definition: return(new NamedEvent(definition.Name));

            case ImmediateEventDefinition _: return(new ImmediateEvent());

            case DelayedEventDefinition definition: return(new DelayedEvent(source.Id, definition.Delay));

            case ServiceSuccessEventDefinition _: return(new ServiceSuccessEvent(serviceDefinition.GetId(source.Id, serviceIndex), null));

            case ServiceErrorEventDefinition _: return(new ServiceErrorEvent(serviceDefinition.GetId(source.Id, serviceIndex), null));

            case DoneEventDefinition _: return(new DoneEvent(source.Id));

            default: throw new Exception("it would be easier to interpret a Statechart if a proper event mapping is defined ;)");
            }
        }
Exemplo n.º 17
0
        public override Bpl.Variable CreateEventVariable(IEventDefinition e)
        {
            Bpl.Variable v;
            string       fieldname = MemberHelper.GetMemberSignature(e, NameFormattingOptions.DocumentationId);

            fieldname = TranslationHelper.TurnStringIntoValidIdentifier(fieldname);
            Bpl.IToken tok = e.Token();

            if (e.Adder.ResolvedMethod.IsStatic)
            {
                Bpl.Type       t      = this.sink.CciTypeToBoogie(e.Type.ResolvedType);
                Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, t);
                v = new Bpl.GlobalVariable(tok, tident);
            }
            else
            {
                Bpl.Type       t      = this.FieldType;
                Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, t);
                v = new Bpl.Constant(tok, tident, true);
            }
            return(v);
        }
        public void CanHandleEvent()
        {
            // refreshers.HandleEvents wants a UmbracoContext
            // which wants an HttpContext, which we build using a SimpleWorkerRequest
            // which requires these to be non-null
            var domain = Thread.GetDomain();

            if (domain.GetData(".appPath") == null)
            {
                domain.SetData(".appPath", "");
            }
            if (domain.GetData(".appVPath") == null)
            {
                domain.SetData(".appVPath", "");
            }

            // create some event definitions
            var definitions = new IEventDefinition[]
            {
                // works because that event definition maps to an empty handler
                new EventDefinition <IContentTypeService, SaveEventArgs <IContentType> >(null, Current.Services.ContentTypeService, new SaveEventArgs <IContentType>(Enumerable.Empty <IContentType>()), "Saved"),
            };

            var umbracoContextFactory = new UmbracoContextFactory(
                new TestUmbracoContextAccessor(),
                Mock.Of <IPublishedSnapshotService>(),
                new TestVariationContextAccessor(),
                new TestDefaultCultureAccessor(),
                TestObjects.GetUmbracoSettings(),
                TestObjects.GetGlobalSettings(),
                new UrlProviderCollection(Enumerable.Empty <IUrlProvider>()),
                new MediaUrlProviderCollection(Enumerable.Empty <IMediaUrlProvider>()),
                Mock.Of <IUserService>());

            // just assert it does not throw
            var refreshers = new DistributedCacheBinder(null, umbracoContextFactory, null);

            refreshers.HandleEvents(definitions);
        }
Exemplo n.º 19
0
    public override Bpl.Variable CreateEventVariable(IEventDefinition e) {
      Bpl.Variable v;
      string fieldName = MemberHelper.GetMemberSignature(e, NameFormattingOptions.DocumentationId);

      // HACK
      fieldName = fieldName.Replace("E:", "F:");

      fieldName = TranslationHelper.TurnStringIntoValidIdentifier(fieldName);
      Bpl.IToken tok = e.Token();
      Bpl.Type t = this.sink.CciTypeToBoogie(e.Type.ResolvedType);

      if (e.Adder.ResolvedMethod.IsStatic) {
        Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, t);
        v = new Bpl.GlobalVariable(tok, tident);
      }
      else {
        Bpl.Type mt = new Bpl.MapType(tok, new List<Bpl.TypeVariable>(), new List<Bpl.Type>(new Bpl.Type[] {this.RefType}), t);
        Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, mt);
        v = new Bpl.GlobalVariable(tok, tident);
      }
      return v;
    }
Exemplo n.º 20
0
        public void WriteMemberDeclaration(ITypeDefinitionMember member)
        {
            IMethodDefinition method = member as IMethodDefinition;

            if (method != null)
            {
                WriteMethodDefinition(method);
                return;
            }

            IPropertyDefinition property = member as IPropertyDefinition;

            if (property != null)
            {
                WritePropertyDefinition(property);
                return;
            }

            IEventDefinition evnt = member as IEventDefinition;

            if (evnt != null)
            {
                WriteEventDefinition(evnt);
                return;
            }

            IFieldDefinition field = member as IFieldDefinition;

            if (field != null)
            {
                WriteFieldDefinition(field);
                return;
            }

            _writer.Write("Unknown member definitions type {0}", member.ToString());
        }
Exemplo n.º 21
0
 public abstract Bpl.Variable CreateEventVariable(IEventDefinition e);
Exemplo n.º 22
0
 private bool Include(IEventDefinition evnt)
 {
     return(evnt.Accessors.Any(a => Include(a.ResolvedMethod)));
 }
Exemplo n.º 23
0
 public override void TraverseChildren(IEventDefinition eventDefinition)
 {
     MethodEnter(eventDefinition);
     base.TraverseChildren(eventDefinition);
     MethodExit();
 }
        public void Can_Find_All_Event_Handlers()
        {
            var definitions = new IEventDefinition[]
            {
                //I would test these but they are legacy events and we don't need them for deploy, when we migrate to new/better events we can wire up the check
                //Permission.New += PermissionNew;
                //Permission.Updated += PermissionUpdated;
                //Permission.Deleted += PermissionDeleted;
                //PermissionRepository<IContent>.AssignedPermissions += CacheRefresherEventHandler_AssignedPermissions;

                new EventDefinition <IApplicationTreeService, EventArgs>(null, ServiceContext.ApplicationTreeService, new EventArgs(), "Deleted"),
                new EventDefinition <IApplicationTreeService, EventArgs>(null, ServiceContext.ApplicationTreeService, new EventArgs(), "Updated"),
                new EventDefinition <IApplicationTreeService, EventArgs>(null, ServiceContext.ApplicationTreeService, new EventArgs(), "New"),

                new EventDefinition <ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "Deleted"),
                new EventDefinition <ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "New"),

                new EventDefinition <IUserService, SaveEventArgs <IUser> >(null, ServiceContext.UserService, new SaveEventArgs <IUser>(Enumerable.Empty <IUser>())),
                new EventDefinition <IUserService, DeleteEventArgs <IUser> >(null, ServiceContext.UserService, new DeleteEventArgs <IUser>(Enumerable.Empty <IUser>())),
                new EventDefinition <IUserService, SaveEventArgs <IUserGroup> >(null, ServiceContext.UserService, new SaveEventArgs <IUserGroup>(Enumerable.Empty <IUserGroup>())),
                new EventDefinition <IUserService, DeleteEventArgs <IUserGroup> >(null, ServiceContext.UserService, new DeleteEventArgs <IUserGroup>(Enumerable.Empty <IUserGroup>())),

                new EventDefinition <ILocalizationService, SaveEventArgs <IDictionaryItem> >(null, ServiceContext.LocalizationService, new SaveEventArgs <IDictionaryItem>(Enumerable.Empty <IDictionaryItem>())),
                new EventDefinition <ILocalizationService, DeleteEventArgs <IDictionaryItem> >(null, ServiceContext.LocalizationService, new DeleteEventArgs <IDictionaryItem>(Enumerable.Empty <IDictionaryItem>())),

                new EventDefinition <IDataTypeService, SaveEventArgs <IDataTypeDefinition> >(null, ServiceContext.DataTypeService, new SaveEventArgs <IDataTypeDefinition>(Enumerable.Empty <IDataTypeDefinition>())),
                new EventDefinition <IDataTypeService, DeleteEventArgs <IDataTypeDefinition> >(null, ServiceContext.DataTypeService, new DeleteEventArgs <IDataTypeDefinition>(Enumerable.Empty <IDataTypeDefinition>())),

                new EventDefinition <IFileService, SaveEventArgs <Stylesheet> >(null, ServiceContext.FileService, new SaveEventArgs <Stylesheet>(Enumerable.Empty <Stylesheet>())),
                new EventDefinition <IFileService, DeleteEventArgs <Stylesheet> >(null, ServiceContext.FileService, new DeleteEventArgs <Stylesheet>(Enumerable.Empty <Stylesheet>())),

                new EventDefinition <IDomainService, SaveEventArgs <IDomain> >(null, ServiceContext.DomainService, new SaveEventArgs <IDomain>(Enumerable.Empty <IDomain>())),
                new EventDefinition <IDomainService, DeleteEventArgs <IDomain> >(null, ServiceContext.DomainService, new DeleteEventArgs <IDomain>(Enumerable.Empty <IDomain>())),

                new EventDefinition <ILocalizationService, SaveEventArgs <ILanguage> >(null, ServiceContext.LocalizationService, new SaveEventArgs <ILanguage>(Enumerable.Empty <ILanguage>())),
                new EventDefinition <ILocalizationService, DeleteEventArgs <ILanguage> >(null, ServiceContext.LocalizationService, new DeleteEventArgs <ILanguage>(Enumerable.Empty <ILanguage>())),

                new EventDefinition <IContentTypeService, SaveEventArgs <IContentType> >(null, ServiceContext.ContentTypeService, new SaveEventArgs <IContentType>(Enumerable.Empty <IContentType>())),
                new EventDefinition <IContentTypeService, DeleteEventArgs <IContentType> >(null, ServiceContext.ContentTypeService, new DeleteEventArgs <IContentType>(Enumerable.Empty <IContentType>())),
                new EventDefinition <IContentTypeService, SaveEventArgs <IMediaType> >(null, ServiceContext.ContentTypeService, new SaveEventArgs <IMediaType>(Enumerable.Empty <IMediaType>())),
                new EventDefinition <IContentTypeService, DeleteEventArgs <IMediaType> >(null, ServiceContext.ContentTypeService, new DeleteEventArgs <IMediaType>(Enumerable.Empty <IMediaType>())),

                new EventDefinition <IMemberTypeService, SaveEventArgs <IMemberType> >(null, ServiceContext.MemberTypeService, new SaveEventArgs <IMemberType>(Enumerable.Empty <IMemberType>())),
                new EventDefinition <IMemberTypeService, DeleteEventArgs <IMemberType> >(null, ServiceContext.MemberTypeService, new DeleteEventArgs <IMemberType>(Enumerable.Empty <IMemberType>())),

                new EventDefinition <IFileService, SaveEventArgs <ITemplate> >(null, ServiceContext.FileService, new SaveEventArgs <ITemplate>(Enumerable.Empty <ITemplate>())),
                new EventDefinition <IFileService, DeleteEventArgs <ITemplate> >(null, ServiceContext.FileService, new DeleteEventArgs <ITemplate>(Enumerable.Empty <ITemplate>())),

                new EventDefinition <IMacroService, SaveEventArgs <IMacro> >(null, ServiceContext.MacroService, new SaveEventArgs <IMacro>(Enumerable.Empty <IMacro>())),
                new EventDefinition <IMacroService, DeleteEventArgs <IMacro> >(null, ServiceContext.MacroService, new DeleteEventArgs <IMacro>(Enumerable.Empty <IMacro>())),

                new EventDefinition <IMemberService, SaveEventArgs <IMember> >(null, ServiceContext.MemberService, new SaveEventArgs <IMember>(Enumerable.Empty <IMember>())),
                new EventDefinition <IMemberService, DeleteEventArgs <IMember> >(null, ServiceContext.MemberService, new DeleteEventArgs <IMember>(Enumerable.Empty <IMember>())),

                new EventDefinition <IMemberGroupService, SaveEventArgs <IMemberGroup> >(null, ServiceContext.MemberGroupService, new SaveEventArgs <IMemberGroup>(Enumerable.Empty <IMemberGroup>())),
                new EventDefinition <IMemberGroupService, DeleteEventArgs <IMemberGroup> >(null, ServiceContext.MemberGroupService, new DeleteEventArgs <IMemberGroup>(Enumerable.Empty <IMemberGroup>())),

                new EventDefinition <IMediaService, SaveEventArgs <IMedia> >(null, ServiceContext.MediaService, new SaveEventArgs <IMedia>(Enumerable.Empty <IMedia>())),
                new EventDefinition <IMediaService, DeleteEventArgs <IMedia> >(null, ServiceContext.MediaService, new DeleteEventArgs <IMedia>(Enumerable.Empty <IMedia>())),
                new EventDefinition <IMediaService, MoveEventArgs <IMedia> >(null, ServiceContext.MediaService, new MoveEventArgs <IMedia>(new MoveEventInfo <IMedia>(null, "", -1)), "Moved"),
                new EventDefinition <IMediaService, MoveEventArgs <IMedia> >(null, ServiceContext.MediaService, new MoveEventArgs <IMedia>(new MoveEventInfo <IMedia>(null, "", -1)), "Trashed"),
                new EventDefinition <IMediaService, RecycleBinEventArgs>(null, ServiceContext.MediaService, new RecycleBinEventArgs(Guid.NewGuid(), new Dictionary <int, IEnumerable <Property> >(), true)),

                new EventDefinition <IContentService, SaveEventArgs <IContent> >(null, ServiceContext.ContentService, new SaveEventArgs <IContent>(Enumerable.Empty <IContent>()), "Saved"),
                new EventDefinition <IContentService, SaveEventArgs <IContent> >(null, ServiceContext.ContentService, new SaveEventArgs <IContent>(Enumerable.Empty <IContent>()), "SavedBlueprint"),
                new EventDefinition <IContentService, DeleteEventArgs <IContent> >(null, ServiceContext.ContentService, new DeleteEventArgs <IContent>(Enumerable.Empty <IContent>()), "Deleted"),
                new EventDefinition <IContentService, DeleteEventArgs <IContent> >(null, ServiceContext.ContentService, new DeleteEventArgs <IContent>(Enumerable.Empty <IContent>()), "DeletedBlueprint"),
                new EventDefinition <IContentService, CopyEventArgs <IContent> >(null, ServiceContext.ContentService, new CopyEventArgs <IContent>(null, null, -1)),
                new EventDefinition <IContentService, MoveEventArgs <IContent> >(null, ServiceContext.ContentService, new MoveEventArgs <IContent>(new MoveEventInfo <IContent>(null, "", -1)), "Trashed"),
                new EventDefinition <IContentService, RecycleBinEventArgs>(null, ServiceContext.ContentService, new RecycleBinEventArgs(Guid.NewGuid(), new Dictionary <int, IEnumerable <Property> >(), true)),
                new EventDefinition <IContentService, PublishEventArgs <IContent> >(null, ServiceContext.ContentService, new PublishEventArgs <IContent>(Enumerable.Empty <IContent>()), "Published"),
                new EventDefinition <IContentService, PublishEventArgs <IContent> >(null, ServiceContext.ContentService, new PublishEventArgs <IContent>(Enumerable.Empty <IContent>()), "UnPublished"),

                new EventDefinition <IPublicAccessService, SaveEventArgs <PublicAccessEntry> >(null, ServiceContext.PublicAccessService, new SaveEventArgs <PublicAccessEntry>(Enumerable.Empty <PublicAccessEntry>())),
                new EventDefinition <IPublicAccessService, DeleteEventArgs <PublicAccessEntry> >(null, ServiceContext.PublicAccessService, new DeleteEventArgs <PublicAccessEntry>(Enumerable.Empty <PublicAccessEntry>())),

                new EventDefinition <IRelationService, SaveEventArgs <IRelationType> >(null, ServiceContext.RelationService, new SaveEventArgs <IRelationType>(Enumerable.Empty <IRelationType>())),
                new EventDefinition <IRelationService, DeleteEventArgs <IRelationType> >(null, ServiceContext.RelationService, new DeleteEventArgs <IRelationType>(Enumerable.Empty <IRelationType>())),

                new EventDefinition <IRelationService, SaveEventArgs <IRelationType> >(null, ServiceContext.RelationService, new SaveEventArgs <IRelationType>(Enumerable.Empty <IRelationType>())),
                new EventDefinition <IRelationService, DeleteEventArgs <IRelationType> >(null, ServiceContext.RelationService, new DeleteEventArgs <IRelationType>(Enumerable.Empty <IRelationType>())),
            };

            foreach (var definition in definitions)
            {
                var found = CacheRefresherEventHandler.FindHandler(definition);
                Assert.IsNotNull(found, "Couldn't find method for " + definition.EventName + " on " + definition.Sender.GetType());
            }
        }
Exemplo n.º 25
0
    private static void WriteEvent(IEventDefinition trigger, TextWriter writer)
    {
      Contract.Requires(trigger != null);
      Contract.Requires(writer != null);

      Contract.Assume(trigger.ContainingType != null, "lack of CCI2 contracts");
      Contract.Assume(trigger.Name != null, "lack of CCI2 contracts");
      Contract.Assume(trigger.Name.Value != null, "lack of CCI2 contracts");

      WriteType(trigger.ContainingType, writer);

      var name = SanitizeMemberName(trigger.Name.Value);

      writer.Write(".{0}", name);

    }
Exemplo n.º 26
0
 public static IEventDefinition GetEvent(INamedTypeDefinition type, IEventDefinition evnt)
 {
     foreach (ITypeDefinitionMember member in type.GetMembersNamed(evnt.Name, false))
     {
         IEventDefinition evntDef = member as IEventDefinition;
         if (evntDef != null)
             return evntDef;
     }
     return null;
 }
 public void EventDefinition(IEventDefinition eventDefinition) {
   this.ILDasmPaper.Directive(".event");
   this.TypeMemberAccess(eventDefinition.Visibility);
   if (eventDefinition.IsSpecialName)
     this.ILDasmPaper.Keyword("specialname");
   if (eventDefinition.IsRuntimeSpecial)
     this.ILDasmPaper.Keyword("rtspecialname");
   this.TypeReference(eventDefinition.Type);
   this.ILDasmPaper.Identifier(eventDefinition.Name.Value);
   this.ILDasmPaper.NewLine();
   this.ILDasmPaper.OpenBlock();
   this.CustomAttributes(eventDefinition.Attributes);
   this.ILDasmPaper.Directive(".addon");
   this.MethodReference(eventDefinition.Adder);
   this.ILDasmPaper.NewLine();
   this.ILDasmPaper.Directive(".removeon");
   this.MethodReference(eventDefinition.Remover);
   this.ILDasmPaper.NewLine();
   if (eventDefinition.Caller != null) {
     this.ILDasmPaper.Directive(".fire");
     this.MethodReference(eventDefinition.Caller);
     this.ILDasmPaper.NewLine();
   }
   foreach (IMethodDefinition methodDef in eventDefinition.Accessors) {
     if (methodDef == eventDefinition.Adder) continue;
     if (methodDef == eventDefinition.Remover) continue;
     if (methodDef == eventDefinition.Caller) continue;
     this.ILDasmPaper.Directive(".other");
     this.MethodReference(methodDef);
     this.ILDasmPaper.NewLine();
   }
   this.ILDasmPaper.CloseBlock();
 }
Exemplo n.º 28
0
 /// <summary>
 /// Traverses the event definition.
 /// </summary>
 public void Traverse(IEventDefinition eventDefinition)
 {
     Contract.Requires(eventDefinition != null);
       //specialized events are simply traversed as if they were normal events
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(eventDefinition);
       if (this.stopTraversal) return;
       this.TraverseChildren(eventDefinition);
       if (this.stopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(eventDefinition);
 }
Exemplo n.º 29
0
 public void Visit(IEventDefinition eventDefinition)
 {
     this.traverser.Traverse(eventDefinition);
 }
 private EventDefinitionChild(IEventDefinition @event) : base(@event.EventType, @event.AssignRecursively, @event.EventOccurredHandler)
 {
 }
Exemplo n.º 31
0
      /// <summary>
      /// Performs some computation with the given event definition.
      /// </summary>
      public void Visit(IEventDefinition eventDefinition) {
        this.Visit((ITypeDefinitionMember)eventDefinition);

        if (eventDefinition.Adder is Dummy)
          this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Adder");
        else if (!IteratorHelper.EnumerableContains(eventDefinition.Accessors, eventDefinition.Adder))
          this.ReportError(MetadataError.AccessorListInconsistent, eventDefinition, "Adder");
        if (eventDefinition.Caller != null)
          if (eventDefinition.Caller is Dummy)
            this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Caller");
          else if (!IteratorHelper.EnumerableContains(eventDefinition.Accessors, eventDefinition.Caller))
            this.ReportError(MetadataError.AccessorListInconsistent, eventDefinition, "Caller");
        if (eventDefinition.Remover is Dummy)
          this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Remover");
        else if (!IteratorHelper.EnumerableContains(eventDefinition.Accessors, eventDefinition.Remover))
          this.ReportError(MetadataError.AccessorListInconsistent, eventDefinition, "Remover");
        if (eventDefinition.IsRuntimeSpecial && !eventDefinition.IsSpecialName)
          this.ReportError(MetadataError.RuntimeSpecialMustAlsoBeSpecialName, eventDefinition);
        if (eventDefinition.Type != null) {
          if (eventDefinition.Type is Dummy)
            this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Type");
          else {
            var etype = eventDefinition.Type.ResolvedType;
            if (!(etype is Dummy) && (etype.IsInterface || etype.IsValueType))
              this.ReportError(MetadataError.EventTypeMustBeClass, eventDefinition.Type, eventDefinition);
          }
        }
        foreach (var a in eventDefinition.Accessors) {
          // if an accessor meets the naming conventions, then it should be the accessor it claims to be
          var methodDefinition = a.ResolvedMethod;
          if (MemberHelper.IsAdder(methodDefinition) && a != eventDefinition.Adder)
            this.ReportError(MetadataError.EventPropertyNamingPatternWarning, methodDefinition);
          if (MemberHelper.IsRemover(methodDefinition) && a != eventDefinition.Remover)
            this.ReportError(MetadataError.EventPropertyNamingPatternWarning, methodDefinition);
          if (MemberHelper.IsCaller(methodDefinition) && a != eventDefinition.Caller)
            this.ReportError(MetadataError.EventPropertyNamingPatternWarning, methodDefinition);
        }
      }
Exemplo n.º 32
0
 public void Visit(IEventDefinition eventDefinition)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 33
0
        public override void TraverseChildren(IEventDefinition eventDefinition)
{ MethodEnter(eventDefinition);
            base.TraverseChildren(eventDefinition);
     MethodExit();   }
Exemplo n.º 34
0
 public virtual void onMetadataElement(IEventDefinition eventDefinition)
 {
 }
Exemplo n.º 35
0
 internal abstract bool TryGetEventHandle(IEventDefinition def, out EventHandle handle);
Exemplo n.º 36
0
 protected override uint GetEventDefIndex(IEventDefinition def)
 {
     return(this.eventDefs[def]);
 }
Exemplo n.º 37
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Performs some computation with the given event definition.
 /// </summary>
 /// <param name="eventDefinition"></param>
 public virtual void Visit(IEventDefinition eventDefinition)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(eventDefinition);
       this.Visit(eventDefinition.Accessors);
       this.Visit(eventDefinition.Type);
       //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count.
       this.path.Pop();
 }
Exemplo n.º 38
0
        public static bool IsEventVirtual(IEventDefinition eventDef)
        {
            if (Util.ContainingTypeDefinition(eventDef).IsInterface)
                return true;

            foreach (IMethodDefinition method in eventDef.Accessors)
            {
                return ResolveMethodThrowing(method).IsVirtual;
            }

            throw new Exception(String.Format("Event {0} has no accessors. Cannot determine whether it is virtual or not", eventDef.ToString()));
        }
Exemplo n.º 39
0
 /// <summary>
 /// Traverses the children of the event definition.
 /// </summary>
 public virtual void TraverseChildren(IEventDefinition eventDefinition)
 {
     Contract.Requires(eventDefinition != null);
       this.TraverseChildren((ITypeDefinitionMember)eventDefinition);
       if (this.stopTraversal) return;
       this.Traverse(eventDefinition.Accessors);
       if (this.stopTraversal) return;
       this.Traverse(eventDefinition.Adder);
       if (this.stopTraversal) return;
       if (eventDefinition.Caller != null) {
     this.Traverse(eventDefinition.Caller);
     if (this.stopTraversal) return;
       }
       this.Traverse(eventDefinition.Remover);
       if (this.stopTraversal) return;
       this.Traverse(eventDefinition.Type);
 }
Exemplo n.º 40
0
 public override void Visit(IEventDefinition @event)
 {
     Emit(MemberHelper.GetMemberSignature(@event, NameFormattingOptions.Signature));
     EmitNewLine();
 }
Exemplo n.º 41
0
 /// <summary>
 /// Performs some computation with the given event definition.
 /// </summary>
 public virtual void Visit(IEventDefinition eventDefinition)
 {
     this.Visit((ITypeDefinitionMember)eventDefinition);
 }
Exemplo n.º 42
0
 public virtual void Visit(IEventDefinition eventDefinition)
 {
     this.Visit(eventDefinition.Accessors);
     this.Visit(eventDefinition.GetType(Context));
 }
Exemplo n.º 43
0
 public bool Apply(IEventDefinition def)
 {
     return(true);
 }
Exemplo n.º 44
0
 public virtual void Visit(IEventDefinition eventDefinition)
 {
     this.Visit(eventDefinition.Accessors);
     this.Visit(eventDefinition.GetType(Context));
 }
Exemplo n.º 45
0
 public override void TraverseChildren(IEventDefinition eventDefinition)
 {
     if (!_filter.Include(eventDefinition))
         return;
     base.TraverseChildren(eventDefinition);
 }
Exemplo n.º 46
0
 protected override EventDefinitionHandle GetEventDefinitionHandle(IEventDefinition def)
 {
     return(MetadataTokens.EventDefinitionHandle(_eventDefs[def]));
 }
Exemplo n.º 47
0
 public override void Visit(IEventDefinition @event)
 {
     Emit(MemberHelper.GetMemberSignature(@event, NameFormattingOptions.Signature));
     EmitNewLine();
 }
Exemplo n.º 48
0
    private void CheckSurface(IEventDefinition Event, IEnumerable<ITypeDefinitionMember> events) {
      Contract.Requires(Event != null);
      Contract.Requires(events != null);

      foreach (var c in events) {
        var candidate = c as IEventDefinition;
        if (candidate == null) continue;
        // What should we check?
        if (candidate.Visibility != Event.Visibility) {
          Error("Event {0} has different visibility: contract: {1}, original: {2}", MemberHelper.GetMemberSignature(Event, NameFormattingOptions.None),
            Event.Visibility, candidate.Visibility);
        }
        return; // found
      }
      if (Event.Adder != null && (IsImplementingInvisibleInterface(Event.Adder.ResolvedMethod) || Event.Adder.ResolvedMethod.Visibility == TypeMemberVisibility.Private) ||
          Event.Remover != null && (IsImplementingInvisibleInterface(Event.Remover.ResolvedMethod) || Event.Adder.ResolvedMethod.Visibility == TypeMemberVisibility.Private))
      {
        Warning("Event {0} only appears in contract reference assembly, but is invisible, so okay", MemberHelper.GetMemberSignature(Event, NameFormattingOptions.None));
      }
      else
      {
        Error("Event {0} only appears in contract reference assembly", MemberHelper.GetMemberSignature(Event, NameFormattingOptions.None));
      }
    }
Exemplo n.º 49
0
 /// <summary>
 /// Performs some computation with the given event definition.
 /// </summary>
 public void Visit(IEventDefinition eventDefinition)
 {
     this.Visit((ITypeDefinitionMember)eventDefinition);
     if (eventDefinition.Adder is Dummy)
       this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Adder");
     if (eventDefinition.Caller != null && eventDefinition.Caller is Dummy)
       this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Caller");
     if (eventDefinition.Remover is Dummy)
       this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Remover");
     if (eventDefinition.IsRuntimeSpecial && !eventDefinition.IsSpecialName)
       this.ReportError(MetadataError.RuntimeSpecialMustAlsoBeSpecialName, eventDefinition);
     if (eventDefinition.Type != null) {
       if (eventDefinition.Type is Dummy)
     this.ReportError(MetadataError.IncompleteNode, eventDefinition, "Type");
       else {
     var etype = eventDefinition.Type.ResolvedType;
     if (etype != Dummy.Type && (etype.IsInterface || etype.IsValueType))
       this.ReportError(MetadataError.EventTypeMustBeClass, eventDefinition.Type, eventDefinition);
       }
     }
 }
Exemplo n.º 50
0
 public EventReference(EventId id, IEventDefinition definition, IMethodInvoker invoker)
 {
     Id         = id;
     Definition = definition;
     _invoker   = invoker;
 }
Exemplo n.º 51
0
 public override void Visit(IEventDefinition evnt)
 {
     if (IsMemberExternallyVisible2(evnt))
     {
         // Recursion
         Visit(evnt.Type);
     }
 }
Exemplo n.º 52
0
 public override void Visit(IEventDefinition eventDefinition)
 {
     this.typeReferenceNeedsToken = true;
     this.Visit(eventDefinition.GetType(Context));
     Debug.Assert(!this.typeReferenceNeedsToken);
 }
 public override void TraverseChildren(IEventDefinition eventDefinition)
 {
     _definitionStack.Push(eventDefinition);
     base.TraverseChildren(eventDefinition);
     _definitionStack.Pop();
 }
Exemplo n.º 54
0
 public override void Visit(IEventDefinition eventDefinition)
 {
     this.typeReferenceNeedsToken = true;
     this.Visit(eventDefinition.GetType(Context));
     Debug.Assert(!this.typeReferenceNeedsToken);
 }
Exemplo n.º 55
0
 public virtual void onMetadataElement(IEventDefinition eventDefinition) { }
Exemplo n.º 56
0
 public UnguardedTransition(IEventDefinition @event, IEnumerable <Target> targets, IEnumerable <OneOf <ActionDefinition, ContextActionDefinition> > actions)
 {
     Event   = @event;
     Targets = targets;
     Actions = actions;
 }
Exemplo n.º 57
0
        internal static MethodInfo FindHandler(IEventDefinition eventDefinition)
        {
            var name = eventDefinition.Sender.GetType().Name + "_" + eventDefinition.EventName;

            return(FoundHandlers.GetOrAdd(eventDefinition, _ => CandidateHandlers.Value.FirstOrDefault(x => x.Name == name)));
        }
Exemplo n.º 58
0
 /// <summary>
 /// Performs some computation with the given event definition.
 /// </summary>
 public virtual void Visit(IEventDefinition eventDefinition)
 {
 }
Exemplo n.º 59
0
 public static EventDefinition FindMatchingEvent(TypeDefinition tdef, IEventDefinition item)
 {
     return(tdef.Events.FirstOrDefault(p => p.ToString() == item.ToString()));
 }
 /// <summary>
 /// Rewrites the given event definition.
 /// </summary>
 public virtual IEventDefinition Rewrite(IEventDefinition eventDefinition)
 {
     return eventDefinition;
 }