Exemple #1
0
 protected override void AppendFormattedParameter(StringBuilder builder, MethodCallParameter parameter, object value)
 {
     builder.Append('"');
     builder.Append(parameter.Name);
     builder.Append("\":");
     JsonConverter.SerializeObject(value, builder);
 }
Exemple #2
0
            protected override void AppendFormattedParameter(StringBuilder builder, MethodCallParameter parameter, object value)
            {
                builder.Append(parameter.Name);
                builder.Append('=');

                string parameterValue = XmlHelper.XmlConvertToString(value);

                if (!string.IsNullOrEmpty(parameterValue))
                {
                    UrlHelper.EscapeDataEncode(parameterValue, builder, _encodingFlags);
                }
            }
Exemple #3
0
            protected override string GetFormattedParameter(MethodCallParameter parameter, object value)
            {
                string parameterValue = Convert.ToString(value, CultureInfo.InvariantCulture);

                if (string.IsNullOrEmpty(parameterValue))
                {
                    return(string.Concat(parameter.Name, "="));
                }

                var sb = new StringBuilder(parameter.Name.Length + parameterValue.Length + 20);

                sb.Append(parameter.Name).Append("=");
                UrlHelper.EscapeDataEncode(parameterValue, sb, encodingFlags);
                return(sb.ToString());
            }
        /// <summary>
        /// Configures the logging and tracing using the given controller configuration.
        /// </summary>
        /// <param name="controllerConfiguration">The controller configuration.</param>
        public static void Configure(ControllerConfiguration controllerConfiguration)
        {
            // we better do this on the UI thread
            if (!Deployment.Current.Dispatcher.CheckAccess())
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Configure(controllerConfiguration));
                return;
            }

            // check if tracing should be enabled
            if (controllerConfiguration.EnableTracing && !string.IsNullOrEmpty(controllerConfiguration.TracingEndpointAddress))
            {
                // create the configuration
                var loggingConfig = new LoggingConfiguration();

                // create the target
                var serviceTarget = new LogReceiverWebServiceTarget();
                serviceTarget.ClientId = "WP7";
                serviceTarget.Name = "WebServiceTarget";
                serviceTarget.IncludeEventProperties = true;
                serviceTarget.UseBinaryEncoding = false;
                serviceTarget.EndpointAddress = controllerConfiguration.TracingEndpointAddress;

                // add parameters
                var parameter = new MethodCallParameter("time", "${time}");
                serviceTarget.Parameters.Add(parameter);
                parameter = new MethodCallParameter("threadid", "${threadid}");
                serviceTarget.Parameters.Add(parameter);

                // create the only rule
                var rule = new LoggingRule("*", LogLevel.Trace, serviceTarget);
                loggingConfig.LoggingRules.Add(rule);

                // set the config
                LogManager.Configuration = loggingConfig;
            }
            else
            {
                // turn off logging
                if (LogManager.Configuration != null && LogManager.Configuration.LoggingRules != null)
                {
                    LogManager.Configuration.LoggingRules.Clear();
                    LogManager.ReconfigExistingLoggers();
                }
            }
        }
        /// <summary>
        /// Configures NLog's logging with the given information.
        /// </summary>
        /// <param name="enableTracing">If set to <c>true</c> enables NLog's logging at "Trace" level. If set to <c>false</c> disables logging.</param>
        /// <param name="tracingEndpointAddress">The endpoint address of the WCF service that receives tracing messages.</param>
        public static void Configure(bool enableTracing, string tracingEndpointAddress)
        {
            // check if tracing should be enabled
            if (enableTracing && !string.IsNullOrEmpty(tracingEndpointAddress))
            {
                // create the configuration
                var loggingConfig = new LoggingConfiguration();

                // create the target
                var serviceTarget = new LogReceiverWebServiceTarget();
                serviceTarget.ClientId = "PC";
                serviceTarget.Name = "WebServiceTarget";
                serviceTarget.IncludeEventProperties = true;
                serviceTarget.UseBinaryEncoding = false;
                serviceTarget.EndpointAddress = tracingEndpointAddress;

                // add parameters
                var parameter = new MethodCallParameter("time", "${time}");
                serviceTarget.Parameters.Add(parameter);
                parameter = new MethodCallParameter("threadid", "${threadid}");
                serviceTarget.Parameters.Add(parameter);

                // create the only rule
                var rule = new LoggingRule("*", LogLevel.Trace, serviceTarget);
                loggingConfig.LoggingRules.Add(rule);

                // set the config
                LogManager.Configuration = loggingConfig;
            }
            else
            {
                if (LogManager.Configuration != null && LogManager.Configuration.LoggingRules != null)
                {
                    LogManager.Configuration.LoggingRules.Clear();
                    LogManager.ReconfigExistingLoggers();
                }
            }
        }
Exemple #6
0
 protected abstract string GetFormattedParameter(MethodCallParameter parameter, object value);
Exemple #7
0
 protected abstract void AppendFormattedParameter(StringBuilder builder, MethodCallParameter parameter, object value);
        internal string ConvertParameterGroupValue(IList <AsyncLogEventInfo> logEvents, MethodCallParameter param)
        {
            using (var targetBuilder = OptimizeBufferReuse && logEvents.Count <= 1000 ? ReusableLayoutBuilder.Allocate() : ReusableLayoutBuilder.None)
            {
                StringBuilder sb = targetBuilder.Result ?? new StringBuilder();
                if (param.GroupHeaderLayout != null)
                {
                    param.GroupHeaderLayout.RenderAppendBuilder(logEvents[0].LogEvent, sb);
                }
                for (int x = 0; x < logEvents.Count; ++x)
                {
                    if (x != 0 && param.GroupItemSeparatorLayout != null)
                    {
                        param.GroupItemSeparatorLayout.RenderAppendBuilder(logEvents[x].LogEvent, sb);
                    }

                    if (param.Layout != null)
                    {
                        // If payload becomes too big, then use local StringBuilder to avoid json-maxlength-validation
                        if (sb.Length < MaxGroupRenderSingleBufferLength)
                        {
                            param.Layout.RenderAppendBuilder(logEvents[x].LogEvent, sb);
                        }
                        else
                        {
                            using (var localTarget = new AppendBuilderCreator(sb, true))
                            {
                                param.Layout.RenderAppendBuilder(logEvents[x].LogEvent, localTarget.Builder);
                            }
                        }
                    }
                }
                if (param.GroupFooterLayout != null)
                {
                    param.GroupFooterLayout.RenderAppendBuilder(logEvents[logEvents.Count - 1].LogEvent, sb);
                }
                return(sb.ToString());
            }
        }
Exemple #9
0
 /// <summary>
 /// Adds an instance of type MethodCallParameter to the end of this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter to be added to the end of this MethodCallParameterCollection.
 /// </param>
 public virtual void Add(MethodCallParameter value)
 {
     this.List.Add(value);
 }
Exemple #10
0
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this MethodCallParameterCollection
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to locate in the MethodCallParameterCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(MethodCallParameter value)
 {
     return(this.List.IndexOf(value));
 }
 /// <summary>
 /// Adds the elements of an array to the end of this MethodCallParameterCollection.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the end of this MethodCallParameterCollection.
 /// </param>
 public virtual void AddRange(MethodCallParameter[]items)
 {
     foreach (MethodCallParameter item in items)
     {
         this.List.Add(item);
     }
 }
Exemple #12
0
            protected override string GetFormattedParameter(MethodCallParameter parameter, object value)
            {
                string parameterValue = Convert.ToString(value, CultureInfo.InvariantCulture);
                if (string.IsNullOrEmpty(parameterValue))
                {
                    return string.Concat(parameter.Name, "=");
                }

                var sb = new StringBuilder(parameter.Name.Length + parameterValue.Length + 20);
                sb.Append(parameter.Name).Append("=");
                UrlHelper.EscapeDataEncode(parameterValue, sb, encodingFlags);
                return sb.ToString();
            }
Exemple #13
0
 protected abstract string GetFormattedParameter(MethodCallParameter parameter, object value);
 /// <summary>
 /// Determines whether a specfic MethodCallParameter value is in this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to locate in this MethodCallParameterCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this MethodCallParameterCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(MethodCallParameter value)
 {
     return this.List.Contains(value);
 }
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this MethodCallParameterCollection
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to locate in the MethodCallParameterCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(MethodCallParameter value)
 {
     return this.List.IndexOf(value);
 }
 /// <summary>
 /// Adds an instance of type MethodCallParameter to the end of this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter to be added to the end of this MethodCallParameterCollection.
 /// </param>
 public virtual void Add(MethodCallParameter value)
 {
     this.List.Add(value);
 }
Exemple #17
0
 /// <summary>
 /// Removes the first occurrence of a specific MethodCallParameter from this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to remove from this MethodCallParameterCollection.
 /// </param>
 public virtual void Remove(MethodCallParameter value)
 {
     this.List.Remove(value);
 }
Exemple #18
0
 /// <summary>
 /// Inserts an element into the MethodCallParameterCollection at the specified index
 /// </summary>
 /// <param name="index">
 /// The index at which the MethodCallParameter is to be inserted.
 /// </param>
 /// <param name="value">
 /// The MethodCallParameter to insert.
 /// </param>
 public virtual void Insert(int index, MethodCallParameter value)
 {
     this.List.Insert(index, value);
 }
Exemple #19
0
 protected override string GetFormattedParameter(MethodCallParameter parameter, object value)
 {
     return string.Concat("\"", parameter.Name, "\":", GetJsonValueString(value));
 }
 /// <summary>
 /// Removes the first occurrence of a specific MethodCallParameter from this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to remove from this MethodCallParameterCollection.
 /// </param>
 public virtual void Remove(MethodCallParameter value)
 {
     this.List.Remove(value);
 }
Exemple #21
0
 protected override string GetFormattedParameter(MethodCallParameter parameter, object value)
 {
     return(string.Concat("\"", parameter.Name, "\":", GetJsonValueString(value)));
 }
 /// <summary>
 /// Initializes a new instance of the MethodCallParameterCollection class, containing elements
 /// copied from an array.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the new MethodCallParameterCollection.
 /// </param>
 public MethodCallParameterCollection(MethodCallParameter[]items)
 {
     this.AddRange(items);
 }
 /// <summary>
 /// Inserts an element into the MethodCallParameterCollection at the specified index
 /// </summary>
 /// <param name="index">
 /// The index at which the MethodCallParameter is to be inserted.
 /// </param>
 /// <param name="value">
 /// The MethodCallParameter to insert.
 /// </param>
 public virtual void Insert(int index, MethodCallParameter value)
 {
     this.List.Insert(index, value);
 }
Exemple #24
0
 /// <summary>
 /// Determines whether a specfic MethodCallParameter value is in this MethodCallParameterCollection.
 /// </summary>
 /// <param name="value">
 /// The MethodCallParameter value to locate in this MethodCallParameterCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this MethodCallParameterCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(MethodCallParameter value)
 {
     return(this.List.Contains(value));
 }