Silverlight Study Notes-learn more about isolated storage independent storage I (theory)

Source: Internet
Author: User

In the articles "How Silverlight reads files on the client" and "How Silverlight writes files on the client", we initially touched the concept of isolated storage. Here, we further sort out the isolated storage knowledge system and use the example to deepen our understanding.
I,What is isolated storage?
Independent storage is a data storage mechanism that defines a standardized association between code and stored data to provide isolation and security. Standardization also provides other benefits. Administrators can use tools designed to operate on independent storage to configure file buckets, set security policies, and delete unused data. Through independent storage, the Code no longer needs to use a unique path to specify a secure location in the file system, and can protect data from damages to other applications that only have independent storage access permissions. You do not need to specify the "hard-coded" information for the location of the application's storage region.
By using independent storage, some trusted applications can store data in a way controlled by computer security policies. This is especially useful for web applications and downloaded components that require careful operation. The security policy rarely grants such code the permission to access the file system using the standard I/O mechanism, but by default, the code running on the Local Computer, local network, or Internet is granted the permission to use the independent storage.
Silverlight does not provide a way to directly operate system files on the client, but it provides another way to implement the client's requirements for reading and writing data. This is the isolated storage. By using isolated storage, data is always isolated by users in the Virtual File System. The virtual file system can be a file in the root directory or a directory and a file tree. When using isolated storage, you do not need to know where the isolated storage is or how to store data. It has an APIS with an independent storage mechanism, these APIs provide a virtual file system and data flow objects that can access the virtual file system. Its independent storage is based on the independent storage in. NET Framework, so it is a subset of the independent storage in. NET Framework.

 Ii. When to use isolated storageIndependent Storage?
In a word, 5 is required. 3 is not required.
 5 is the most common five situations:
1. The downloaded control. Hosted code controls downloaded from the Internet are not allowed to be written to hard disks through normal I/O classes, but they can be stored independently to persistently save user settings and application status.
2. Persistent web application storage. Web applications are also prohibited from using I/O classes. These programs can use independent storage for the same purpose as the downloaded components.
3. Shared Component Storage. Components shared between applications can use independent storage to provide controllable access to the data storage area.
4. server storage. Server applications can use independent storage to provide separate storage areas for a large number of users requesting applications. Because independent storage is always isolated by users, the server must simulate the user sending the request. In this case, data is isolated based on the identity of the subject, which is the same identity as the user ID of the application.
5. roaming. Applications can also use independent storage and roaming user configuration files. This allows the user's independent storage zone to roam with the configuration file.
In three cases, you should use independent storage instead:
1. Independent storage should not be used to store important secrets (such as keys or passwords that are not encrypted) because it does not protect trusted users of highly trusted code, unmanaged code, or computers.
2. Independent storage should not be used to store code.
3. Independent storage should not be used to store configuration and deployment settings. They are controlled by the Administrator. (Because the Administrator does not control user preferences, user preferences are not considered configuration settings .)
Many applications today use databases to store and isolate data. In this case, one or more rows in the database may represent the storage of a specific user. When the number of users is small, the system overhead of the database is very large, or the database function does not exist, you can choose to use independent storage instead of the database. In addition, when applications require more flexible and complex storage than database row-based storage, independent storage can also provide a feasible alternative.
In addition, in the traditional ASP. isolated storage cannot be used in. We generally use cookies, sessions, and so on to achieve relevant functions. Isolated storage is often used in silverlikes, which is not as secure as cookies, it also does not need to maintain the connection to the server as the session does to inevitably increase the server load.

Iii. Independent storage zones in Silverlight have the following rules
(1) different applications on the same website have different storage areas.
(2) Use different domain names to open the same application of the website and have different storage areas (the storage path is related to the domain name ).
(3) load the same application on different pages and use the same storage zone.
(4) renaming the xap file will lead to the re-creation of the storage zone.
(5) modifying the assembly information (such as guid and version) will not re-create the storage zone.
(6) replace an application with another xap application package of the same name, and the original storage zone will be used directly.

4. Independent storage in Silverlight has the following features:
1. Each Silverlight-based application is allocated a part of its own storage space, but the assembly in the application is shared in the storage space. An application is assigned a unique fixed Identifier value by the server. The Virtual File System of the Silverlight-based application is now accessed with an ID value. The value must be a constant so that the shared location can be found every time the application is running.
2. The APIS stored independently is similar to other file operations, such as file and directory, which are used to access and maintain files or folders. They are all based on filestream APIs to maintain the file content.
3. Independent storage strictly limits the size of data that can be stored by applications. The current ceiling is 1 MB for each application.

5. Two independent storage methods are available in Silverlight:
1. file method. This method uses the isolatedstoragefile class. This class includes two subclasses:
Isolatedstoragesettings. sitesettings-dictionary table saved by site
Isolatedstoragesettings. applicationsettings-dictionary table by key-value saved by Application
Common methods include add, contains, and remove.
2. Key-value method. This method uses the isolatedstoragesettings class. This class includes two methods:
Isolatedstoragefile. getuserstoreforsite ()-obtain the user's independent storage by site
Isolatedstoragefile. getuserstoreforapplication ()-obtain the user's independent storage by Application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.