/// <summary>
 /// Get all configurations
 /// </summary>
 public GlobalConfiguration()
 {
     Server      = new ServerConfiguration();
     Application = new ApplicationConfiguration();
     Common      = new CommonConfiguration();
     Editor      = new EditorConfiguration();
 }
コード例 #2
0
        // Visible for testing
        internal void SaveEditorConfiguration(QuickDeployWindow.ToolBarSelectedButton currentTab,
                                              EditorConfiguration configuration, string editorConfigurationPath)
        {
            switch (currentTab)
            {
            case QuickDeployWindow.ToolBarSelectedButton.CreateBundle:
                configuration.assetBundleFileName = AssetBundleFileName;
                break;

            case QuickDeployWindow.ToolBarSelectedButton.DeployBundle:
                configuration.cloudCredentialsFileName = CloudCredentialsFileName;
                configuration.assetBundleFileName      = AssetBundleFileName;
                configuration.cloudStorageBucketName   = CloudStorageBucketName;
                configuration.cloudStorageObjectName   = CloudStorageObjectName;
                break;

            default:
                throw new ArgumentOutOfRangeException("currentTab", currentTab,
                                                      "Can't save editor configurations from this tab.");
            }

            // Shouldn't hurt to write to persistent storage as long as SaveEditorConfiguration(currentTab) is only called
            // when a major action happens.
            File.WriteAllText(editorConfigurationPath, JsonUtility.ToJson(configuration));
        }
コード例 #3
0
        public void ExportingConversationIncludingReport()
        {
            var exporter = new ConversationExporter();

            string[] args        = { "--report" };
            var      editorCofig = new EditorConfiguration(args);
            var      editor      = new ConversationEditor(editorCofig);
            var      logCreator  = new LogCreator(editorCofig);

            exporter.ExportConversation("chat.txt", "chatReport.json", editor, logCreator);

            var serializedConversation = new StreamReader(new FileStream("chatReport.json", FileMode.Open)).ReadToEnd();

            var savedConversation = JsonConvert.DeserializeObject <Conversation>(serializedConversation);

            Assert.That(savedConversation.name, Is.EqualTo("My Conversation"));

            var messages   = savedConversation.messages.ToList();
            var reportList = savedConversation.activity.ToList();

            Assert.That(messages[0].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470901)));
            Assert.That(messages[0].senderId, Is.EqualTo("bob"));
            Assert.That(messages[0].content, Is.EqualTo("Hello there!"));

            Assert.That(reportList[0].sender, Is.EqualTo("bob"));
            Assert.That(reportList[0].count, Is.EqualTo(3));

            Assert.That(reportList[1].sender, Is.EqualTo("mike"));
            Assert.That(reportList[1].count, Is.EqualTo(2));

            Assert.That(reportList[2].sender, Is.EqualTo("angus"));
            Assert.That(reportList[2].count, Is.EqualTo(2));
        }
コード例 #4
0
        public ApplicationConfiguration()
        {
            Editor = new EditorConfiguration();
            Git    = new GitConfiguration();
            Images = new ImagesConfiguration();

            MarkdownOptions    = new MarkdownOptionsConfiguration();
            WindowPosition     = new WindowPositionConfiguration();
            FolderBrowser      = new FolderBrowserConfiguration();
            ApplicationUpdates = new ApplicationUpdatesConfiguration();
            OpenDocuments      = new List <OpenFileDocument>();


            InternalCommonFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Markdown Monster");
            CommonFolder         = InternalCommonFolder;
            LastFolder           = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            PreviewSyncMode = PreviewSyncMode.EditorToPreview;

            AutoSaveBackups   = true;
            AutoSaveDocuments = false;

            RecentDocumentsLength       = 10;
            RememberLastDocumentsLength = 5;


            //BugReportUrl = "https://markdownmonster.west-wind.com/bugreport/bugreport.ashx?method=ReportBug";
            //BugReportUrl = "http://localhost.fiddler/MarkdownMonster/bugreport/bugreport.ashx?method=ReportBug";
            //TelemetryUrl = "https://markdownmonster.west-wind.com/bugreport/bugreport.ashx?method=Telemetry";
            SendTelemetry = true;

            ApplicationTheme = Themes.Dark;
            PreviewTheme     = "Dharkan";
            EditorTheme      = "vscodedark";

            DefaultCodeSyntax = "csharp";

            PreviewHttpLinksExternal = true;

            UseMachineEncryptionKeyForPasswords = true;

            TerminalCommand     = "powershell.exe";
            TerminalCommandArgs = "-noexit -command \"cd '{0}'\"";
            OpenFolderCommand   = "explorer.exe";

            WebBrowserPreviewExecutable = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Google\Chrome\Application\chrome.exe");

            ReportErrors = true;

            UseSingleWindow = true;

            IsPreviewVisible         = true;
            IsDocumentOutlineVisible = true;
            OpenInPresentationMode   = false;
            AlwaysUsePreviewRefresh  = false;

            // Disable for better stability and compatibility
            // We're not doing anything that pushes the hardware to bring benefits
            DisableHardwareAcceleration = true;
        }
コード例 #5
0
ファイル: MainViewModel.cs プロジェクト: alexwnovak/GitMap
        private void OnExitingCommand(CancelEventArgs e)
        {
            bool promptToSaveChanges = EditorViewModels.Any(evm => evm.IsDirty);

            if (promptToSaveChanges)
            {
                var result = _showExitConfirmation();

                if (result == ExitConfirmationResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
                if (result == ExitConfirmationResult.No)
                {
                    return;
                }

                foreach (var editorViewModel in EditorViewModels)
                {
                    var editorConfiguration = new EditorConfiguration
                    {
                        FilePath  = editorViewModel.EditorPath,
                        Arguments = editorViewModel.Arguments,
                        IsEnabled = editorViewModel.IsEnabled
                    };

                    _writeConfiguration(editorViewModel.WorkflowName, editorConfiguration);
                }
            }
        }
コード例 #6
0
        public void ReportTest()
        {
            var messages   = new List <Message>();
            var messageOne = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "stan", "i tested string");

            messages.Add(messageOne);
            var messageTwo = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "stan", "i tested string");

            messages.Add(messageTwo);
            var messageThree = new Message(DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64("1448470901")), "bob", "i tested string");

            messages.Add(messageThree);

            var testConversation = new Conversation("test", messages);

            string[] args        = { "--report" };
            var      editorCofig = new EditorConfiguration(args);
            var      logCreator  = new LogCreator(editorCofig);

            var reportList = logCreator.AddReport(testConversation);

            Assert.That(reportList[0].sender, Is.EqualTo("stan"));
            Assert.That(reportList[0].count, Is.EqualTo(2));

            Assert.That(reportList[1].sender, Is.EqualTo("bob"));
            Assert.That(reportList[1].count, Is.EqualTo(1));
        }
コード例 #7
0
        public ApplicationConfiguration()
        {
            Editor = new EditorConfiguration();
            Git    = new GitConfiguration();
            Images = new ImagesConfiguration();

            MarkdownOptions    = new MarkdownOptionsConfiguration();
            WindowPosition     = new WindowPositionConfiguration();
            FolderBrowser      = new FolderBrowserConfiguration();
            ApplicationUpdates = new ApplicationUpdatesConfiguration();
            PdfOutputWindow    = new  PdfOutputConfiguration();
            WebServer          = new WebServerConfiguration();
            System             = new SystemConfiguration();

            OpenDocuments = new List <OpenFileDocument>();

            // Make sure common folder points at AppData\Markdown Monster or PortableSettings
            InternalCommonFolder = FindCommonFolder();


            CommonFolder = InternalCommonFolder;
            LastFolder   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            PreviewSyncMode = PreviewSyncMode.EditorToPreview;

            AutoSaveBackups   = true;
            AutoSaveDocuments = false;

            RecentDocumentsLength       = 10;
            RememberLastDocumentsLength = 5;


            //BugReportUrl = "https://markdownmonster.west-wind.com/bugreport/bugreport.ashx?method=ReportBug";
            //BugReportUrl = "http://localhost.fiddler/MarkdownMonster/bugreport/bugreport.ashx?method=ReportBug";
            //TelemetryUrl = "https://markdownmonster.west-wind.com/bugreport/bugreport.ashx?method=Telemetry";


            ApplicationTheme = Themes.Dark;
            PreviewTheme     = "Dharkan";
            EditorTheme      = "vscodedark";

            DefaultCodeSyntax = "csharp";

            PreviewHttpLinksExternal = true;

            UseMachineEncryptionKeyForPasswords = true;

            TerminalCommand     = "powershell.exe";
            TerminalCommandArgs = "-noexit -command \"cd '{0}'\"";
            OpenFolderCommand   = "explorer.exe";

            WebBrowserPreviewExecutable = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Google\Chrome\Application\chrome.exe");
            UseSingleWindow             = true;

            IsPreviewVisible         = true;
            IsDocumentOutlineVisible = true;
            OpenInPresentationMode   = false;
            AlwaysUsePreviewRefresh  = false;
        }
コード例 #8
0
        protected override void SetEditorConfiguration(ExtendedMetadata metadata)
        {
            // Get the StringListAttribute with which you can specify the editor configuration,
            // and override the default settings in the StringList.js file.
            var stringListAttribute = metadata.Attributes.FirstOrDefault(a => typeof(StringListAttribute) == a.GetType()) as StringListAttribute;

            if (stringListAttribute != null)
            {
                if (!string.IsNullOrEmpty(stringListAttribute.ValueLabel))
                {
                    EditorConfiguration[VALUE_LABEL] = stringListAttribute.ValueLabel;
                }
                else
                {
                    EditorConfiguration.Remove(VALUE_LABEL);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.AddButtonLabel))
                {
                    EditorConfiguration[ADD_BUTTON_LABEL] = stringListAttribute.AddButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(ADD_BUTTON_LABEL);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.RemoveButtonLabel))
                {
                    EditorConfiguration[REMOVE_BUTTON_LABEL] = stringListAttribute.RemoveButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(REMOVE_BUTTON_LABEL);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.ValidationExpression))
                {
                    EditorConfiguration[VALIDATION_EXPRESSION] = stringListAttribute.ValidationExpression;
                }
                else
                {
                    EditorConfiguration.Remove(VALIDATION_EXPRESSION);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.ValidationMessage))
                {
                    EditorConfiguration[VALIDATION_MESSAGE] = stringListAttribute.ValidationMessage;
                }
                else
                {
                    EditorConfiguration.Remove(VALIDATION_MESSAGE);
                }
            }

            base.SetEditorConfiguration(metadata);
        }
コード例 #9
0
        public void LoadConfiguration()
        {
            _editorConfig = LoadEditorConfiguration(EditorConfigurationFilePath);

            // Copy of fields from EditorConfig for holding unsaved values set in the UI.
            AssetBundleUrl         = _editorConfig.assetBundleUrl;
            AssetBundleFileName    = _editorConfig.assetBundleFileName;
            AssetBundleScenes      = _editorConfig.assetBundleScenes;
            LoadingSceneFileName   = _editorConfig.loadingSceneFileName;
            LoadingBackgroundImage = _editorConfig.loadingBackgroundImage;
        }
コード例 #10
0
        public void LoadConfiguration()
        {
            EditorConfig = LoadEditorConfiguration(EditorConfigurationFilePath);
            EngineConfig = LoadEngineConfiguration(EngineConfigurationFilePath);

            // Copy of fields from EditorConfig and EngineConfig for holding unsaved values set in the UI.
            CloudCredentialsFileName = EditorConfig.cloudCredentialsFileName;
            AssetBundleFileName      = EditorConfig.assetBundleFileName;
            CloudStorageBucketName   = EditorConfig.cloudStorageBucketName;
            CloudStorageObjectName   = EditorConfig.cloudStorageObjectName;
            AssetBundleUrl           = EngineConfig.assetBundleUrl;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalConfiguration"/> class.
 /// Get all configurations.
 /// </summary>
 public GlobalConfiguration()
 {
     this.server      = new ServerConfiguration();
     this.application = new ApplicationConfiguration();
     this.signature   = new SignatureConfiguration();
     this.viewer      = new ViewerConfiguration();
     this.common      = new CommonConfiguration();
     this.annotation  = new AnnotationConfiguration();
     this.comparison  = new ComparisonConfiguration();
     this.conversion  = new ConversionConfiguration();
     this.editor      = new EditorConfiguration();
     this.metadata    = new MetadataConfiguration();
     this.search      = new SearchConfiguration();
 }
コード例 #12
0
        // Visible for testing
        public void SaveEditorConfiguration(EditorConfiguration configuration, string editorConfigurationPath)
        {
            _lastSaveTime = Time.realtimeSinceStartup;
            _configChangedSinceLastSave = false;

            configuration.assetBundleFileName    = AssetBundleFileName;
            configuration.assetBundleScenes      = AssetBundleScenes;
            configuration.assetBundleUrl         = AssetBundleUrl;
            configuration.loadingBackgroundImage = LoadingBackgroundImage;
            configuration.loadingSceneFileName   = LoadingSceneFileName;

            // Shouldn't hurt to write to persistent storage as long as SaveEditorConfiguration(currentTab) is only
            // called when a major action happens.
            File.WriteAllText(editorConfigurationPath, JsonUtility.ToJson(configuration));
        }
コード例 #13
0
        private string BuildDocContent()
        {
            var docContent = Properties.Resources.HtmlEditor;

            if (EditorConfiguration != null)
            {
                EditorConfiguration.Optimize(PackageType);
                docContent = docContent.Replace("$$CONFIG",
                                                new JavaScriptSerializer().Serialize(EditorConfiguration));
                docContent = docContent.Replace("$$PACKAGE", PackageType);
            }

            docContent = docContent.Replace("$$CONTENT", (Content ?? "").ToString());

            return(docContent);
        }
コード例 #14
0
        public void LoadedCommand_EditorsHaveSettings_SettingsAreLoaded()
        {
            var editorConfiguration = new EditorConfiguration
            {
                Arguments = "arguments",
                FilePath  = "filePath",
                IsEnabled = true
            };

            var mainViewModel = new MainViewModel(Enumerable.Empty <IEditorViewModel>(),
                                                  w => editorConfiguration,
                                                  (_, __) => { },
                                                  () => default(ExitConfirmationResult));

            mainViewModel.LoadedCommand.Execute(null);
        }
コード例 #15
0
        public void ExportingConversationExportsConversation()
        {
            var exporter = new ConversationExporter();

            string[] args        = { };
            var      editorCofig = new EditorConfiguration(args);
            var      editor      = new ConversationEditor(editorCofig);
            var      logCreator  = new LogCreator(editorCofig);

            exporter.ExportConversation("chat.txt", "chat.json", editor, logCreator);

            var serializedConversation = new StreamReader(new FileStream("chat.json", FileMode.Open)).ReadToEnd();

            var savedConversation = JsonConvert.DeserializeObject <Conversation>(serializedConversation);

            Assert.That(savedConversation.name, Is.EqualTo("My Conversation"));

            var messages = savedConversation.messages.ToList();

            Assert.That(messages[0].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470901)));
            Assert.That(messages[0].senderId, Is.EqualTo("bob"));
            Assert.That(messages[0].content, Is.EqualTo("Hello there!"));

            Assert.That(messages[1].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470905)));
            Assert.That(messages[1].senderId, Is.EqualTo("mike"));
            Assert.That(messages[1].content, Is.EqualTo("how are you?"));

            Assert.That(messages[2].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470906)));
            Assert.That(messages[2].senderId, Is.EqualTo("bob"));
            Assert.That(messages[2].content, Is.EqualTo("I'm good thanks, do you like pie?"));

            Assert.That(messages[3].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470910)));
            Assert.That(messages[3].senderId, Is.EqualTo("mike"));
            Assert.That(messages[3].content, Is.EqualTo("no, let me ask Angus..."));

            Assert.That(messages[4].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470912)));
            Assert.That(messages[4].senderId, Is.EqualTo("angus"));
            Assert.That(messages[4].content, Is.EqualTo("Hell yes! Are we buying some pie?"));

            Assert.That(messages[5].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470914)));
            Assert.That(messages[5].senderId, Is.EqualTo("bob"));
            Assert.That(messages[5].content, Is.EqualTo("No, just want to know if there's anybody else in the pie society..."));

            Assert.That(messages[6].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470915)));
            Assert.That(messages[6].senderId, Is.EqualTo("angus"));
            Assert.That(messages[6].content, Is.EqualTo("YES! I'm the head pie eater there..."));
        }
コード例 #16
0
        public void Launch_EditorIsLaunched_ReturnsEditorProcessExitCode()
        {
            var editorConfiguration = new EditorConfiguration
            {
                FilePath  = "does not matter",
                Arguments = "does not matter"
            };

            var workflow = new Workflow(
                "CommitWorkflow",
                w => editorConfiguration,
                (_, __) => 1);

            int exitCode = workflow.Launch("COMMIT_EDITMSG");

            exitCode.Should().Be(1);
        }
コード例 #17
0
        public static EditorConfiguration GetConfiguration(String configurationPath)
        {
            EditorConfiguration config = null;

            try
            {
                config = lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <EditorConfiguration>("EditorConfiguration");
                if (config == null)
                {
                    lm.Comol.Core.DomainModel.Helpers.XmlRepository <EditorConfiguration> repository = new lm.Comol.Core.DomainModel.Helpers.XmlRepository <EditorConfiguration>();
                    config = repository.Deserialize(configurationPath);
                    lm.Comol.Core.DomainModel.Helpers.CacheHelper.AddToFileCache("EditorConfiguration", config, configurationPath);
                }
            }
            catch (Exception ex) {
            }
            return(config);
        }
コード例 #18
0
 public static void InitEditorConfiguration()
 {
     if (UnityEditor.AssetDatabase.FindAssets("AltUnityTesterEditorSettings").Length == 0)
     {
         var altUnityEditorFolderPath = UnityEditor.AssetDatabase.GUIDToAssetPath(UnityEditor.AssetDatabase.FindAssets("AltUnityTesterEditor")[0]);
         altUnityEditorFolderPath = altUnityEditorFolderPath.Substring(0, altUnityEditorFolderPath.Length - 24);
         UnityEngine.Debug.Log(altUnityEditorFolderPath);
         EditorConfiguration = UnityEngine.ScriptableObject.CreateInstance <EditorConfiguration>();
         UnityEditor.AssetDatabase.CreateAsset(EditorConfiguration, altUnityEditorFolderPath + "/AltUnityTesterEditorSettings.asset");
         UnityEditor.AssetDatabase.SaveAssets();
     }
     else
     {
         EditorConfiguration = UnityEditor.AssetDatabase.LoadAssetAtPath <EditorConfiguration>(
             UnityEditor.AssetDatabase.GUIDToAssetPath(UnityEditor.AssetDatabase.FindAssets("AltUnityTesterEditorSettings")[0]));
     }
     UnityEditor.EditorUtility.SetDirty(EditorConfiguration);
 }
コード例 #19
0
        /// <summary>
        /// The application entry point.
        /// </summary>
        /// <param name="args">
        /// The command line arguments.
        /// </param>
        /// <summary>
        /// The message content.
        /// </summary>
        static void Main(string[] args)
        {
            // We use Microsoft.Extensions.Configuration.CommandLine and Configuration.Binder to read command line arguments.
            var configuration         = new ConfigurationBuilder().AddCommandLine(args).Build();
            var exporterConfiguration = configuration.Get <ExporterConfiguration>();

            // Building a configuration of the editing of the conversation -
            // couldn't get a boolean flag to work in ExporterConfiguration
            var editorConfiguration = new EditorConfiguration(args);
            var conversationEditor  = new ConversationEditor(editorConfiguration);

            var logCreator = new LogCreator(editorConfiguration);

            var conversationExporter = new ConversationExporter();

            conversationExporter.ExportConversation(exporterConfiguration.InputFilePath,
                                                    exporterConfiguration.OutputFilePath, conversationEditor, logCreator);
        }
コード例 #20
0
        protected override void SetEditorConfiguration(ExtendedMetadata metadata)
        {
            // Get the AutocompleteListAttribute with which you can specify the editor configuration,
            // and override the default settings in the AutocompleteList.js file.
            var stringListAttribute = metadata.Attributes.FirstOrDefault(a => typeof(AutocompleteListAttribute) == a.GetType()) as AutocompleteListAttribute;

            if (stringListAttribute != null)
            {
                if (!string.IsNullOrEmpty(stringListAttribute.ValueLabel))
                {
                    EditorConfiguration[VALUE_LABEL] = stringListAttribute.ValueLabel;
                }
                else
                {
                    EditorConfiguration.Remove(VALUE_LABEL);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.AddButtonLabel))
                {
                    EditorConfiguration[ADD_BUTTON_LABEL] = stringListAttribute.AddButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(ADD_BUTTON_LABEL);
                }

                if (!string.IsNullOrEmpty(stringListAttribute.RemoveButtonLabel))
                {
                    EditorConfiguration[REMOVE_BUTTON_LABEL] = stringListAttribute.RemoveButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(REMOVE_BUTTON_LABEL);
                }

                string format = ServiceLocator.Current.GetInstance <ModuleTable>().ResolvePath("Shell", "stores/selectionquery/{0}/");
                EditorConfiguration["storeurl"] = string.Format(CultureInfo.InvariantCulture, format, new object[]
                {
                    stringListAttribute.SelectionFactoryType.FullName
                });
            }

            base.SetEditorConfiguration(metadata);
        }
コード例 #21
0
        public void Launch_ConfigurationSpecifiesWhereTheFilePathGoes_EditorReceivesTheFilePath()
        {
            var editorConfiguration = new EditorConfiguration
            {
                FilePath  = "file path",
                Arguments = "-file %1"
            };

            string path      = null;
            string arguments = null;

            var workflow = new Workflow(
                "CommitWorkflow",
                w => editorConfiguration,
                (p, a) => { path = p; arguments = a; return(0); });

            workflow.Launch("COMMIT_EDITMSG");

            path.Should().Be("file path");
            arguments.Should().Be("-file COMMIT_EDITMSG");
        }
コード例 #22
0
        public void Launch_GetsCommitEditorConfiguration_LaunchesConfiguredEditor()
        {
            var editorConfiguration = new EditorConfiguration
            {
                FilePath  = "file path",
                Arguments = "arguments"
            };

            string path      = null;
            string arguments = null;

            var workflow = new Workflow(
                "CommitWorkflow",
                w => editorConfiguration,
                (p, a) => { path = p; arguments = a; return(0); });

            workflow.Launch(null);

            path.Should().Be("file path");
            arguments.Should().Be("arguments");
        }
コード例 #23
0
        public void ExportingConversationWithFilters()
        {
            var exporter = new ConversationExporter();

            string[] args        = { "--filterByUser", "bob", "--filterByKeyword", "society", "--blacklist", "pie", "--report" };
            var      editorCofig = new EditorConfiguration(args);
            var      editor      = new ConversationEditor(editorCofig);
            var      logCreator  = new LogCreator(editorCofig);

            exporter.ExportConversation("chat.txt", "chatFilter.json", editor, logCreator);

            var serializedConversation = new StreamReader(new FileStream("chatFilter.json", FileMode.Open)).ReadToEnd();

            var savedConversation = JsonConvert.DeserializeObject <Conversation>(serializedConversation);

            Assert.That(savedConversation.name, Is.EqualTo("My Conversation"));

            var messages   = savedConversation.messages.ToList();
            var reportList = savedConversation.activity.ToList();

            Assert.That(messages[0].timestamp, Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1448470914)));
            Assert.That(messages[0].senderId, Is.EqualTo("bob"));
            Assert.That(messages[0].content, Is.EqualTo("No, just want to know if there's anybody else in the *redacted* society..."));
        }
コード例 #24
0
        public void ExitingCommand_SavesChangesWhenPrompted_ChangesAreSaved()
        {
            var viewModelMock = new Mock <IEditorViewModel>();

            viewModelMock.SetupGet(vm => vm.IsDirty).Returns(true);
            viewModelMock.SetupGet(vm => vm.EditorPath).Returns("editor");
            viewModelMock.SetupGet(vm => vm.Arguments).Returns("arguments");
            viewModelMock.SetupGet(vm => vm.IsEnabled).Returns(true);

            var cancelEventArgs = new CancelEventArgs();

            EditorConfiguration actualConfiguration = null;

            var mainViewModel = new MainViewModel(new[] { viewModelMock.Object },
                                                  w => EditorConfiguration.Empty,
                                                  (_, ec) => actualConfiguration = ec,
                                                  () => ExitConfirmationResult.Yes);

            mainViewModel.ExitingCommand.Execute(cancelEventArgs);

            actualConfiguration.FilePath.Should().Be("editor");
            actualConfiguration.Arguments.Should().Be("arguments");
            actualConfiguration.IsEnabled.Should().BeTrue();
        }
コード例 #25
0
        public void InitView(String editorConfigurationPath, System.Guid currentWorkingApplicationId)
        {
            NoticeboardMessage message = null;

            EditorConfiguration config = ServiceEditor.GetConfiguration(editorConfigurationPath);

            if (config != null)
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();
                if (mSettings == null && config.CssFiles.Any())
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && mSettings.CssFiles.Any() && mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, mSettings.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && !mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
            }

            long idMessage   = View.PreloadedIdMessage;
            int  IdCommunity = View.PreloadedIdCommunity;

            if (idMessage != 0)
            {
                message = Service.GetMessage(idMessage);
            }
            else
            {
                message = Service.GetLastMessage(IdCommunity);
                if (message != null)
                {
                    idMessage = message.Id;
                }
            }
            if (message != null && message.Community != null)
            {
                IdCommunity = message.Community.Id;
            }
            else if (message != null && message.isForPortal)
            {
                IdCommunity = 0;
            }
            else
            {
                IdCommunity = UserContext.WorkingCommunityID;
            }

            Community community = null;

            if (IdCommunity > 0)
            {
                community = CurrentManager.GetCommunity(IdCommunity);
            }
            if (community == null && IdCommunity > 0)
            {
                View.ContainerName = "";
            }
            else if (community != null)
            {
                View.ContainerName = community.Name;
            }
            else
            {
                View.ContainerName = View.PortalName;
            }

            Boolean anonymousViewAllowed = (View.PreloadWorkingApplicationId != Guid.Empty && View.PreloadWorkingApplicationId == currentWorkingApplicationId);

            if (message == null && idMessage > 0)
            {
                View.DisplayUnknownMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewUnknownMessage);
            }
            else if (message == null && idMessage == 0)
            {
                View.DisplayEmptyMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewEmptyMessage);
            }
            else if (UserContext.isAnonymous && !anonymousViewAllowed)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.IdCurrentMessage = idMessage;

                ModuleNoticeboard module = null;
                if (IdCommunity == 0 && message.isForPortal)
                {
                    module = ModuleNoticeboard.CreatePortalmodule((UserContext.isAnonymous) ? (int)UserTypeStandard.Guest : UserContext.UserTypeID);
                }
                else if (IdCommunity > 0)
                {
                    module = new ModuleNoticeboard(CurrentManager.GetModulePermission(UserContext.CurrentUserID, IdCommunity, ModuleID));
                }
                else
                {
                    module = new ModuleNoticeboard();
                }
                if (module.Administration || module.ViewCurrentMessage || module.ViewOldMessage || anonymousViewAllowed)
                {
                    View.DisplayMessage(message);
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewMessage);
                }
                else
                {
                    View.DisplayNoPermission();
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.NoPermission);
                }
            }
        }
コード例 #26
0
        public String ImageHandlerPath(String configurationPath)
        {
            EditorConfiguration config = GetConfiguration(configurationPath);

            return((config == null) ? "" : config.ImageHandlerPath);
        }
        protected override void SetEditorConfiguration(ExtendedMetadata metadata)
        {
            // Get the KeyValueItemsAttribute with which you can specify the editor configuration,
            // and override the default settings in the KeyValueItems.js file.
            var keyValueItemsAttribute = metadata.Attributes.FirstOrDefault(a => typeof(KeyValueItemsAttribute) == a.GetType()) as KeyValueItemsAttribute;

            if (keyValueItemsAttribute != null)
            {
                if (!string.IsNullOrEmpty(keyValueItemsAttribute.KeyLabel))
                {
                    EditorConfiguration[KEY_LABEL] = keyValueItemsAttribute.KeyLabel;
                }
                else
                {
                    EditorConfiguration.Remove(KEY_LABEL);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.ValueLabel))
                {
                    EditorConfiguration[VALUE_LABEL] = keyValueItemsAttribute.ValueLabel;
                }
                else
                {
                    EditorConfiguration.Remove(VALUE_LABEL);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.AddButtonLabel))
                {
                    EditorConfiguration[ADD_BUTTON_LABEL] = keyValueItemsAttribute.AddButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(ADD_BUTTON_LABEL);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.RemoveButtonLabel))
                {
                    EditorConfiguration[REMOVE_BUTTON_LABEL] = keyValueItemsAttribute.RemoveButtonLabel;
                }
                else
                {
                    EditorConfiguration.Remove(REMOVE_BUTTON_LABEL);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.KeyValidationExpression))
                {
                    EditorConfiguration[KEY_VALIDATION_EXPRESSION] = keyValueItemsAttribute.KeyValidationExpression;
                }
                else
                {
                    EditorConfiguration.Remove(KEY_VALIDATION_EXPRESSION);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.KeyValidationMessage))
                {
                    EditorConfiguration[KEY_VALIDATION_MESSAGE] = keyValueItemsAttribute.KeyValidationMessage;
                }
                else
                {
                    EditorConfiguration.Remove(KEY_VALIDATION_MESSAGE);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.ValueValidationExpression))
                {
                    EditorConfiguration[VALUE_VALIDATION_EXPRESSION] = keyValueItemsAttribute.ValueValidationExpression;
                }
                else
                {
                    EditorConfiguration.Remove(VALUE_VALIDATION_EXPRESSION);
                }

                if (!string.IsNullOrEmpty(keyValueItemsAttribute.ValueValidationMessage))
                {
                    EditorConfiguration[VALUE_VALIDATION_MESSAGE] = keyValueItemsAttribute.ValueValidationMessage;
                }
                else
                {
                    EditorConfiguration.Remove(VALUE_VALIDATION_MESSAGE);
                }

                EditorConfiguration[SHOW_SELECTED_BY_DEFAULT_CHECKBOX] = keyValueItemsAttribute.ShowSelectedByDefaultCheckbox;
            }

            base.SetEditorConfiguration(metadata);
        }
コード例 #28
0
 public AnchorsOnPageEditorDescriptor()
 {
     SelectionFactoryType = typeof(PropertySettingsSelectionFactory);
     ClientEditingClass   = "epi-cms/contentediting/editors/SelectionEditor";
     EditorConfiguration.Add("style", "width: 240px");
 }