/// <summary>
        /// Find shadow property in given type corresponding to property.
        /// </summary>
        public static Property FindShadow(this TypeNode parent, Property property)
        {
            if (property == null || property.Name == null)
            {
                return null;
            }

            MemberList members = parent.GetMembersNamed(property.Name);
            for (int i = 0, n = members == null ? 0 : members.Count; i < n; i++)
            {
                var p = members[i] as Property;
                if (p == null) continue;

                if (p.Parameters.MatchShadow(property.Parameters))
                {
                    return p;
                }
            }

            return null;
        }
Example #2
0
 public virtual Property VisitProperty(Property property)
 {
     if (property == null) return null;
     property.Attributes = this.VisitAttributeList(property.Attributes);
     property.Parameters = this.VisitParameterList(property.Parameters);
     property.Type = this.VisitTypeReference(property.Type);
     return property;
 }
Example #3
0
        private void SetAttributeProperty(Property/*!*/ prop, System.Attribute attr, object val)
        {
            //This could execute partially trusted code, so set up a very restrictive execution environment
            //TODO: skip this if the attribute is from a trusted assembly
            System.Reflection.PropertyInfo propInfo = prop.GetPropertyInfo();
            if(propInfo == null)
                return;
            //Because we invoke the setter through reflection, a stack walk is performed. The following two commented-out statements
            //would cause the stack walk to fail.
            //For now, we will run the setter in full trust until we work around this.
            //For VS2005 and later, we will construct a DynamicMethod, wrap it in a delegate, and invoke that.

            //System.Security.PermissionSet perm = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.None);
            //perm.PermitOnly();
            try
            {
                propInfo.SetValue(attr, val, null);
            }
            catch { }
        }