Server.Commands.Properties.GetCPA C# (CSharp) Méthode

GetCPA() public static méthode

public static GetCPA ( PropertyInfo p ) : Server.CommandPropertyAttribute
p System.Reflection.PropertyInfo
Résultat Server.CommandPropertyAttribute
		public static CPA GetCPA( PropertyInfo p )
		{
			object[] attrs = p.GetCustomAttributes( typeofCPA, false );

			if ( attrs.Length == 0 )
				return null;

			return attrs[0] as CPA;
		}

Usage Example

Exemple #1
0
        public bool HasAccess(Type type)
        {
            if (type != null)
            {
                PropertyInfo[] allProps = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                foreach (PropertyInfo prop in allProps)
                {
                    CPA attr = Properties.GetCPA(prop);
                    if (attr != null && ((prop.CanRead && m_From.AccessLevel < attr.ReadLevel) || (prop.CanWrite && m_From.AccessLevel < attr.WriteLevel)))
                    {
                        m_From.SendMessage("The item {0} contains the property {1}, which you do not have access to.", type.Name, prop.Name);
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
All Usage Examples Of Server.Commands.Properties::GetCPA