tests/DotNetCommon.Test/Extensions/TypeExtensions/Context.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace DotNetCommon.Test.Extensions.TypeExtensions
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using DotNetCommon;
    using DotNetCommon.Extensions;

    public class Context
    {
        protected IEnumerable<PropertyInfo> PropertesWithAttribute;

        protected void When_getting_properties_with_specific_attribute_for_type<T, TA>(bool inherit) where TA : Attribute
        {
            PropertesWithAttribute = typeof(T).GetPropertiesWithAttribute<TA>(inherit);
        }

        protected class SampleParent
        {
            [My("_parentId")]
            public int ParentId { get; set; }

            public string ParentName { get; set; }

            [My("_privateParentName")]
            private string PrivateParentName { get; set; }

            [Obsolete("Just a test")]
            public double ParentAge { get; set; }
        }

        protected class SampleChild : SampleParent
        {
            [My("_childId")]
            public int ChildId { get; set; }

            [My("_childAge")]
            public double ChildAge { get; set; }

            public string ChildName { get; set; }

            [My("_privateChildName")]
            private string PrivateChildName { get; set; }

            [Obsolete("Just another test")]
            public decimal Salary { get; set; }
        }

        [AttributeUsage(AttributeTargets.Property)]
        protected sealed class MyAttribute : Attribute
        {
            public string Name { get; private set; }

            public MyAttribute(string name)
            {
                Ensure.NotNull(name, "name");
                Name = name;
            }
        }
    }
后面还有 1 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。