CK.Keyboard.Key.IStructuredSerializable C# (CSharp) Method

IStructuredSerializable() private method

private IStructuredSerializable ( IStructuredReader sr ) : void
sr IStructuredReader
return void
        void IStructuredSerializable.ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            Debug.Assert( r.Name == "Key" );
            r.Read();
            r.ReadStartElement( "KeyModes" );
            while( r.IsStartElement( "KeyMode" ) )
            {
                // We consider a missing attribute Mode (GetAttribute will return null) as Mode="": we'll use the Context EmptyMode.
                IKeyboardMode keyMode = Context.ObtainMode( r.GetAttribute( "Mode" ) );
                IKeyboardMode availableKeyMode = Keyboard.AvailableMode.Intersect( keyMode );

                if( keyMode == availableKeyMode )
                {
                    // If the mode is defined at the keyboard level,
                    // we create a new or update the existing actual key.
                    KeyMode k = FindOrCreate( keyMode );
                    sr.ReadInlineObjectStructured( k );
                }
                else
                {
                    // Key mode is not defined... This is not a
                    // standard case. Since defining the mode at the keyboard level just because a
                    // key uses it is NOT an option, we choose to create the key with the actually available mode
                    // only if it does not already exist and we DO NOT change an existing key.
                    // This is a conservative approach that avoids blindly accepting biased data from the context.
                    KeyMode k = Find( availableKeyMode );
                    if( k == null )
                    {
                        k = FindOrCreate( keyMode );
                        sr.ReadInlineObjectStructured( k );
                    }
                    else r.Skip();
                }
            }
            r.Read();

            CK.Keyboard.Versionning.V150To160.Key150To160( this );
        }

Same methods

Key::IStructuredSerializable ( IStructuredWriter sw ) : void