{"id":157,"date":"2008-12-14T20:12:12","date_gmt":"2008-12-14T19:12:12","guid":{"rendered":"http:\/\/www.leading-edge-dev.de\/?p=157"},"modified":"2010-07-10T10:56:50","modified_gmt":"2010-07-10T09:56:50","slug":"live-framework-ctp-4-net-loe-and-data-basics","status":"publish","type":"post","link":"https:\/\/www.minddriven.de\/index.php\/technology\/microsoft\/cloud-computing\/live-services\/live-framework-ctp-4-net-loe-and-data-basics","title":{"rendered":"Live Framework CTP #4 &#8211; .NET: LOE and data basics"},"content":{"rendered":"<p>Instead of creating new Silverlight applications, which run in your mesh and use the data, you can furthermore <em>mesh-enable<\/em> your existing .NET applications or create new mesh-enabled .NET applications from scratch. That&#8217;s pretty easy and in the following post I will show you some basics&#8230;<\/p>\n<h2>The Live Operating Environment (LOE)<\/h2>\n<p>First there is the <strong>Live Operating Environment<\/strong>, being the center point of all your operations to the mesh. With an object of type <code>LiveOperatingEnvironment<\/code> you can connect to your online mesh or to your local mesh storage sync or async and perform any operation you want. But that&#8217;s just the developer&#8217;s point of view. In fact, the LOE (every instance of it) is an <strong>agent component<\/strong>, responsible for providing an efficient cache and for background synchronization of data on your device to other devices (other instances of the LOE on those devices) in your mesh, including the &#8222;special&#8220; LOE in the cloud. Running an LOE means exposing data through a RESTful interface at port 2048 of your machine &#8211; one could check the presence of this and either connect locally or to the cloud.<\/p>\n<p>Connecting to your online\/cloud LOE means that you have to provide your credentials on connect, whereas you can connect locally without those. I like to work on my local storage, it&#8217;s fast and safe. But there are some limitations (at the moment?) there. Due to the lack of file synchronization, files as data entries are not available from the local storage, so you have to connect to your online LOE instead. Furthermore you only get your local device in the <code>Devices<\/code> collection of your LOE and it&#8217;s not possible to have a look at your contacts and profiles\u00a0for instance. What I expected first or want to have for the &#8222;final&#8220; version of the Live Framework: just one connection method, which takes local data if it&#8217;s available and instead connects to the cloud LOE. It should be no problem, because the various LOEs (loal, cloud) are taking responsibility over synchronization&#8230; or have I forgotten to consider something?<\/p>\n<p>Well, let&#8217;s take a look to connecting to your (online) LOE. Just create an instance of <code>LiveOperatingEnvironment<\/code> and connect via the <code>Connect()<\/code> method (local LOE: use <code>ConnectLocally()<\/code> instead). You have to pass your credentials as a parameter, which could come from a secure source or from user input:<\/p>\n<pre class=\"brush:csharp\">var creds = new NetworkCredential(\"username\", \"password\", \"https:\/\/user-ctp.windows.net\");\r\nvar loe = new LiveOperatingEnvironment();\r\n\r\nloe.Connect(creds);<\/pre>\n<p><code>https:\/\/user-ctp.windows.net<\/code> is the fixed base URI when connecting to your cloud LOE. After you&#8217;ve been connected, you get access to your mesh items (<a href=\"http:\/\/www.leading-edge-dev.de\/?p=147\">shown before<\/a>) and can start meshing \ud83d\ude42<\/p>\n<h2>Mesh Objects, Data Feeds and Data Entries<\/h2>\n<p>A <em>mesh object<\/em> is a container for concrete data in your mesh. There are several types of mesh objects and you are allowed to create your own application specific types, which your applications can work with. Mesh objects can be files, folders, applications, custom objects etc.. You have access to the mesh objects via <code>loe.Mesh.MeshObjects.Entries<\/code> and have the possibililty to easily iterate over them in this way.<\/p>\n<p>Every mesh object consists of <code>DataFeeds<\/code>, <code>Members<\/code>, <code>Mappings<\/code> and <code>News<\/code>, as stated <a href=\"http:\/\/www.leading-edge-dev.de\/?p=147\">before<\/a>. Interesting at this point are the data feeds. Those are further containers for the <em>real<\/em> data entries. Why this abstraction? Over data feeds you can group your data together, separating logically distinct data. Every <code>DataFeed<\/code> object finally contains a <code>DataEntries<\/code> collection, which gives you access to the underlying data and information about that. Note: there is no obvious possibility to store <strong>hierarchical data entries<\/strong> at the moment. There is one level of data entries and a data entry can&#8217;t contain other data entries. So that&#8217;s a drawback at this point and I don&#8217;t like\/understand it much. The <a href=\"http:\/\/blogs.conchango.com\/jamiethomson\/archive\/2008\/11\/03\/livefx-recursing-hierarchical-dataentries.aspx\">solution<\/a> for that is: every data entry contains a parent ID and over that you can identify top level data entries and those, who are child entries of another data entry. But that&#8217;s not a good solution, isn&#8217;t it? Hopefully there will be done some work on that&#8230;<\/p>\n<p>Well, a nice little .NET console application would be to show us the titles of all mesh objects, of their data feeds and data entries in there. That&#8217;s no problem and leads to the following little program:<\/p>\n<pre class=\"brush:csharp\">var creds = new NetworkCredential(\"username\", \"password\", \"https:\/\/user-ctp.windows.net\");\r\nvar loe = new LiveOperatingEnvironment();\r\nloe.Connect(creds);\r\nif (loe.IsRunning())\r\n{\r\n    foreach (var meshobj in loe.Mesh.MeshObjects.Entries)\r\n    {\r\n        Console.WriteLine(\"- \" + meshobj.Resource.Title);\r\n        foreach (var feed in meshobj.DataFeeds.Entries)\r\n        {\r\n            Console.WriteLine(\"  + \" + feed.Resource.Title);\r\n            foreach (var entry in feed.DataEntries.Entries)\r\n                Console.WriteLine(\"    * \" + entry.Resource.Title);\r\n        }\r\n    }\r\n}\r\nConsole.ReadLine();<\/pre>\n<h2>Create, Update, Delete<\/h2>\n<p>The creation, update and delete of all the three entities <code>MeshObject<\/code>, <code>DataFeed<\/code> and <code>DataEntry<\/code> is made really easy. Just call the <code>Add()<\/code> and <code>Remove()<\/code> methods of the particular collections. The rest is done automatically by the Live Framework. The update process isn&#8217;t problematic, too. Just change your entity and then make sure to call the <code>Update()<\/code> method of this entity. Because everything in your Live Operating Environment has <strong>LiveItem<\/strong> as base type, you have an integrated and consistent CRUD process.<\/p>\n<h2>Little example<\/h2>\n<p>The following screenshot shows a little WinForms application, that connects to my mesh and over which I can perform the CRUD process on my mesh entities. Further on I can navigate through my mesh and if I got images as data entries, those are downloaded automatically as media resource stream and then shown up at the picture box on the right. In the screen below is shown the (IKEA-powered \ud83d\ude09 ) couch corner of my little apartment&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-160\" style=\"border: black 1px solid;\" title=\"Live Framework .NET WinForms example application\" src=\"http:\/\/www.leading-edge-dev.de\/wp-content\/uploads\/2008\/12\/livefx_loaded_picture1.png\" alt=\"Live Framework .NET WinForms example application\" width=\"648\" height=\"326\" srcset=\"https:\/\/www.minddriven.de\/wp-content\/uploads\/2008\/12\/livefx_loaded_picture1.png 648w, https:\/\/www.minddriven.de\/wp-content\/uploads\/2008\/12\/livefx_loaded_picture1-300x150.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/p>\n<p>In upcoming blog posts I want to show you more information about handling data entries, media resources and hierarchical data. So stay tuned \ud83d\ude42<\/p>\n<p><a href=\"http:\/\/www.dotnetkicks.com\/kick\/?url=http%3a%2f%2fwww.leading-edge-dev.de%2f%3fp%3d157\"><img decoding=\"async\" src=\"http:\/\/www.dotnetkicks.com\/Services\/Images\/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.leading-edge-dev.de%2f%3fp%3d157\" border=\"0\" alt=\"kick it on DotNetKicks.com\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Instead of creating new Silverlight applications, which run in your mesh and use the data, you can furthermore mesh-enable your existing .NET applications or create new mesh-enabled .NET applications from scratch. That&#8217;s pretty easy and in the following post I will show you some basics&#8230; The Live Operating Environment (LOE) First there is the Live &hellip; <a href=\"https:\/\/www.minddriven.de\/index.php\/technology\/microsoft\/cloud-computing\/live-services\/live-framework-ctp-4-net-loe-and-data-basics\" class=\"more-link\"><span class=\"screen-reader-text\">Live Framework CTP #4 &#8211; .NET: LOE and data basics<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87,89,71],"tags":[96,99,100,55,90,97,98],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-live-framework","category-live-mesh","category-live-services","tag-crud","tag-data-entries","tag-data-feeds","tag-live--framework","tag-live-framework-ctp","tag-live-operating-environment","tag-mesh-objects"],"_links":{"self":[{"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":12,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":950,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions\/950"}],"wp:attachment":[{"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.minddriven.de\/index.php\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}