Пример #1
0
        private static void RemoveDeletedProperties(List <CustomProperty> propCollection, Type customActivityType, IServiceProvider serviceProvider)
        {
            //
            IMemberCreationService memberCreationService = serviceProvider.GetService(typeof(IMemberCreationService)) as IMemberCreationService;

            if (memberCreationService == null)
            {
                throw new Exception(SR.GetString(SR.General_MissingService, typeof(IMemberCreationService).FullName));
            }

            PropertyInfo[] properties = customActivityType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo property in properties)
            {
                bool found = false;
                foreach (CustomProperty customProperty in propCollection)
                {
                    if (property.Name == customProperty.oldPropertyName &&
                        property.PropertyType.FullName == customProperty.oldPropertyType)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    memberCreationService.RemoveProperty(customActivityType.FullName, property.Name, property.PropertyType);
                }
            }

            EventInfo[] events = customActivityType.GetEvents(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);
            foreach (EventInfo evtInfo in events)
            {
                bool found = false;
                foreach (CustomProperty customProperty in propCollection)
                {
                    if (evtInfo.Name == customProperty.oldPropertyName &&
                        evtInfo.EventHandlerType.FullName == customProperty.oldPropertyType)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found && evtInfo.Name != null && evtInfo.EventHandlerType != null)
                {
                    memberCreationService.RemoveEvent(customActivityType.FullName, evtInfo.Name, evtInfo.EventHandlerType);
                }
            }
        }
        private static void RemoveDeletedProperties(List <CustomProperty> propCollection, System.Type customActivityType, IServiceProvider serviceProvider)
        {
            IMemberCreationService service = serviceProvider.GetService(typeof(IMemberCreationService)) as IMemberCreationService;

            if (service == null)
            {
                throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(IMemberCreationService).FullName }));
            }
            foreach (PropertyInfo info in customActivityType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                bool flag = false;
                foreach (CustomProperty property in propCollection)
                {
                    if ((info.Name == property.oldPropertyName) && (info.PropertyType.FullName == property.oldPropertyType))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    service.RemoveProperty(customActivityType.FullName, info.Name, info.PropertyType);
                }
            }
            foreach (EventInfo info2 in customActivityType.GetEvents(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                bool flag2 = false;
                foreach (CustomProperty property2 in propCollection)
                {
                    if ((info2.Name == property2.oldPropertyName) && (info2.EventHandlerType.FullName == property2.oldPropertyType))
                    {
                        flag2 = true;
                        break;
                    }
                }
                if ((!flag2 && (info2.Name != null)) && (info2.EventHandlerType != null))
                {
                    service.RemoveEvent(customActivityType.FullName, info2.Name, info2.EventHandlerType);
                }
            }
        }