Esempio n. 1
0
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            int numberOfFileNames = settings.FileNames.Count;

            if (numberOfFileNames < 3)
            {
                throw new ApplicationException("The name of the XSLT file should be set.");
            }

            this.processor.XslFileFullName = settings.FileNames[2];

            await this.processor.Process(document);

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Wrapper constructor
        /// </summary>
        /// <param name="internalSettings">Settings to be wrapped</param>
        public CommandSettingsDelegator(ICommandSettings internalSettings)
        {
            Guard.NotNull(() => internalSettings, internalSettings);

            this.internalSettings             = internalSettings;
            internalSettings.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(internalSettings_PropertyChanged);
        }
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            int numberOfFileNames = settings.FileNames.Count;

            if (numberOfFileNames < 2)
            {
                throw new ApplicationException("Output file name should be set.");
            }

            if (numberOfFileNames < 3)
            {
                throw new ApplicationException("The file path to xml-file-to-clone should be set.");
            }

            string sourceFileName = settings.FileNames[2];
            var    sourceDocument = await this.ReadSourceDocument(sourceFileName);

            return(await this.cloner.Clone(document, sourceDocument));
        }
Esempio n. 4
0
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            int numberOfFileNames = settings.FileNames.Count;

            if (numberOfFileNames < 3)
            {
                throw new ApplicationException("The query file name should be set.");
            }

            string queryFileName = settings.FileNames[2];

            var processedContent = await this.queryReplacer.Replace(document.Xml, queryFileName);

            document.Xml = processedContent;

            return(true);
        }
        /// <summary>
        /// Called when validations are needed for the command
        /// </summary>
        /// <param name="context">Validation Context where to add validation errors</param>
        /// <param name="settingsElement">The settings element in the model being validated</param>
        /// <param name="settings">Settings for the command</param>
        public void Validate(Microsoft.VisualStudio.Modeling.Validation.ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
        {
            try
            {
                Guard.NotNull(() => settings, settings);

                var templateValidator = new TemplateValidator(settings.Name,
                        new UnfoldVsTemplateCommand.UnfoldVsTemplateSettings
                        {
                            SanitizeName = settings.GetPropertyValue<bool>(Reflector<UnfoldVsTemplateCommand>.GetPropertyName(u => u.SanitizeName)),
                            SyncName = settings.GetPropertyValue<bool>(Reflector<UnfoldVsTemplateCommand>.GetPropertyName(u => u.SyncName)),
                            TemplateAuthoringUri = settings.GetPropertyValue<string>(Reflector<UnfoldVsTemplateCommand>.GetPropertyName(u => u.TemplateAuthoringUri)),
                            TemplateUri = settings.GetPropertyValue<string>(Reflector<UnfoldVsTemplateCommand>.GetPropertyName(u => u.TemplateUri)),
                            SettingsElement = settingsElement,
                            OwnerElement = settings.Owner,
                        }, context, ((ModelElement)settings).Store);
                templateValidator.ValidateCommandSettings(tracer);
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Resources.ValidationMethodFailed_Error,
                    Reflector<TemplateValidator>.GetMethod(n => n.ValidateCommandSettings(null)).Name);

                throw;
            }
        }
Esempio n. 6
0
        private void CallBack(System.Object sender, Telegram.Bot.Args.CallbackQueryEventArgs e)
        {
            if (commands.Any(c => c.Equals(e.CallbackQuery.Data)))                               // проверка есть ли команда в списке
            {
                ICommand Command = commands.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data)); // вытягиваем класс
                Command.Execute(BotClient, e.CallbackQuery, pairs, baseContext);
            }
            else if (calendars.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                if (!keyValues.Any(c => c.Key == e.CallbackQuery.From.Id) || keyValues.Count == 0)
                {
                    keyValues.Add(e.CallbackQuery.From.Id, new Calendar());
                }

                ICalendar Command = calendars.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));                 // вытягиваем класс
                if (Command.Name == "BackToStart" || Command.Name == "BackToCalendar" ||
                    Command.Name == "Calendar" || Command.Name == "<" ||
                    Command.Name == ">")
                {
                    Command.Execute(BotClient, e.CallbackQuery, keyValues, baseContext);
                }
                else
                {
                    Command.Execute(BotClient, e.CallbackQuery, eventCals, baseContext);
                }
            }
            else if (commandSettings.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                ICommandSettings ISettings = commandSettings.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));
                ISettings.Execute(BotClient, e.CallbackQuery, iSettings, baseContext);
            }
            else if (commandiOrganizer.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                IOrganizer iTOrganizer = commandiOrganizer.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));
                iTOrganizer.Execute(BotClient, e.CallbackQuery, iOrganizer, baseContext);
            }
            else
            {
                User users = baseContext._User.Where(p => p.ID == e.CallbackQuery.From.Id).FirstOrDefault();
                if (users.Work / 100 <= 22)
                {
                    ChouseItem chouseItem = new ChouseItem();
                    chouseItem.Execute(BotClient, e.CallbackQuery, pairs, baseContext);
                }
                else if (users.Work / 100 == 30)
                {
                    ChouseData chouseData = new ChouseData();
                    chouseData.Execute(BotClient, e.CallbackQuery, baseContext);
                }
                else if (users.Work % 100 >= 26 && users.Work % 100 <= 28)
                {
                    ShowItemCalndar showItemCalnder = new ShowItemCalndar();
                    showItemCalnder.Execute(BotClient, e.CallbackQuery, eventCals, baseContext);
                }
            }
        }
Esempio n. 7
0
        public CommandEditorDialog([NotNull] Command command) : base(command)
        {
            _command = command;

            var ext = command.GetModExtension <CommandExtension>();

            if (ext?.SettingsHandler != null)
            {
                _settings = Activator.CreateInstance(ext.SettingsHandler) as ICommandSettings;
            }
        }
        private void SetReferencesOutputFileName(IDocument document, ICommandSettings settings)
        {
            if (string.IsNullOrWhiteSpace(settings.OutputFileName))
            {
                return;
            }

            string referencesFileName = document.GenerateFileNameFromDocumentId();

            var outputDirectoryName = Path.GetDirectoryName(settings.OutputFileName);

            this.tagger.ReferencesGetReferencesXmlPath = Path.Combine(outputDirectoryName, $"{referencesFileName}-references.{FileConstants.XmlFileExtension}");
        }
Esempio n. 9
0
        /// <summary>
        /// Sets the value of the property.
        /// </summary>
        public static void SetPropertyValue <T>(this ICommandSettings settings, string propertyName, T value)
        {
            Guard.NotNull(() => settings, settings);
            Guard.NotNullOrEmpty(() => propertyName, propertyName);

            var converter = TypeDescriptor.GetConverter(typeof(T));
            var prop      = (IPropertyBindingSettings)settings.Properties.FirstOrDefault(p => p.Name == propertyName);

            if (prop != null)
            {
                prop.Value = converter.ConvertToString(value);
            }
        }
Esempio n. 10
0
        public Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(this.generator.Generate(document));
        }
Esempio n. 11
0
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(await this.formatter.Format(document));
        }
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(await this.parser.Parse(document.XmlDocument.DocumentElement));
        }
Esempio n. 13
0
        public Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.provider.RenumerateFootNotes(document);
            return(Task.FromResult <object>(true));
        }
        public Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.SetReferencesOutputFileName(document, settings);

            return(this.tagger.Tag(document.XmlDocument.DocumentElement));
        }
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var result = await this.validator.Validate(document, this.reporter);

            await this.reporter.MakeReport();

            return(result);
        }
Esempio n. 16
0
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var result = await this.tagger.Tag(document);

            await this.documentNormalizer.NormalizeToSystem(document);

            return(result);
        }
Esempio n. 17
0
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var result = await this.parser.Parse(document.XmlDocument.DocumentElement);

            await this.PrintNonParsedTaxa(document.XmlDocument);

            return(result);
        }
        public async Task <object> Run(IDocument document, ICommandSettings settings)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var context = document.XmlDocument.DocumentElement;

            if (settings.ExtractTaxa)
            {
                var data = await this.harvester.Harvest(context);

                this.BuildReport(Messages.ExtractAllTaxaMessage, data);
            }
            else
            {
                if (settings.ExtractLowerTaxa)
                {
                    var data = await this.harvester.HarvestLowerTaxa(context);

                    this.BuildReport(Messages.ExtractLowerTaxaMessage, data);
                }

                if (settings.ExtractHigherTaxa)
                {
                    var data = await this.harvester.HarvestHigherTaxa(context);

                    this.BuildReport(Messages.ExtractHigherTaxaMessage, data);
                }
            }

            await this.reporter.MakeReport();

            return(true);
        }
        /// <summary>
        /// Called to validate the design-time settings on the custom command
        /// </summary>
        /// <param name="context">Validation context to be assigned errors and warnings.</param>
        /// <param name="settingsElement">The settings element in the model being validated</param>
        /// <param name="settings">Settings for the command</param>
        public void Validate(Microsoft.VisualStudio.Modeling.Validation.ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
        {
            try
            {
                // TODO: Validate a setting on the command
                // Note that a propValue1 may still not have a value if it was configured with a ValueProvider.
                //var propValue1 = settings.GetOrCreatePropertyValue(Reflector<ShowElementTypePicker>.GetPropertyName(s => s.AProperty), String.Empty);
                //if (String.IsNullOrEmpty(propValue1))
                //{
                //    context.LogError(String.Format(CultureInfo.CurrentCulture,
                //        "{0} is configured with an invalid value for its 'AProperty'. This value must be valid.", settingsElement.Name), "1", settingsElement as ModelElement);
                //}

            }
            catch (Exception ex)
            {
                // Make error trace statement for the failure
                tracer.Error(
                    "Validation rule ShowElementTypePickerValidation unexpectedly failed, error was: '{0}'", ex.Message);
                throw;
            }
        }
 private static void LogSolutionItemNotFound(ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
 {
     if (!settings.Owner.Root.PatternModel.IsInTailorMode())
     {
         //item not found error
         context.LogError(
             string.Format(
                 CultureInfo.CurrentCulture,
                 Resources.Validate_GenerateModelingCodeAuthoringUriIsInvalid,
                 settings.Name),
             Resources.Validate_GenerateModelingCodeAuthoringUriIsInvalidCode, settingsElement as ModelElement);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Called to validate the design-time settings on the custom command
 /// </summary>
 /// <param name="context">Validation context to be assigned errors and warnings.</param>
 /// <param name="settingsElement">The settings element in the model being validated</param>
 /// <param name="settings">Settings for the command</param>
 public void Validate(Microsoft.VisualStudio.Modeling.Validation.ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
 {
     try
     {
         // TODO: Validate a setting on the command
         // Note that a propValue1 may still not have a value if it was configured with a ValueProvider.
         //var propValue1 = settings.GetOrCreatePropertyValue(Reflector<ShowEventSubscriptionPicker>.GetPropertyName(s => s.AProperty), String.Empty);
         //if (String.IsNullOrEmpty(propValue1))
         //{
         //    context.LogError(String.Format(CultureInfo.CurrentCulture,
         //        "{0} is configured with an invalid value for its 'AProperty'. This value must be valid.", settingsElement.Name), "1", settingsElement as ModelElement);
         //}
     }
     catch (Exception ex)
     {
         // Make error trace statement for the failure
         tracer.Error(
             "Validation rule ShowEventSubscriptionPickerValidation unexpectedly failed, error was: '{0}'", ex.Message);
         throw;
     }
 }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandReference"/> class.
 /// </summary>
 /// <param name="commandSettings">The command settings.</param>
 public CommandReference(ICommandSettings commandSettings)
 {
     this.CommandSettings = commandSettings;
 }
Esempio n. 23
0
        /// <summary>
        /// Called when validations are needed for the command
        /// </summary>
        /// <param name="context">Validation Context where to add validation errors</param>
        /// <param name="settingsElement">The settings element in the model being validated</param>
        /// <param name="settings">Settings for the command</param>
        public void Validate(Microsoft.VisualStudio.Modeling.Validation.ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
        {
            try
            {
                Guard.NotNull(() => settings, settings);

                var templateValidator = new TemplateValidator(settings.Name,
                                                              new UnfoldVsTemplateCommand.UnfoldVsTemplateSettings
                {
                    SanitizeName         = settings.GetPropertyValue <bool>(Reflector <UnfoldVsTemplateCommand> .GetPropertyName(u => u.SanitizeName)),
                    SyncName             = settings.GetPropertyValue <bool>(Reflector <UnfoldVsTemplateCommand> .GetPropertyName(u => u.SyncName)),
                    TemplateAuthoringUri = settings.GetPropertyValue <string>(Reflector <UnfoldVsTemplateCommand> .GetPropertyName(u => u.TemplateAuthoringUri)),
                    TemplateUri          = settings.GetPropertyValue <string>(Reflector <UnfoldVsTemplateCommand> .GetPropertyName(u => u.TemplateUri)),
                    SettingsElement      = settingsElement,
                    OwnerElement         = settings.Owner,
                }, context, ((ModelElement)settings).Store);
                templateValidator.ValidateCommandSettings(tracer);
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Resources.ValidationMethodFailed_Error,
                    Reflector <TemplateValidator> .GetMethod(n => n.ValidateCommandSettings(null)).Name);

                throw;
            }
        }
        /// <summary>
        /// Called when validations are needed for the command
        /// </summary>
        /// <param name="context">Validation Context where to add validation errors</param>
        /// <param name="settingsElement">The settings element in the model being validated</param>
        /// <param name="settings">Settings for the command</param>
        public virtual void Validate(ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => settings, settings);

            try
            {
                var authoringUriString = settings.GetPropertyValue<string>(Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TemplateAuthoringUri));
                if (!string.IsNullOrEmpty(authoringUriString))
                {
                    var authoringUri = new Uri(authoringUriString);
                    var uriService = serviceProvider.GetService<IUriReferenceService>();
                    IItem item = null;
                    try
                    {
                        item = uriService.ResolveUri<IItemContainer>(authoringUri).As<IItem>();
                    }
                    catch (NotSupportedException)
                    {
                        LogSolutionItemNotFound(context, settingsElement, settings);
                        return;
                    }
                    catch (UriFormatException)
                    {
                        LogSolutionItemNotFound(context, settingsElement, settings);
                        return;
                    }

                    // Ensure file is configured as 'Content'
                    if (!(string.Equals(item.Data.ItemType, BuildAction.Content.ToString(), StringComparison.OrdinalIgnoreCase)))
                    {
                        context.LogError(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Resources.Validate_GenerateModelingCodeCommandItemTypeShouldBeSetToContent,
                            settings.Name),
                        Resources.Validate_GenerateModelingCodeCommandItemTypeShouldBeSetToContentCode, settingsElement as ModelElement);
                    }

                    // Ensure file is 'IncludeInVSIX'
                    if (!(string.Equals(item.Data.IncludeInVSIX, Boolean.TrueString.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)))
                    {
                        if (String.IsNullOrEmpty(item.Data.IncludeInVSIXAs))
                        {
                            context.LogError(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXShouldBeSetToTrue,
                                settings.Name),
                            Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXShouldBeSetToTrueCode, settingsElement as ModelElement);
                        }
                        else
                        {
                            // Ensure the 'IncludeInVSIXAs' value matches TemplateUri value
                            var templateUriString = settings.GetPropertyValue<string>(Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TemplateUri));
                            if (!String.IsNullOrEmpty(templateUriString))
                            {
                                var templateFilename = TextTemplateUri.ParseFileName(new Uri(templateUriString));
                                if (!templateFilename.Equals(item.Data.IncludeInVSIXAs, StringComparison.OrdinalIgnoreCase))
                                {
                                    context.LogError(
                                    string.Format(
                                        CultureInfo.CurrentCulture,
                                        Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXAsShouldBeSameAsFile,
                                        settings.Name),
                                    Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXAsShouldBeSameAsFileCode, settingsElement as ModelElement);
                                }
                            }
                        }
                    }
                    else
                    {
                        // Ensure not both 'IncludeInVSIX' and 'IncludeInVSIXAs'
                        if (!String.IsNullOrEmpty(item.Data.IncludeInVSIXAs))
                        {
                            context.LogError(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXDuplicate,
                                settings.Name),
                            Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXDuplicateCode, settingsElement as ModelElement);
                        }
                    }
                }
                else
                {
                    LogSolutionItemNotFound(context, settingsElement, settings);
                    return;
                }

                var targetFilename = settings.GetPropertyValue<string>(Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TargetFileName));
                if (string.IsNullOrEmpty(targetFilename))
                {
                    context.LogError(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.Validate_GenerateModelingCodeCommandTargetFilenameEmpty,
                        settings.Name),
                    Resources.Validate_GenerateModelingCodeCommandTargetFilenameEmptyCode, settingsElement as ModelElement);
                }

                var isConfiguredOnProduct = ((settingsElement.Parent as IPatternSchema) != null);
                var targetPath = settings.GetPropertyValue<string>(Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TargetPath));
                if ((!string.IsNullOrEmpty(targetPath))
                    && (targetPath.StartsWith(PathResolver.ResolveArtifactLinkCharacter, StringComparison.OrdinalIgnoreCase))
                    && !isConfiguredOnProduct)
                {
                    context.LogWarning(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.Validate_GenerateModelingCodeCommandTargetPathStartsWithResolver,
                        settings.Name, targetPath, PathResolver.ResolveArtifactLinkCharacter),
                    Resources.Validate_GenerateModelingCodeCommandTargetPathStartsWithResolverCode, settingsElement as ModelElement);
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Resources.ValidationMethodFailed_Error,
                    Reflector<GenerateModelingCodeCommandValidation>.GetMethod(n => n.Validate(null, null, null)).Name);

                throw;
            }
        }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandReference"/> class.
 /// </summary>
 /// <param name="commandSettings">The command settings.</param>
 public CommandReference(ICommandSettings commandSettings)
 {
     this.CommandSettings = commandSettings;
 }
        /// <summary>
        /// Called when validations are needed for the command
        /// </summary>
        /// <param name="context">Validation Context where to add validation errors</param>
        /// <param name="settingsElement">The settings element in the model being validated</param>
        /// <param name="settings">Settings for the command</param>
        public virtual void Validate(ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => settings, settings);

            try
            {
                var authoringUriString = settings.GetPropertyValue <string>(Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TemplateAuthoringUri));
                if (!string.IsNullOrEmpty(authoringUriString))
                {
                    var   authoringUri = new Uri(authoringUriString);
                    var   uriService   = serviceProvider.GetService <IUriReferenceService>();
                    IItem item         = null;
                    try
                    {
                        item = uriService.ResolveUri <IItemContainer>(authoringUri).As <IItem>();
                    }
                    catch (NotSupportedException)
                    {
                        LogSolutionItemNotFound(context, settingsElement, settings);
                        return;
                    }
                    catch (UriFormatException)
                    {
                        LogSolutionItemNotFound(context, settingsElement, settings);
                        return;
                    }

                    // Ensure file is configured as 'Content'
                    if (!(string.Equals(item.Data.ItemType, BuildAction.Content.ToString(), StringComparison.OrdinalIgnoreCase)))
                    {
                        context.LogError(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.Validate_GenerateModelingCodeCommandItemTypeShouldBeSetToContent,
                                settings.Name),
                            Resources.Validate_GenerateModelingCodeCommandItemTypeShouldBeSetToContentCode, settingsElement as ModelElement);
                    }

                    // Ensure file is 'IncludeInVSIX'
                    if (!(string.Equals(item.Data.IncludeInVSIX, Boolean.TrueString.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)))
                    {
                        if (String.IsNullOrEmpty(item.Data.IncludeInVSIXAs))
                        {
                            context.LogError(
                                string.Format(
                                    CultureInfo.CurrentCulture,
                                    Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXShouldBeSetToTrue,
                                    settings.Name),
                                Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXShouldBeSetToTrueCode, settingsElement as ModelElement);
                        }
                        else
                        {
                            // Ensure the 'IncludeInVSIXAs' value matches TemplateUri value
                            var templateUriString = settings.GetPropertyValue <string>(Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TemplateUri));
                            if (!String.IsNullOrEmpty(templateUriString))
                            {
                                var templateFilename = TextTemplateUri.ParseFileName(new Uri(templateUriString));
                                if (!templateFilename.Equals(item.Data.IncludeInVSIXAs, StringComparison.OrdinalIgnoreCase))
                                {
                                    context.LogError(
                                        string.Format(
                                            CultureInfo.CurrentCulture,
                                            Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXAsShouldBeSameAsFile,
                                            settings.Name),
                                        Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXAsShouldBeSameAsFileCode, settingsElement as ModelElement);
                                }
                            }
                        }
                    }
                    else
                    {
                        // Ensure not both 'IncludeInVSIX' and 'IncludeInVSIXAs'
                        if (!String.IsNullOrEmpty(item.Data.IncludeInVSIXAs))
                        {
                            context.LogError(
                                string.Format(
                                    CultureInfo.CurrentCulture,
                                    Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXDuplicate,
                                    settings.Name),
                                Resources.Validate_GenerateModelingCodeCommandIIncludeInVSIXDuplicateCode, settingsElement as ModelElement);
                        }
                    }
                }
                else
                {
                    LogSolutionItemNotFound(context, settingsElement, settings);
                    return;
                }

                var targetFilename = settings.GetPropertyValue <string>(Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TargetFileName));
                if (string.IsNullOrEmpty(targetFilename))
                {
                    context.LogError(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Resources.Validate_GenerateModelingCodeCommandTargetFilenameEmpty,
                            settings.Name),
                        Resources.Validate_GenerateModelingCodeCommandTargetFilenameEmptyCode, settingsElement as ModelElement);
                }

                var isConfiguredOnProduct = ((settingsElement.Parent as IPatternSchema) != null);
                var targetPath            = settings.GetPropertyValue <string>(Reflector <GenerateModelingCodeCommand> .GetPropertyName(u => u.TargetPath));
                if ((!string.IsNullOrEmpty(targetPath)) &&
                    (targetPath.StartsWith(PathResolver.ResolveArtifactLinkCharacter, StringComparison.OrdinalIgnoreCase)) &&
                    !isConfiguredOnProduct)
                {
                    context.LogWarning(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Resources.Validate_GenerateModelingCodeCommandTargetPathStartsWithResolver,
                            settings.Name, targetPath, PathResolver.ResolveArtifactLinkCharacter),
                        Resources.Validate_GenerateModelingCodeCommandTargetPathStartsWithResolverCode, settingsElement as ModelElement);
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Resources.ValidationMethodFailed_Error,
                    Reflector <GenerateModelingCodeCommandValidation> .GetMethod(n => n.Validate(null, null, null)).Name);

                throw;
            }
        }
 private static void LogSolutionItemNotFound(ValidationContext context, IAutomationSettingsSchema settingsElement, ICommandSettings settings)
 {
     if (!settings.Owner.Root.PatternModel.IsInTailorMode())
     {
         //item not found error
         context.LogError(
         string.Format(
             CultureInfo.CurrentCulture,
             Resources.Validate_GenerateModelingCodeAuthoringUriIsInvalid,
             settings.Name),
         Resources.Validate_GenerateModelingCodeAuthoringUriIsInvalidCode, settingsElement as ModelElement);
     }
 }