コード例 #1
0
 public static void CheckReadOnly <T>(IAttributeConverter <T> converter, IProjectObject po,
                                      RedDotAttribute attribute) where T : IProjectObject
 {
     if (converter.IsReadOnly || attribute.IsReadOnly)
     {
         throw new SmartAPIException(po.Session.ServerLogin,
                                     string.Format("Writing to attribute {0} is forbidden", attribute.Description));
     }
 }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: keith-anders/NAdapter
        /// <summary>
        /// Common logic for handling the data on an IAttributeConverter and applying it to a member
        /// </summary>
        /// <param name="converter">The IAttributeConverter whose data is being applied</param>
        /// <param name="targets">The target to which the attribute is being applied</param>
        /// <param name="adder">A function to add an attribute to the member. Necessary because
        /// SetCustomAttribute is not on a common interface on the member Builder types.</param>
        /// <param name="customAttributeData">The data on the attributes to convert</param>
        internal static void HandleAttributes(this IAttributeConverter converter, AttributeTargets targets, Action <CustomAttributeBuilder> adder, CustomAttributeData[] customAttributeData)
        {
            foreach (var attData in customAttributeData)
            {
                var cBuilder = new CustomAttributeBuilderBuilder(attData);
                var att      = cBuilder.BuildAttribute();
                if (converter.Convert(cBuilder, true, targets, out CustomAttributeBuilderBuilder aBuilder))
                {
                    if (aBuilder != null)
                    {
                        adder(aBuilder.Build());
                    }
                }
                else
                {
                    adder(cBuilder.Build());
                }
            }

            foreach (var newAttBuilder in converter.GetNewAttributes())
            {
                adder(newAttBuilder.Build());
            }
        }
コード例 #3
0
 public AttributeConverterDescriptor(Type type, IAttributeConverter converter)
 {
     Type      = type;
     Converter = converter;
 }
コード例 #4
0
 public void Register(Type propertyType, IAttributeConverter converter)
 {
     cache[propertyType] = converter;
 }