/// <summary>Initializes this object.</summary> /// <param name="portion">The portion.</param> private void Initialize(DatePortion portion) { Type = typeof(DateTime); Features = 0; if (portion.HasFlag(DatePortion.Date)) { Features |= DateTimeFeature.Year | DateTimeFeature.Month | DateTimeFeature.Day; } if (portion.HasFlag(DatePortion.DateExtended)) { Features |= DateTimeFeature.DayOfYear | DateTimeFeature.DayOfWeek; } if (portion.HasFlag(DatePortion.Time)) { Features |= DateTimeFeature.Hour | DateTimeFeature.Minute; } if (portion.HasFlag(DatePortion.TimeExtended)) { Features |= DateTimeFeature.Second | DateTimeFeature.Millisecond; } }
public void Test_Good_Date_Descriptor_With_Portions(int index, string name, DatePortion portion) { var desc = Descriptor.Create <FakeDate>(); Assert.AreEqual(name, desc.Features[index].Name); Assert.AreEqual(new DateTimeProperty(portion).Features, ((DateTimeProperty)desc.Features[index]).Features); }
public void Test_Good_Date_Descriptor_With_Portions_Fluent() { DatePortion portion = DatePortion.Date | DatePortion.DateExtended; var d = Descriptor.For <FakeDate>() .WithDateTime(f => f.Date1, portion); Assert.AreEqual("Date1", d.Features[0].Name); Assert.AreEqual(new DateTimeProperty(portion).Features, ((DateTimeProperty)d.Features[0]).Features); }
/// <summary>Adds DateTime property to descriptor with previously chained name.</summary> /// <exception cref="DescriptorException">Thrown when a Descriptor error condition occurs.</exception> /// <param name="portion"> /// Which date portions to use (can pipe: DateTimeFeature.Year | /// DateTimeFeature.DayOfWeek) /// </param> /// <returns>descriptor with added property.</returns> public Descriptor AsDateTime(DatePortion portion) { if (this._label) { throw new DescriptorException("Cannot use an DateTime property as a label"); } var p = new DateTimeProperty(portion) { Discrete = true, Name = this._name }; this.AddProperty(p); return(this._descriptor); }
/// <summary>Constructor.</summary> /// <param name="portion">The portion.</param> public DateFeatureAttribute(DatePortion portion) { dp = new DateTimeProperty(portion); }
public void Test_Good_Date_Descriptor_With_Portions(int index, string name, DatePortion portion) { var desc = Descriptor.Create<FakeDate>(); Assert.AreEqual(name, desc.Features[index].Name); Assert.AreEqual(new DateTimeProperty(portion).Features, ((DateTimeProperty)desc.Features[index]).Features); }
/// <summary>Adds DateTime property to descriptor with previously chained name.</summary> /// <exception cref="DescriptorException">Thrown when a Descriptor error condition occurs.</exception> /// <param name="portion">Which date portions to use (can pipe: DateTimeFeature.Year | /// DateTimeFeature.DayOfWeek)</param> /// <returns>descriptor with added property.</returns> public Descriptor AsDateTime(DatePortion portion) { if (_label) throw new DescriptorException("Cannot use an DateTime property as a label"); var p = new DateTimeProperty(portion) { Discrete = true, Name = _name }; AddProperty(p); return _descriptor; }
public DateFeatureAttribute(DatePortion portion) { dp = new DateTimeProperty(portion); }
/// <summary>Constructor.</summary> /// <param name="portion">The portion.</param> public DateTimeProperty(DatePortion portion) { Initialize(portion); }
/// <summary>Initializes this object.</summary> /// <param name="portion">The portion.</param> private void Initialize(DatePortion portion) { Type = typeof(DateTime); Features = 0; if (portion.HasFlag(DatePortion.Date)) Features |= DateTimeFeature.Year | DateTimeFeature.Month | DateTimeFeature.Day; if (portion.HasFlag(DatePortion.DateExtended)) Features |= DateTimeFeature.DayOfYear | DateTimeFeature.DayOfWeek; if (portion.HasFlag(DatePortion.Time)) Features |= DateTimeFeature.Hour | DateTimeFeature.Minute; if (portion.HasFlag(DatePortion.TimeExtended)) Features |= DateTimeFeature.Second | DateTimeFeature.Millisecond; }
/// <summary>Constructor.</summary> /// <param name="portion">The portion.</param> public DateTimeProperty(DatePortion portion) : base() { Initialize(portion); }
/// <summary>Constructor.</summary> /// <param name="portion">The portion.</param> public DateTimeProperty(DatePortion portion) : base() { this.Initialize(portion); }