Exemple #1
0
        /// <SecurityNote>
        /// Review - checks member visibility to calculate if access to it requires MemberAccessPermission for deserialization.
        ///          since this information is used to determine whether to give the generated code access
        ///          permissions to private members, any changes to the logic should be reviewed.
        /// </SecurityNote>
        internal bool RequiresMemberAccessForSet(string[] serializationAssemblyPatterns)
        {
            MemberInfo memberInfo = MemberInfo;
            FieldInfo  field      = memberInfo as FieldInfo;

            if (field != null)
            {
                return(DataContract.FieldRequiresMemberAccess(field, serializationAssemblyPatterns));
            }
            else
            {
                PropertyInfo property  = (PropertyInfo)memberInfo;
                MethodInfo   setMethod = property.SetMethod;
                if (setMethod != null)
                {
                    return(DataContract.MethodRequiresMemberAccess(setMethod, serializationAssemblyPatterns) || !DataContract.IsTypeVisible(property.PropertyType, serializationAssemblyPatterns));
                }
            }
            return(false);
        }
Exemple #2
0
        /// <SecurityNote>
        /// Review - checks member visibility to calculate if access to it requires MemberAccessPermission for deserialization.
        ///          since this information is used to determine whether to give the generated code access
        ///          permissions to private members, any changes to the logic should be reviewed.
        /// </SecurityNote>
        internal bool RequiresMemberAccessForSet()
        {
            MemberInfo memberInfo = MemberInfo;
            FieldInfo  field      = memberInfo as FieldInfo;

            if (field != null)
            {
                return(DataContract.FieldRequiresMemberAccess(field));
            }
            else
            {
                PropertyInfo property  = (PropertyInfo)memberInfo;
                MethodInfo   setMethod = property.SetMethod;
                if (setMethod != null)
                {
                    return(DataContract.MethodRequiresMemberAccess(setMethod) || !DataContract.IsTypeVisible(property.PropertyType));
                }
            }
            return(false);
        }
        internal bool RequiresMemberAccessForSet()
        {
            System.Reflection.MemberInfo memberInfo = this.MemberInfo;
            FieldInfo field = memberInfo as FieldInfo;

            if (field != null)
            {
                return(DataContract.FieldRequiresMemberAccess(field));
            }
            PropertyInfo info3     = (PropertyInfo)memberInfo;
            MethodInfo   setMethod = info3.GetSetMethod(true);

            if (setMethod == null)
            {
                return(false);
            }
            if (!DataContract.MethodRequiresMemberAccess(setMethod))
            {
                return(!DataContract.IsTypeVisible(info3.PropertyType));
            }
            return(true);
        }