コード例 #1
0
ファイル: DateTimeProperty.cs プロジェクト: notesjor/numl
        /// <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;
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: DateFeatureAttribute.cs プロジェクト: notesjor/numl
 /// <summary>Constructor.</summary>
 /// <param name="portion">The portion.</param>
 public DateFeatureAttribute(DatePortion portion)
 {
     dp = new DateTimeProperty(portion);
 }
コード例 #6
0
ファイル: DescriptorTests.cs プロジェクト: vladtepes1473/numl
 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);
 }
コード例 #7
0
ファイル: DescriptorProperty.cs プロジェクト: m-abubakar/numl
        /// <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;
        }
コード例 #8
0
ファイル: NumlAttributes.cs プロジェクト: budbjames/numl
 public DateFeatureAttribute(DatePortion portion)
 {
     dp = new DateTimeProperty(portion);
 }
コード例 #9
0
ファイル: DateTimeProperty.cs プロジェクト: notesjor/numl
 /// <summary>Constructor.</summary>
 /// <param name="portion">The portion.</param>
 public DateTimeProperty(DatePortion portion)
 {
     Initialize(portion);
 }
コード例 #10
0
ファイル: DateTimeProperty.cs プロジェクト: sethjuarez/numl
        /// <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;
        }
コード例 #11
0
ファイル: DateTimeProperty.cs プロジェクト: sethjuarez/numl
 /// <summary>Constructor.</summary>
 /// <param name="portion">The portion.</param>
 public DateTimeProperty(DatePortion portion)
     : base()
 {
     Initialize(portion);
 }
コード例 #12
0
 /// <summary>Constructor.</summary>
 /// <param name="portion">The portion.</param>
 public DateTimeProperty(DatePortion portion)
     : base()
 {
     this.Initialize(portion);
 }