Ejemplo n.º 1
0
 void Flush(string fileName)
 {
     if (this.modelTreeManager == null)
     {
         // It's possible for modelTreeManager to be null if Load is called but the xaml file being loaded is invalid.
         // We only want to throw exception if Load hasn't been called yet.
         if (IsInErrorState() == false)
         {
             throw FxTrace.Exception.AsError(new InvalidOperationException(SR.WorkflowDesignerLoadShouldBeCalledFirst));
         }
     }
     else
     {
         this.FlushEdits();
         IDocumentPersistenceService documentPersistenceService = this.Context.Services.GetService <IDocumentPersistenceService>();
         if (documentPersistenceService != null)
         {
             documentPersistenceService.Flush(this.modelTreeManager.Root.GetCurrentValue());
         }
         else
         {
             this.WriteModelToText(fileName);
         }
     }
 }
        public void SaveJsonData_WhenInserted_ReturnsTrue()
        {
            _documentPersistenceService = new DocumentPersistenceService(_configuration);

            var bsonDocumentId = _documentPersistenceService.SaveDocument(GetLogRows());

            Assert.NotNull(bsonDocumentId);
        }
Ejemplo n.º 3
0
        public void Load(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("fileName"));
            }

            DesignerConfigurationService service = this.Context.Services.GetService <DesignerConfigurationService>();

            service.SetDefaultOfLoadingFromUntrustedSourceEnabled();
            if (!service.LoadingFromUntrustedSourceEnabled && !IsFromUnrestrictedPath(fileName))
            {
                throw FxTrace.Exception.AsError(new SecurityException(string.Format(CultureInfo.CurrentUICulture, SR.UntrustedSourceDetected, fileName)));
            }

            try
            {
                IDocumentPersistenceService documentPersistenceService = this.Context.Services.GetService <IDocumentPersistenceService>();
                if (documentPersistenceService != null)
                {
                    this.Load(documentPersistenceService.Load(fileName));
                }
                else
                {
                    using (StreamReader fileStream = new StreamReader(fileName))
                    {
                        this.loadedFile = fileName;
                        WorkflowFileItem fileItem = new WorkflowFileItem();
                        fileItem.LoadedFile = fileName;
                        this.context.Items.SetValue(fileItem);
                        this.Text = fileStream.ReadToEnd();
                        this.Load();
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                else
                {
                    this.Context.Items.SetValue(new ErrorItem()
                    {
                        Message = e.Message, Details = e.ToString()
                    });
                }
            }
            if (!this.IsInErrorState())
            {
                this.lastWorkflowSymbol = GetAttachedWorkflowSymbol();
                if (this.debuggerService != null)
                {
                    this.debuggerService.InvalidateSourceLocationMapping(fileName);
                }
            }
        }
        void NotifyModelChanged()   // Notify text is going to changed
        {
            IDocumentPersistenceService documentPersistenceService = this.Context.Services.GetService <IDocumentPersistenceService>();

            if (documentPersistenceService != null)
            {
                documentPersistenceService.OnModelChanged(this.modelTreeManager.Root.GetCurrentValue());
            }
            else
            {
                this.isModelChanged = true;
                if (this.ModelChanged != null)
                {
                    this.ModelChanged.Invoke(this, null);
                }
            }
        }