Exemplo n.º 1
0
        internal void ValidateWizardIdIsValid(ValidationContext context, MenuSettings settings)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => settings, settings);

            try
            {
                if (settings.WizardId != Guid.Empty)
                {
                    if (!settings.Owner.GetAutomationSettings <IWizardSettings>().Any(c => c.Id.Equals(settings.WizardId)))
                    {
                        if (settings.Owner.IsInheritedFromBase &&
                            SettingsValidationHelper.TryToFixId <IWizardSettings>(settings.Store, settings.Owner, settings.WizardId, id => settings.WizardId = id))
                        {
                            return;
                        }

                        context.LogError(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.Validate_WizardIsNotValid),
                            Resources.Validate_WizardIsNotValidCode, settings.Extends);
                    }
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Properties.Resources.ValidationMethodFailed_Error,
                    Reflector <MenuSettingsValidations> .GetMethod(n => n.ValidateWizardIdIsValid(null, null)).Name);

                throw;
            }
        }
        internal void ValidateCommandIdIsValid(ValidationContext context)
        {
            try
            {
                if (this.CommandId != Guid.Empty)
                {
                    if (!this.Owner.GetAutomationSettings <ICommandSettings>().Any(c => c.Id.Equals(this.CommandId)))
                    {
                        if (this.Owner.IsInheritedFromBase &&
                            SettingsValidationHelper.TryToFixId <ICommandSettings>(this.Store, this.Owner, this.CommandId, id => this.CommandId = id))
                        {
                            return;
                        }

                        context.LogError(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.Validate_CommandIsNotValid),
                            Resources.Validate_CommandIsNotValidCode, this.Extends);
                    }
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Properties.Resources.ValidationMethodFailed_Error,
                    Reflector <TemplateSettings> .GetMethod(n => n.ValidateCommandIdIsValid(context)).Name);

                throw;
            }
        }