Ejemplo n.º 1
0
 void IStructuredSerializable.ReadContent( IStructuredReader sr )
 {
     sr.Xml.Read();
     sr.ReadInlineObjectStructuredElement( "PluginStatusCollection", PluginStatusCollection );
     sr.ReadInlineObjectStructuredElement( UriHistoryCollection.EntryName + "Collection", UriHistoryCollection );
     sr.GetService<ISharedDictionaryReader>( true ).ReadPluginsDataElement( "Plugins", this );
 }
Ejemplo n.º 2
0
        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 );
        }
Ejemplo n.º 3
0
 internal void ReadInlineContent( IStructuredReader sr )
 {
     XmlReader r = sr.Xml;
     Keyboard current = null;
     r.Read();
     while( r.IsStartElement( "Keyboard" ) )
     {
         string n = r.GetAttribute( "Name" );
         Keyboard kb = Create( n );
         bool isCurrent = r.GetAttribute( "IsCurrent" ) == "1";
         sr.ReadInlineObjectStructured( kb );
         if( isCurrent ) current = kb;
     }
     if( current != null ) Current = current;
 }
Ejemplo n.º 4
0
        void IStructuredSerializable.ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            bool isCurrent = false;

            //We are on the <Layouts> tag, we mode on to the content
            r.Read();

            while( r.IsStartElement( "Layout" ) )
            {
                Layout l = null;
                string n = r.GetAttribute( "Name" );
                if( n == null ) n = String.Empty;

                l = this[n];
                if( l == null ) l = Create( n );

                isCurrent = r.GetAttributeBoolean( "IsCurrent", false );
                sr.ReadInlineObjectStructured( l );
                if( isCurrent ) _currentLayout = l;
            }
        }
Ejemplo n.º 5
0
 internal ReaderBookmark( IStructuredReader r )
 {
     _storageVersion = r.StorageVersion;
     _xmlContext = new XmlParserContext( r.Xml.NameTable, null, r.Xml.XmlLang, r.Xml.XmlSpace );
     _skippedFragment = r.Xml.ReadOuterXml();
 }
Ejemplo n.º 6
0
 public void ReadContent( IStructuredReader sr )
 {
     XmlReader r = sr.Xml;
     r.Read();
     r.ReadStartElement( "Bind" );
     Target = r.GetAttribute( "Master" );
     Origin = r.GetAttribute( "Origin" );
     Position = r.GetAttributeEnum( "Position", BindingPosition.None );
     r.Read();
 }
Ejemplo n.º 7
0
            public void ReadContent( IStructuredReader sr )
            {
                XmlReader r = sr.Xml;
                r.Read();
                r.ReadStartElement( "Bindings" );
                if( r.IsStartElement( "Bind" ) )
                {
                    while( r.IsStartElement( "Bind" ) )
                    {
                        Bindings.Add( new SerializableBinding( r.GetAttribute( 0 ), r.GetAttribute( 1 ), r.GetAttributeEnum<BindingPosition>( "Position", BindingPosition.None ) ) );
                        r.Read();
                    }
                }

                r.ReadEndElement();
            }
Ejemplo n.º 8
0
        protected virtual LoadResult DoRead(Func <IStructuredReader, IReadOnlyList <ISimpleErrorMessage> > reader, IStructuredReader structuredReader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (structuredReader == null)
            {
                throw new ArgumentNullException("structuredReader");
            }

            return(new LoadResult(_ctx.LogCenter, reader.Method, false, reader(structuredReader)));
        }
Ejemplo n.º 9
0
 void IStructuredSerializable.ReadContent( IStructuredReader sr )
 {
     ReadInlineContent( sr.Xml );
 }
Ejemplo n.º 10
0
        void IStructuredSerializable.ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            Debug.Assert( r.Name == "LayoutKey" );
            r.Read();
            while( r.IsStartElement( "LayoutKeyMode" ) )
            {
                IKeyboardMode keyMode = _key.Context.ObtainMode( r.GetAttribute( "Mode" ) );
                IKeyboardMode availableKeyMode = _key.Keyboard.AvailableMode.Intersect( keyMode );

                LayoutKeyMode k = FindOrCreate( availableKeyMode );
                sr.ReadInlineObjectStructured( k );
            }
        }
Ejemplo n.º 11
0
        void IStructuredSerializable.ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            Debug.Assert( r.Name == "Keyboard" );

            Rename( r.GetAttribute( "Name" ) );
            r.ReadStartElement( "Keyboard" );

            sr.ReadInlineObjectStructuredElement( "RequirementLayer", _reqLayer );

            if( r.IsStartElement( "Modes" ) )
            {
                string currentMode = r.GetAttribute( "Current" );
                if( r.IsEmptyElement )  r.Read();
                else
                {
                    r.Read();

                    IKeyboardMode futureAvailableMode = Context.EmptyMode;
                    while( r.IsStartElement( "Mode" ) )
                    {
                        futureAvailableMode = futureAvailableMode.Add( Context.ObtainMode( r.ReadElementContentAsString() ) );
                    }
                    AvailableMode = futureAvailableMode;
                    CurrentMode = Context.ObtainMode( currentMode );
                    r.ReadEndElement(); // Modes;
                }
            }
            sr.ReadInlineObjectStructuredElement( "Zones", Zones );
            sr.ReadInlineObjectStructuredElement( "Layouts", Layouts );
        }
Ejemplo n.º 12
0
        public void ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            r.Read();
            Dictionary<Guid,PluginStatus> newContent = new Dictionary<Guid, PluginStatus>();
            while( r.IsStartElement( "PluginStatus" ) )
            {
                Guid guid = new Guid( r.GetAttribute( "Guid" ) );
                ConfigPluginStatus status = (ConfigPluginStatus)Enum.Parse( typeof( ConfigPluginStatus ), r.GetAttribute( "Status" ) );
                newContent[guid] = new PluginStatus( this, guid, status );
                r.Skip();
            }
            _pluginStatusDic.Clear();
            _pluginStatusDic.AddRange( newContent );

            //may eventually be replaced by some code in SolvedPluginConfiguration
            //Without that, SolvedPluginConfiguration's ResolveConfiguration method is not called
            Change(ChangeStatus.ContainerUpdate, Guid.Empty, 0);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new <see cref="ObjectWriteExDataEventArgs"/>.
 /// </summary>
 /// <param name="r">Structured reader.</param>
 /// <param name="o">Object read.</param>
 public ObjectReadExDataEventArgs( IStructuredReader r, object o )
 {
     Obj = o;
     Reader = r;
 }
Ejemplo n.º 14
0
 public void ReadContent( IStructuredReader sr )
 {
     sr.Xml.Read();
     sr.Xml.ReadStartElement( "Value" );
     Value = sr.Xml.ReadContentAsInt();
     sr.Xml.ReadEndElement();
 }
Ejemplo n.º 15
0
 void OnObjectRead( object o, IStructuredReader rSub )
 {
     ObjectReadExDataEventArgs e = new ObjectReadExDataEventArgs( rSub, o );
     while( Xml.IsStartElement() )
     {
         e.Handled = false;
         using( Root.CreateJail() )
         {
             RaiseReadEvent( e );
         }
     }
 }
Ejemplo n.º 16
0
        void IStructuredSerializable.ReadContent( IStructuredReader sr )
        {
            XmlReader r = sr.Xml;
            Debug.Assert( r.Name == "Zone" );
            if( !r.IsEmptyElement )
            {
                r.Read();

                if( r.IsStartElement( "Keys" ) )
                {
                    r.Read();
                    while( r.IsStartElement( "Key" ) )
                    {
                        Key k = Create( _keys.Count );
                        sr.ReadInlineObjectStructured( k );
                    }
                    r.Read();
                }
            }
        }
Ejemplo n.º 17
0
        protected virtual LoadResult DoRead( Func<IStructuredReader, IReadOnlyList<ISimpleErrorMessage>> reader, IStructuredReader structuredReader )
        {
            if( reader == null ) throw new ArgumentNullException( "reader" );
            if( structuredReader == null ) throw new ArgumentNullException( "structuredReader" );

            return new LoadResult( _ctx.LogCenter, reader.Method, false, reader( structuredReader ) );
        }
Ejemplo n.º 18
0
        public IReadOnlyList<ISimpleErrorMessage> LoadSystemConfig( IStructuredReader reader )
        {
            if( reader == null ) throw new ArgumentNullException( "reader" );

            // Creates reader.
            IList<ReadElementObjectInfo> objs;
            using( var dr = _dic.RegisterReader( reader, MergeMode.ReplaceExistingTryMerge ) )
            {
                reader.ReadInlineObjectStructuredElement( "System", _systemConfiguration );                
                objs = dr.ErrorCollector;
            }
            _systemConfiguration.UriHistoryCollection.FireLoadedChangedEvents();
            IsSystemConfigDirty = false;
            return objs.ToReadOnlyList();
        }