コード例 #1
0
        private void InitOrder(IEnumerable<CustomAttribute> aspectAttributes)
        {
            AspectRoleDependencyAttributes =
                aspectAttributes.Where(
                    c => c.AttributeType.FullName == typeof (AspectRoleDependencyAttribute).FullName).ToList();

            if (AspectRoleDependencyAttributes.Count == 0)
                return;

            var aspectOrder = new AspectOrder(this);
            foreach (var roleDependencyAttribute in AspectRoleDependencyAttributes)
            {
                var role = (string) roleDependencyAttribute.ConstructorArguments[2].Value;
                if (role == Role)
                {
                    var msg = string.Format(AspectCanTHaveRoleAndBeOrderedBeforeOrAfterThatRole, Name, role);
                    throw new InvalidAspectConfigurationException(msg);
                }

                var position = (AspectDependencyPosition) roleDependencyAttribute.ConstructorArguments[1].Value;

                aspectOrder.AddRole(role, position);
            }

            Order = aspectOrder;
        }
コード例 #2
0
        private void InitOrder(IEnumerable <CustomAttribute> aspectAttributes)
        {
            AspectRoleDependencyAttributes =
                aspectAttributes.Where(
                    c => c.AttributeType.FullName == AttributeFullNames.AspectRoleDependencyAttribute).ToList();

            if (AspectRoleDependencyAttributes.Count == 0)
            {
                return;
            }

#pragma warning disable 0618
            var aspectOrder = new AspectOrder(this);
#pragma warning restore 0618

            foreach (var roleDependencyAttribute in AspectRoleDependencyAttributes)
            {
                var role = (string)roleDependencyAttribute.ConstructorArguments[2].Value;
                if (role == Role)
                {
                    var msg = string.Format(AspectCanTHaveRoleAndBeOrderedBeforeOrAfterThatRole, Name, role);
                    throw new InvalidAspectConfigurationException(msg);
                }

                var position = (int)roleDependencyAttribute.ConstructorArguments[1].Value;

                aspectOrder.AddRole(role, position);
            }

            Order = aspectOrder;
        }