[ 
https://issues.apache.org/jira/browse/GEODE-9464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17404696#comment-17404696
 ] 

ASF GitHub Bot commented on GEODE-9464:
---------------------------------------

mmartell commented on a change in pull request #856:
URL: https://github.com/apache/geode-native/pull/856#discussion_r696083927



##########
File path: netcore/AspNetCore GeodeSession 
Sample/Extensions/SessionExtensions.cs
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System.Text.Json;
+using Microsoft.AspNetCore.Http;
+
+namespace Web.Extensions
+{
+    #region snippet1
+    public static class SessionExtensions
+    {
+        public static void Set<T>(this ISession session, string key, T value)
+        {
+            session.SetString(key, JsonSerializer.Serialize(value));
+        }
+
+        public static T Get<T>(this ISession session, string key)
+        {
+            var value = session.GetString(key);
+            return value == null ? default : 
JsonSerializer.Deserialize<T>(value);
+        }
+    }
+    #endregion      
+}
+
+namespace Web.Extensions2
+{
+    // Alternate approach
+
+    public static class SessionExtensions
+    {
+        public static void Set<T>(this ISession session, string key, T value)
+        {
+            session.SetString(key, JsonSerializer.Serialize(value));
+        }
+
+        public static bool TryGet<T>(this ISession session, string key, out T 
value)
+        {
+            var state = session.GetString(key);
+            value = default;
+            if (state == null)
+                return false;
+            value = JsonSerializer.Deserialize<T>(state);
+            return true;
+        }
+    }
+}

Review comment:
       Yup




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add a non-Steeltoe Asp.Net Core SessionState sample app to SessionStateCore
> ---------------------------------------------------------------------------
>
>                 Key: GEODE-9464
>                 URL: https://issues.apache.org/jira/browse/GEODE-9464
>             Project: Geode
>          Issue Type: Test
>          Components: native client
>            Reporter: Michael Martell
>            Priority: Major
>              Labels: pull-request-available
>
> The current Asp.Net sample app uses Steeltoe for discovery and registration 
> of our sessionstate provider. We need a non-Steeltoe sample as well, since 
> not everyone uses Steeltoe.
> This will be a good test of our NuGet access to the SessionState Core 
> artifacts and its dependencies.
> Note: Ensure that the web application runs on all platforms.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to