Ejemplo n.º 1
0
 private void WriteNewNamespace(IUidUpdateHandleStrategy uidUpdateHandleStrategy)
 {
     if (uidUpdateHandleStrategy.GetAddNewNamespace(collector))
     {
         WriteTillSourcePosition(collector.RootElementLineNumber, collector.RootElementLinePosition);
         WriteElementTag();
         WriteSpace();
         WriteNewNamespace();
     }
 }
Ejemplo n.º 2
0
        private void ManageUid()
        {
            OperationDescription = "Performing " + ManageUidOperation;
            StepDescription      = String.Format("Preparing files list...");

            solutionFolder = visualStudioAdapter.GetSolutionFolder();
            //solutionSettings = settingsService.GetSolutionSettings();

            var xamlFiles = new List <XamlFileDescription>();

            foreach (var projDescr in visualStudioAdapter.GetProjects())
            {
                if (settingsService.IsProjectHandled(projDescr))
                {
                    xamlFiles.AddRange(visualStudioAdapter.GetXamlFiles(projDescr));
                }
            }

            if (xamlFiles.Count == 0)
            {
                MessageBox.Show("No .xaml files in selected projects", "Easy BAML");
                return;
            }

            uidUpdateHandleStrategy = new DefaultUidUpdateHandleStrategy(ManageUidOperation == ManageUidOperation.RemoveUid);

            InvalidFiles = new ObservableCollection <XamlFileViewModel>();
            TotalSteps   = xamlFiles.Count;
            CurrentStep  = 0;
            foreach (var xamlFileDescription in xamlFiles)
            {
                UpdateStepDescription(xamlFileDescription);
                ManageFileUids(xamlFileDescription);
                CurrentStep++;
            }
            CurrentStep          = TotalSteps;
            OperationDescription = "Completed: " + ManageUidOperation;
            StepDescription      = "";
        }
Ejemplo n.º 3
0
        internal bool UpdateUidWrite(IUidUpdateHandleStrategy uidUpdateHandleStrategy)
        {
            bool result;

            try
            {
                WriteNewNamespace(uidUpdateHandleStrategy);

                for (int i = 0; i < collector.Count; i++)
                {
                    Uid uid    = collector[i];
                    var action = uidUpdateHandleStrategy.GetAction(uid);
                    switch (action)
                    {
                    case UidUpdateHandleAction.Skip:
                        break;

                    case UidUpdateHandleAction.Add:
                        WriteTillSourcePosition(uid.LineNumber, uid.LinePosition);
                        if (uid.Space == SpaceInsertion.BeforeUid)
                        {
                            WriteSpace();
                        }
                        WriteNewUid(uid);
                        if (uid.Space == SpaceInsertion.AfterUid)
                        {
                            WriteSpace();
                        }
                        break;

                    case UidUpdateHandleAction.UpdateValue:
                        WriteTillSourcePosition(uid.LineNumber, uid.LinePosition);
                        ProcessAttributeStart(WriterAction.Write);
                        SkipSourceAttributeValue();
                        WriteNewAttributeValue(uid.Value);
                        break;

                    case UidUpdateHandleAction.Remove:
                        WriteTillSourcePosition(uid.LineNumber, uid.LinePosition - 1);
                        ProcessAttributeStart(WriterAction.Skip);
                        SkipSourceAttributeValue();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                WriteTillEof();
                result = true;
            }
            catch (Exception exception)
            {
                if (exception is NullReferenceException || exception is SEHException)
                {
                    throw;
                }
                result = false;
            }
            catch
            {
                result = false;
            }
            return(result);
        }