Esempio n. 1
0
        /// <inheritdoc />
        public override T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
        {
            T value;

            _properties.TryGetValue(propertyDescriptor, out value);
            return(value);
        }
Esempio n. 2
0
        static LogFileProperties()
        {
            Name           = new WellKnownLogFilePropertyDescriptor <string>("Name");
            StartTimestamp = new WellKnownLogFilePropertyDescriptor <DateTime?>("StartTimestamp");
            EndTimestamp   = new WellKnownLogFilePropertyDescriptor <DateTime?>("EndTimestamp");
            Duration       = new WellKnownLogFilePropertyDescriptor <TimeSpan?>("Duration");
            LastModified   = new WellKnownLogFilePropertyDescriptor <DateTime?>("LastModified");
            Created        = new WellKnownLogFilePropertyDescriptor <DateTime?>("Created");
            Size           = new WellKnownLogFilePropertyDescriptor <Size?>("Size");
            EmptyReason    = new WellKnownLogFilePropertyDescriptor <ErrorFlags>("EmptyReason");
            Format         = new WellKnownLogFilePropertyDescriptor <ILogFileFormat>("Format");
            Encoding       = new WellKnownLogFilePropertyDescriptor <Encoding>("Encoding");

            Minimum = new ILogFilePropertyDescriptor[]
            {
                Name,
                StartTimestamp,
                EndTimestamp,
                Duration,
                LastModified,
                Created,
                Size,
                EmptyReason,
                Format,
                Encoding
            };
        }
Esempio n. 3
0
        /// <inheritdoc />
        public override object GetValue(ILogFilePropertyDescriptor propertyDescriptor)
        {
            object value;

            _properties.TryGetValue(propertyDescriptor, out value);
            return(value);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public object GetValue(ILogFilePropertyDescriptor property)
        {
            object value;

            if (!TryGetValue(property, out value))
            {
                throw new NoSuchPropertyException(property);
            }

            return(value);
        }
Esempio n. 5
0
        /// <inheritdoc />
        public T GetValue <T>(ILogFilePropertyDescriptor <T> property)
        {
            T value;

            if (!TryGetValue(property, out value))
            {
                throw new NoSuchPropertyException(property);
            }

            return(value);
        }
#pragma warning restore 67

        #endregion

        private ILogFilePropertyViewModel TryCreateViewModel(ILogFilePropertyDescriptor x)
        {
            try
            {
                return((ILogFilePropertyViewModel)CreateViewModel((dynamic)x));
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Caught unexpected exception: {0}", e);
                return(null);
            }
        }
Esempio n. 7
0
 /// <inheritdoc />
 public T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
 {
     try
     {
         return(_logFile.GetValue(propertyDescriptor));
     }
     catch (Exception e)
     {
         BlameExceptionOnPlugin(e);
         return(propertyDescriptor.DefaultValue);
     }
 }
Esempio n. 8
0
        /// <inheritdoc />
        public bool TryGetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor, out T value)
        {
            IPropertyStorage storage;

            if (!_values.TryGetValue(propertyDescriptor, out storage))
            {
                value = propertyDescriptor.DefaultValue;
                return(false);
            }

            value = ((PropertyStorage <T>)storage).Value;
            return(true);
        }
Esempio n. 9
0
        /// <inheritdoc />
        public bool TryGetValue(ILogFilePropertyDescriptor propertyDescriptor, out object value)
        {
            IPropertyStorage storage;

            if (!_values.TryGetValue(propertyDescriptor, out storage))
            {
                value = propertyDescriptor.DefaultValue;
                return(false);
            }

            value = storage.Value;
            return(true);
        }
Esempio n. 10
0
        /// <inheritdoc />
        public T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
        {
            var logFile = _innerLogFile;

            if (logFile != null)
            {
                return(logFile.GetValue(propertyDescriptor));
            }

            if (Equals(propertyDescriptor, LogFileProperties.EmptyReason))
            {
                return((T)(object)ErrorFlags.SourceDoesNotExist);
            }

            return(propertyDescriptor.DefaultValue);
        }
Esempio n. 11
0
        static LogFileProperties()
        {
            StartTimestamp = new WellKnownLogFilePropertyDescriptor <DateTime?>("StartTimestamp");
            EndTimestamp   = new WellKnownLogFilePropertyDescriptor <DateTime?>("EndTimestamp");
            LastModified   = new WellKnownLogFilePropertyDescriptor <DateTime?>("LastModified");
            Created        = new WellKnownLogFilePropertyDescriptor <DateTime?>("Created");
            Size           = new WellKnownLogFilePropertyDescriptor <Size?>("Size");
            EmptyReason    = new WellKnownLogFilePropertyDescriptor <ErrorFlags>("EmptyReason");

            Minimum = new ILogFilePropertyDescriptor[]
            {
                StartTimestamp,
                EndTimestamp,
                LastModified,
                Created,
                Size,
                EmptyReason
            };
        }
Esempio n. 12
0
        /// <inheritdoc />
        public void SetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor, T value)
        {
            if (propertyDescriptor == null)
            {
                throw new ArgumentNullException(nameof(propertyDescriptor));
            }
            if (!LogFileProperty.IsAssignableFrom(propertyDescriptor, value))
            {
                throw new ArgumentException();
            }

            if (!_values.ContainsKey(propertyDescriptor))
            {
                _propertyDescriptors.Add(propertyDescriptor);
                var storage = CreateValueStorage(propertyDescriptor);
                storage.Value = value;
                _values.Add(propertyDescriptor, storage);
            }
            else
            {
                ((PropertyStorage <T>)_values[propertyDescriptor]).Value = value;
            }
        }
Esempio n. 13
0
        /// <summary>
        ///     Tests if the given value is compatible with the given property's type.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsAssignableFrom(ILogFilePropertyDescriptor property, object value)
        {
            var type = property.DataType;

            if (value == null)
            {
                if (type.IsClass || type.IsInterface || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)))
                {
                    return(true);
                }

                return(false);
            }

            var valueType = value.GetType();

            if (type.IsAssignableFrom(valueType))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 14
0
 /// <inheritdoc />
 public override T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
 {
     return(_source.GetValue(propertyDescriptor));
 }
Esempio n. 15
0
 /// <inheritdoc />
 public override object GetValue(ILogFilePropertyDescriptor propertyDescriptor)
 {
     return(_source.GetValue(propertyDescriptor));
 }
Esempio n. 16
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="propertyDescriptor"></param>
 /// <param name="value"></param>
 public void SetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor, T value)
 {
     _properties.SetValue(propertyDescriptor, value);
 }
Esempio n. 17
0
 /// <summary>
 /// </summary>
 /// <param name="property"></param>
 /// <param name="value"></param>
 public LogFileProperty(ILogFilePropertyDescriptor property, object value)
 {
     PropertyDescriptor = property;
     Value = value;
 }
Esempio n. 18
0
 /// <inheritdoc />
 public T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
 {
     return(_buffer.GetValue(propertyDescriptor));
 }
Esempio n. 19
0
        private IPropertyStorage CreateValueStorage(ILogFilePropertyDescriptor propertyDescriptor)
        {
            dynamic tmp = propertyDescriptor;

            return(CreateValueStorage(tmp));
        }
 private LogFilePropertyViewModel <T> CreateViewModel <T>(ILogFilePropertyDescriptor <T> descriptor)
 {
     return(new LogFilePropertyViewModel <T>(descriptor));
 }
Esempio n. 21
0
 /// <inheritdoc />
 public abstract T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor);
 public LogFilePropertyViewModel(ILogFilePropertyDescriptor <T> descriptor)
 {
     _descriptor = descriptor;
 }
Esempio n. 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="property"></param>
 public NoSuchPropertyException(ILogFilePropertyDescriptor property)
     : base(string.Format("No such property: '{0}'", property.Id))
 {
 }
Esempio n. 24
0
 private IPropertyStorage CreateValueStorage <T>(ILogFilePropertyDescriptor <T> propertyDescriptor)
 {
     return(new PropertyStorage <T>(propertyDescriptor.DefaultValue));
 }
Esempio n. 25
0
 /// <inheritdoc />
 public abstract object GetValue(ILogFilePropertyDescriptor propertyDescriptor);
Esempio n. 26
0
 /// <inheritdoc />
 public object GetValue(ILogFilePropertyDescriptor propertyDescriptor)
 {
     return(_buffer.GetValue(propertyDescriptor));
 }