Exemple #1
0
        /// <summary>
        /// Initializes a new instance of a <see cref="TextFormatter"></see> with the given 
        /// <see cref="TextFormatterData"></see> configuration data
        /// </summary>
        /// <param name="textFormatterData">
        /// <para>A <see cref="TextFormatterData"/> object.</para>
        /// </param>
        public TextFormatter(TextFormatterData textFormatterData)
        {
            ArgumentValidation.CheckForNullReference(textFormatterData, "textFormatterData");

            this.textFormatterData = textFormatterData;
            RegisterTemplate();
        }
        public void DistributorSettingsPropertiesTest()
        {
            CategoryData categoryData = new CategoryData();
            categoryData.Name = SR.DefaultCategory;
            CategoryNode defaultCategory = new CategoryNode(categoryData);
            TextFormatterData formatterData = new TextFormatterData();
            formatterData.Name = SR.DefaultFormatter;
            TextFormatterNode defaultFormatter = new TextFormatterNode(formatterData);

            DistributorSettingsNode distributorSettings = new DistributorSettingsNode();
            applicationNode.Nodes.Add(distributorSettings);
            distributorSettings.DefaultFormatter = defaultFormatter;
            distributorSettings.DefaultCategory = defaultCategory;

            Assert.AreEqual(defaultCategory.Name, distributorSettings.DefaultCategory.Name);
            Assert.AreEqual(defaultFormatter, distributorSettings.DefaultFormatter);
        }
        private string FormatEntry(string template, LogEntry entry)
        {
            TextFormatterData data = new TextFormatterData();
            data.Template.Value = template;

            TextFormatter formatter = new TextFormatter(data);
            return formatter.Format(entry);
        }
 /// <summary>
 /// Adds a <see cref="TextFormatterNode"/>.
 /// </summary>
 protected override void AddDefaultChildNodes()
 {
     base.AddDefaultChildNodes();
     TextFormatterData data = new TextFormatterData(SR.DefaultFormatter, SR.DefaultTextFormat);
     Nodes.Add(new TextFormatterNode(data));
 }
        public void TextFormatterDataTest()
        {
            string name = "testName";
            string template = "<test>template</test>";
            string type = typeof(TextFormatter).AssemblyQualifiedName;

            TextFormatterData data = new TextFormatterData();
            data.Name = name;
            data.Template.Value = template;
            data.TypeName = type;

            TextFormatterNode node = new TextFormatterNode(data);
            GeneratedApplicationNode.Nodes.Add(node);
            TextFormatterData nodeData = (TextFormatterData) node.FormatterData;

            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(template, nodeData.Template.Value);
            Assert.AreEqual(type, nodeData.TypeName);
        }
Exemple #6
0
        /// <summary>
        /// Initialize a new instance of a <see cref="TextFormatter"/>.  Reads the template from
        /// configuration parameters.
        /// </summary>
        /// <param name="configurationView">Dynamic view into the configuration information needed by the <see cref="TextFormatter"></see></param>     
        public override void Initialize(ConfigurationView configurationView)
        {
            ArgumentValidation.CheckForNullReference(configurationView, "configurationView");
            ArgumentValidation.CheckExpectedType(configurationView, typeof(LoggingConfigurationView));

            LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)configurationView;
            FormatterData formatterData = loggingConfigurationView.GetFormatterData(ConfigurationName);
            ArgumentValidation.CheckExpectedType(textFormatterData, typeof(TextFormatterData));

            textFormatterData = (TextFormatterData)formatterData;
            RegisterTemplate();
        }
Exemple #7
0
 /// <summary>
 /// Creates node with specified configuration data.
 /// </summary>
 /// <param name="textFormatterData">Configuration data.</param>
 public TextFormatterNode(TextFormatterData textFormatterData)
     : base(textFormatterData)
 {
     this.textFormatterData = textFormatterData;
 }