Пример #1
0
        /// <summary>
        /// Creates the specified name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <param name="options">The options.</param>
        /// <param name="item">The item.</param>
        /// <param name="elapsed">The elapsed.</param>
        /// <param name="machineName"></param>
        /// <returns></returns>
        public static MarbleBase Create <T>(
            string name,
            MarbleSerializationOptions options,
            T item,
            TimeSpan elapsed,
            string machineName)
        {
            var marble = new MarbleNext(name, options, elapsed, machineName);

            //object surrogate = null;
            //if (surrogateMapping == null)
            //    surrogate = item;
            //else
            //    surrogate = surrogateMapping(item, marble) ?? item;

            if (item is string ||
                (options & SERIALIZE_OPTION) == MarbleSerializationOptions.None)
            {
                marble.RawValue       = item; // TODO: consider BinaryFormatter / NetDataContractSerialization if supported
                marble.FormattedValue = item.ToString();
            }
            else
            {
                marble.RawValue = item;
            }
            return(marble);
        }
Пример #2
0
 public MonitorSurrogate(
     MarbleSerializationOptions serializationStrategy = MarbleSerializationOptions.ToString,
     Func <T, MarbleCandidate, object> mapping        = null)
 {
     _mapping = mapping;
     SerializationStrategy = serializationStrategy;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MarbleNext"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="options">The options.</param>
 /// <param name="elapsed">The elapsed.</param>
 /// <param name="machineName">Name of the machine.</param>
 internal MarbleNext(
     string name,
     MarbleSerializationOptions options,
     TimeSpan elapsed,
     string machineName)
     : base(name, options, MarbleKind.OnNext, elapsed, machineName)
 {
 }
Пример #4
0
        /// <summary>
        /// Monitors many streams (like window).
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="name">The name.</param>
        /// <param name="orderingBaseIndex">Index of the ordering base.</param>
        /// <param name="surrogateAction">The surrogate action.</param>
        /// <param name="serializationStrategy">The serialization strategy.</param>
        /// <param name="keywords">The keywords.</param>
        /// <returns></returns>
        public static IObservable <IObservable <T> > MonitorMany <T>(
            this IObservable <IObservable <T> > instance,
            string name,
            double orderingBaseIndex,
            Func <T, MarbleCandidate, object> surrogateAction,
            MarbleSerializationOptions serializationStrategy = MarbleSerializationOptions.ToString,
            params string[] keywords)
        {
            IMonitorSurrogate <T> surrogate = new FuncSurrogate <T>(surrogateAction, serializationStrategy);

            return(MonitorMany(instance, name, orderingBaseIndex, surrogate, keywords));
        }
Пример #5
0
        /// <summary>
        /// Monitor ISubject stream
        /// </summary>
        /// <typeparam name="TIn">The type of the in.</typeparam>
        /// <typeparam name="TOut">The type of the out.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="name">The name.</param>
        /// <param name="orderingIndex">Index of the ordering.</param>
        /// <param name="surrogateAction">The surrogate action.</param>
        /// <param name="serializationStrategy">The serialization strategy.</param>
        /// <param name="keywords">The keywords.</param>
        /// <returns></returns>
        public static ISubject <TIn, TOut> Monitor <TIn, TOut>(
            this ISubject <TIn, TOut> instance,
            string name,
            double orderingIndex,
            Func <TOut, MarbleCandidate, object> surrogateAction,
            MarbleSerializationOptions serializationStrategy = MarbleSerializationOptions.ToString,
            params string[] keywords)
        {
            IMonitorSurrogate <TOut> surrogate = new FuncSurrogate <TOut>(surrogateAction, serializationStrategy);

            return(Monitor <TIn, TOut>(instance, name, orderingIndex, surrogate, keywords));
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarbleBase"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="options">The options.</param>
        /// <param name="kind">The kind.</param>
        /// <param name="elapsed">The elapsed.</param>
        /// <param name="machineName">Name of the machine.</param>
        internal MarbleBase(
            string name,
            MarbleSerializationOptions options,
            MarbleKind kind,
            TimeSpan elapsed,
            string machineName)
        {
            Name     = name;
            Kind     = kind;
            ThreadId = Thread.CurrentThread.ManagedThreadId;

            Options = options;
            Offset  = elapsed;

            DateCreatedUtc = DateTime.UtcNow;
            Keywords       = new string[0];

            MachineName = machineName;
        }
Пример #7
0
 public FuncSurrogate(Func <T, MarbleCandidate, object> surrogate,
                      MarbleSerializationOptions serializationStrategy = MarbleSerializationOptions.ToString)
 {
     _surrogate             = surrogate;
     _serializationStrategy = serializationStrategy;
 }
Пример #8
0
 /// <summary>
 /// Creates the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="options">The options.</param>
 /// <param name="elapsed">The elapsed.</param>
 /// <param name="machineName">Name of the machine.</param>
 /// <returns></returns>
 public static MarbleBase Create(string name, MarbleSerializationOptions options,
                                 TimeSpan elapsed, string machineName)
 {
     return(new MarbleComplete(name, options, elapsed, machineName));
 }
Пример #9
0
 /// <summary>
 /// Creates the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="options">The options.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="elapsed">The elapsed.</param>
 /// <param name="machineName">Name of the machine.</param>
 /// <returns></returns>
 public static MarbleBase Create(string name,
                                 MarbleSerializationOptions options, Exception ex, TimeSpan elapsed,
                                 string machineName)
 {
     return(new MarbleError(name, options, ex, elapsed, machineName));
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MarbleError"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="options">The options.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="elapsed">The elapsed.</param>
 /// <param name="machineName">Name of the machine.</param>
 internal MarbleError(string name, MarbleSerializationOptions options,
                      Exception ex, TimeSpan elapsed, string machineName)
     : base(name, options, MarbleKind.OnError, elapsed, machineName)
 {
     base.RawValue = ex.ToString();
 }