Server.Property.BindTo C# (CSharp) Méthode

BindTo() public méthode

public BindTo ( Type objectType, PropertyAccess desiredAccess ) : void
objectType System.Type
desiredAccess PropertyAccess
Résultat void
		public void BindTo( Type objectType, PropertyAccess desiredAccess )
		{
			if ( IsBound )
				throw new AlreadyBoundException( this );

			string[] split = m_Binding.Split( '.' );

			PropertyInfo[] chain = new PropertyInfo[split.Length];

			for ( int i = 0; i < split.Length; ++i )
			{
				bool isFinal = ( i == ( chain.Length - 1 ) );

				chain[i] = objectType.GetProperty( split[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase );

				if ( chain[i] == null )
					throw new UnknownPropertyException( this, split[i] );

				objectType = chain[i].PropertyType;

				PropertyAccess access = desiredAccess;

				if ( !isFinal )
					access |= PropertyAccess.Read;

				if ( ( access & PropertyAccess.Read ) != 0 && !chain[i].CanRead )
					throw new WriteOnlyException( this );

				if ( ( access & PropertyAccess.Write ) != 0 && !chain[i].CanWrite )
					throw new ReadOnlyException( this );
			}

			m_Access = desiredAccess;
			m_Chain = chain;
		}

Usage Example

Exemple #1
0
        public static Property Parse(Type type, string binding, PropertyAccess access)
        {
            Property prop = new Property(binding);

            prop.BindTo(type, access);

            return(prop);
        }
All Usage Examples Of Server.Property::BindTo