/// <inheritdoc /> public override T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor) { T value; _properties.TryGetValue(propertyDescriptor, out value); return(value); }
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 }; }
/// <inheritdoc /> public override object GetValue(ILogFilePropertyDescriptor propertyDescriptor) { object value; _properties.TryGetValue(propertyDescriptor, out value); return(value); }
/// <inheritdoc /> public object GetValue(ILogFilePropertyDescriptor property) { object value; if (!TryGetValue(property, out value)) { throw new NoSuchPropertyException(property); } return(value); }
/// <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); } }
/// <inheritdoc /> public T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor) { try { return(_logFile.GetValue(propertyDescriptor)); } catch (Exception e) { BlameExceptionOnPlugin(e); return(propertyDescriptor.DefaultValue); } }
/// <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); }
/// <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); }
/// <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); }
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 }; }
/// <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; } }
/// <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); }
/// <inheritdoc /> public override T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor) { return(_source.GetValue(propertyDescriptor)); }
/// <inheritdoc /> public override object GetValue(ILogFilePropertyDescriptor propertyDescriptor) { return(_source.GetValue(propertyDescriptor)); }
/// <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); }
/// <summary> /// </summary> /// <param name="property"></param> /// <param name="value"></param> public LogFileProperty(ILogFilePropertyDescriptor property, object value) { PropertyDescriptor = property; Value = value; }
/// <inheritdoc /> public T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor) { return(_buffer.GetValue(propertyDescriptor)); }
private IPropertyStorage CreateValueStorage(ILogFilePropertyDescriptor propertyDescriptor) { dynamic tmp = propertyDescriptor; return(CreateValueStorage(tmp)); }
private LogFilePropertyViewModel <T> CreateViewModel <T>(ILogFilePropertyDescriptor <T> descriptor) { return(new LogFilePropertyViewModel <T>(descriptor)); }
/// <inheritdoc /> public abstract T GetValue <T>(ILogFilePropertyDescriptor <T> propertyDescriptor);
public LogFilePropertyViewModel(ILogFilePropertyDescriptor <T> descriptor) { _descriptor = descriptor; }
/// <summary> /// /// </summary> /// <param name="property"></param> public NoSuchPropertyException(ILogFilePropertyDescriptor property) : base(string.Format("No such property: '{0}'", property.Id)) { }
private IPropertyStorage CreateValueStorage <T>(ILogFilePropertyDescriptor <T> propertyDescriptor) { return(new PropertyStorage <T>(propertyDescriptor.DefaultValue)); }
/// <inheritdoc /> public abstract object GetValue(ILogFilePropertyDescriptor propertyDescriptor);
/// <inheritdoc /> public object GetValue(ILogFilePropertyDescriptor propertyDescriptor) { return(_buffer.GetValue(propertyDescriptor)); }