tailieunhanh - Professional Windows PowerShell Programming phần 9

Các đối tượng Deserialized được tạo ra từ XML được tuần tự các kết quả từ clixml xuất khẩu. Clixml nhập tạo ra các đối tượng deserialized XML trung gian (thường là định dạng tập tin). Điều quan trọng là phải hiểu là các đối tượng deserialized khác nhau từ các đối tượng ban đầu trong một số cách khác nhau. | Chapter 8 Formatting Output Formatting Deserialized Objects Deserialized objects are created from serialized XML that results from export-clixml. Import-clixml creates deserialized objects from the intermediate XML usually in file format . What s important to understand is that the deserialized objects differ from the original objects in a number of ways. First the object is considered dead. This means that instead of having an instance of the original object the deserialized object is really a PSObject object with properties. For example calling methods on a deserialized Process object won t work. The methods don t exist and there is no instance of a Process object to invoke them against. Second all the properties that existed for the original live object may not be present in the deserialized object. The properties that are serialized to XML are controlled via the serialization properties in the type s configuration file. Lastly the type of the object is different. For example if the original object s type name was System. the deserialized object s type name is . Process. The different type names enable PowerShell to treat deserialized objects differently from their original live counterparts if desired. For formatting purposes you can choose to use the same view for deserialized objects create different views or not provide any view for them at all and let default formatting take place. When defining a view it is possible to add multiple type names to the ViewSelectedBy node. Here s an example of what the ViewSelectedBy node would look like for live and deserialized Process objects . ViewSelectedBy TypeName TypeName TypeName .Process TypeName ViewSelectedBy . Make sure that if a single view is formatting deserialized objects it doesn t access any methods in the script block that rely on a live instance of the object. Stick to properties and you should be

TỪ KHÓA LIÊN QUAN