private static IEnumerable <PartDefinition> CreatePluginTypes()
        {
            var plugins = new List <PartDefinition>
            {
                new PartDefinition
                {
                    Identity = TypeIdentity.CreateDefinition(typeof(ActionOnMethod)),
                    Exports  = new List <SerializableExportDefinition>
                    {
                        TypeBasedExportDefinition.CreateDefinition("ActionExport", typeof(ActionOnMethod))
                    },
                    Imports = new List <SerializableImportDefinition>(),
                    Actions = new List <ScheduleActionDefinition>
                    {
                        ScheduleActionDefinition.CreateDefinition(
                            "ActionMethod",
                            typeof(ActionOnMethod).GetMethod("ActionMethod"))
                    },
                    Conditions = new List <ScheduleConditionDefinition>(),
                },
                new PartDefinition
                {
                    Identity = TypeIdentity.CreateDefinition(typeof(ConditionOnMethod)),
                    Exports  = new List <SerializableExportDefinition>
                    {
                        TypeBasedExportDefinition.CreateDefinition("ConditionOnMethodExport", typeof(ConditionOnMethod))
                    },
                    Imports    = new List <SerializableImportDefinition>(),
                    Actions    = new List <ScheduleActionDefinition>(),
                    Conditions = new List <ScheduleConditionDefinition>
                    {
                        MethodBasedScheduleConditionDefinition.CreateDefinition(
                            "OnMethod",
                            typeof(ConditionOnMethod).GetMethod("ConditionMethod"))
                    },
                },
                new PartDefinition
                {
                    Identity = TypeIdentity.CreateDefinition(typeof(ConditionOnProperty)),
                    Exports  = new List <SerializableExportDefinition>
                    {
                        TypeBasedExportDefinition.CreateDefinition("ConditionOnPropertyExport", typeof(ConditionOnProperty))
                    },
                    Imports    = new List <SerializableImportDefinition>(),
                    Actions    = new List <ScheduleActionDefinition>(),
                    Conditions = new List <ScheduleConditionDefinition>
                    {
                        PropertyBasedScheduleConditionDefinition.CreateDefinition(
                            "OnProperty",
                            typeof(ConditionOnProperty).GetProperty("ConditionProperty"))
                    },
                },
                new PartDefinition
                {
                    Identity = TypeIdentity.CreateDefinition(typeof(ExportOnProperty)),
                    Exports  = new List <SerializableExportDefinition>
                    {
                        PropertyBasedExportDefinition.CreateDefinition(
                            typeof(IExportingInterface).FullName,
                            typeof(ExportOnProperty).GetProperty("ExportingProperty"))
                    },
                    Imports    = new List <SerializableImportDefinition>(),
                    Actions    = new List <ScheduleActionDefinition>(),
                    Conditions = new List <ScheduleConditionDefinition>(),
                },
                new PartDefinition
                {
                    Identity = TypeIdentity.CreateDefinition(typeof(ImportOnProperty)),
                    Exports  = new List <SerializableExportDefinition>
                    {
                        TypeBasedExportDefinition.CreateDefinition(typeof(ImportOnProperty).FullName, typeof(ImportOnProperty))
                    },
                    Imports = new List <SerializableImportDefinition>
                    {
                        PropertyBasedImportDefinition.CreateDefinition(
                            typeof(IExportingInterface).FullName,
                            TypeIdentity.CreateDefinition(typeof(IExportingInterface)),
                            ImportCardinality.ExactlyOne,
                            false,
                            CreationPolicy.Shared,
                            typeof(ImportOnProperty).GetProperty("ImportingProperty"))
                    },
                    Actions    = new List <ScheduleActionDefinition>(),
                    Conditions = new List <ScheduleConditionDefinition>(),
                }
            };

            return(plugins);
        }
        private PartDefinition ExtractActionsAndConditions(Type type, PartDefinition part, Func <Type, TypeIdentity> createTypeIdentity)
        {
            var actions    = new List <ScheduleActionDefinition>();
            var conditions = new List <ScheduleConditionDefinition>();

            foreach (var method in type.GetMethods())
            {
                if (method.ReturnType == typeof(void) && !method.GetParameters().Any())
                {
                    var actionAttribute = method.GetCustomAttribute <ScheduleActionAttribute>(true);
                    if (actionAttribute != null)
                    {
                        var actionDefinition = ScheduleActionDefinition.CreateDefinition(
                            actionAttribute.Name,
                            method,
                            createTypeIdentity);
                        actions.Add(actionDefinition);

                        m_Logger.Log(
                            LevelToLog.Info,
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Discovered action: {0}",
                                actionDefinition));
                    }

                    continue;
                }

                if (method.ReturnType == typeof(bool) && !method.GetParameters().Any())
                {
                    var conditionAttribute = method.GetCustomAttribute <ScheduleConditionAttribute>(true);
                    if (conditionAttribute != null)
                    {
                        var conditionDefinition = MethodBasedScheduleConditionDefinition.CreateDefinition(
                            conditionAttribute.Name,
                            method,
                            createTypeIdentity);
                        conditions.Add(conditionDefinition);

                        m_Logger.Log(
                            LevelToLog.Info,
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Discovered condition: {0}",
                                conditionDefinition));
                    }
                }
            }

            foreach (var property in type.GetProperties())
            {
                if (property.PropertyType == typeof(bool))
                {
                    var conditionAttribute = property.GetCustomAttribute <ScheduleConditionAttribute>(true);
                    if (conditionAttribute != null)
                    {
                        var conditionDefinition = PropertyBasedScheduleConditionDefinition.CreateDefinition(
                            conditionAttribute.Name,
                            property,
                            createTypeIdentity);
                        conditions.Add(conditionDefinition);

                        m_Logger.Log(
                            LevelToLog.Info,
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Discovered condition: {0}",
                                conditionDefinition));
                    }
                }
            }

            if (actions.Count > 0 || conditions.Count > 0)
            {
                part.Actions    = actions;
                part.Conditions = conditions;
            }

            return(part);
        }