@@ -9,64 +9,92 @@ namespace Moryx.AbstractionLayer.Resources
99 public static class ResourceFacadeExtensions
1010 {
1111 /// <summary>
12- /// Read data from a resource
12+ /// Read data from a resource by the given resource-proxy
1313 /// </summary>
14- public static TResult Read < TResult > ( this IResourceManagement facade , long resourceId , Func < Resource , TResult > accessor )
14+ /// <param name="facade">Extended facade</param>
15+ /// <param name="proxy">Resource proxy reference</param>
16+ /// <param name="accessor">Accessor delegate for the resource</param>
17+ /// <remarks>
18+ /// The <param name="accessor"></param> action uses the actual resource instance, not wrapped by proxy.
19+ /// As a result, all internal members, including properties and
20+ /// methods not exposed through interfaces, are accessible.
21+ ///
22+ /// This API is intended primarily for endpoint controllers that must export or
23+ /// inspect the full internal state of a resource.
24+ ///
25+ /// Because the returned objects are the originals, the API consumer is responsible for keeping and watching the life-cycle.
26+ /// Use with extreme caution. Do not keep the instance in memory for later usage.
27+ /// </remarks>
28+ public static TResult ReadUnsafe < TResult > ( this IResourceManagement facade , IResource proxy , Func < Resource , TResult > accessor )
1529 {
16- return facade . Read ( resourceId , accessor ) ;
30+ return facade . ReadUnsafe ( proxy . Id , accessor ) ;
1731 }
1832
1933 /// <summary>
20- /// Read data from a resource
34+ /// Modify the resource by the given resource-proxy
2135 /// </summary>
22- public static TResult Read < TResult > ( this IResourceManagement facade , IResource proxy , Func < Resource , TResult > accessor )
23- {
24- return facade . Read ( proxy . Id , accessor ) ;
25- }
26-
27- /// <summary>
28- /// Modify the resource.
29- /// </summary>
30- /// <param name="resourceId"></param>
31- /// <param name="modifier">Modifier delegate, must return <value>true</value> in order to save changes</param>
32- /// <param name="facade"></param>
33- public static void Modify ( this IResourceManagement facade , long resourceId , Func < Resource , bool > modifier )
34- {
35- facade . Modify ( resourceId , modifier ) ;
36- }
37-
38- /// <summary>
39- /// Modify the resource.
40- /// </summary>
41- /// <param name="proxy"></param>
36+ /// <param name="facade">Extended facade</param>
37+ /// <param name="proxy">Resource proxy reference</param>
4238 /// <param name="modifier">Modifier delegate, must return <value>true</value> in order to save changes</param>
43- /// <param name="facade"></param>
44- public static void Modify ( this IResourceManagement facade , IResource proxy , Func < Resource , bool > modifier )
39+ /// <remarks>
40+ /// The <param name="modifier"></param> action uses the actual resource instance, not wrapped by proxy.
41+ /// As a result, all internal members, including properties and
42+ /// methods not exposed through interfaces, are accessible.
43+ ///
44+ /// This API is intended primarily for endpoint controllers that must export or
45+ /// inspect the full internal state of a resource.
46+ ///
47+ /// Because the returned objects are the originals, the API consumer is responsible for keeping and watching the life-cycle.
48+ /// Use with extreme caution. Do not keep the instance in memory for later usage.
49+ /// </remarks>
50+ public static void ModifyUnsafe ( this IResourceManagement facade , IResource proxy , Func < Resource , bool > modifier )
4551 {
46- facade . Modify ( proxy . Id , modifier ) ;
52+ facade . ModifyUnsafe ( proxy . Id , modifier ) ;
4753 }
4854
4955 /// <summary>
50- /// Modify the resource.
56+ /// Modify the resource.
5157 /// </summary>
52- /// <param name="proxy"></param>
58+ /// <param name="facade">Extended facade</param>
59+ /// <param name="proxy">Resource proxy reference</param>
5360 /// <param name="modifier">Modifier delegate, must return <value>true</value> in order to save changes</param>
54- /// <param name="facade"></param>
55- /// <param name="context"></param>
56- public static void Modify < TContext > ( this IResourceManagement facade , IResource proxy , Func < Resource , TContext , bool > modifier , TContext context )
61+ /// <param name="context">Additional context, used within the <param cref="modifier"/></param>
62+ /// <remarks>
63+ /// The <param name="modifier"></param> action uses the actual resource instance, not wrapped by proxy.
64+ /// As a result, all internal members, including properties and
65+ /// methods not exposed through interfaces, are accessible.
66+ ///
67+ /// This API is intended primarily for endpoint controllers that must export or
68+ /// inspect the full internal state of a resource.
69+ ///
70+ /// Because the returned objects are the originals, the API consumer is responsible for keeping and watching the life-cycle.
71+ /// Use with extreme caution. Do not keep the instance in memory for later usage.
72+ /// </remarks>
73+ public static void ModifyUnsafe < TContext > ( this IResourceManagement facade , IResource proxy , Func < Resource , TContext , bool > modifier , TContext context )
5774 {
58- facade . Modify ( proxy . Id , resource => modifier ( resource , context ) ) ;
75+ facade . ModifyUnsafe ( proxy . Id , resource => modifier ( resource , context ) ) ;
5976 }
6077
6178 /// <summary>
62- /// Create a resource with typed initializer
79+ /// Create and initialize a resource with typed initializer
6380 /// </summary>
64- /// <param name="facade"></param>
65- /// <param name="initializer"></param>
66- public static long Create < TResource > ( this IResourceManagement facade , Action < TResource > initializer )
81+ /// <remarks>
82+ /// The <param name="initializer"></param> action uses the actual resource instance, not wrapped by proxy.
83+ /// As a result, all internal members, including properties and
84+ /// methods not exposed through interfaces, are accessible.
85+ ///
86+ /// This API is intended primarily for endpoint controllers that must export or
87+ /// inspect the full internal state of a resource.
88+ ///
89+ /// Because the returned objects are the originals, the API consumer is responsible for keeping and watching the life-cycle.
90+ /// Use with extreme caution. Do not keep the instance in memory for later usage.
91+ /// </remarks>
92+ /// <param name="facade">Extended facade</param>
93+ /// <param name="initializer">Initializer delegate for the resource</param>
94+ public static long CreateUnsafe < TResource > ( this IResourceManagement facade , Action < TResource > initializer )
6795 where TResource : Resource
6896 {
69- return facade . Create ( typeof ( TResource ) , r => initializer ( ( TResource ) r ) ) ;
97+ return facade . CreateUnsafe ( typeof ( TResource ) , r => initializer ( ( TResource ) r ) ) ;
7098 }
7199 }
72- }
100+ }
0 commit comments