Oglr.InGame.TypeLookup.Rehydrate C# (CSharp) Method

Rehydrate() public static method

public static Rehydrate ( System.Xml.Linq.XElement xml ) : void
xml System.Xml.Linq.XElement
return void
        public static void Rehydrate( XElement xml )
        {
            var lookup = new Dictionary<int, string>( ) ;

            xml.CertainElement( @"TypeMap" ).Elements( @"Type" ).ForEach(
                a => lookup[ (int) a.CertainAttribute( @"Index" ) ] = (string) a.CertainAttribute( @"Name" ) ) ;

            xml.Descendants( ).Attributes( ).Where( a => a.Name.LocalName.StartsWith( @"ClrType" ) ).ForEach(
                attribute =>
                    {
                        var index = (int) attribute ;
                        attribute.Value = lookup[ index ] ;
                    } ) ;

            xml.Descendants( ).Where( a => a.Name.LocalName.StartsWith( @"ClrType" ) ).ForEach(
                element =>
                    {
                        var index = (int) element ;
                        element.Value = lookup[ index ] ;
                    } ) ;
        }

Usage Example

Ejemplo n.º 1
0
 public static Level Load(XElement xml)
 {
     TypeLookup.Rehydrate(xml);
     return(new Level(xml));
 }