This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 8eb5c67 GEODE-4343: Add auto-serialization example for .net (#227)
8eb5c67 is described below
commit 8eb5c67d83db444dd03fa962489ea382ca6495df
Author: Blake Bender <[email protected]>
AuthorDate: Mon Mar 5 13:14:05 2018 -0800
GEODE-4343: Add auto-serialization example for .net (#227)
* Normalize naming convention in find module.
---
.../FindGeodeNative.cmake} | 86 +++++++++++++++-------
examples/cpp/customserializable/CMakeLists.txt | 6 +-
examples/cpp/customserializer/CMakeLists.txt | 6 +-
examples/cpp/put-get-remove/CMakeLists.txt | 6 +-
examples/dotnet/AuthInitialize/CMakeLists.txt | 20 ++---
examples/dotnet/AuthInitialize/Program.cs | 19 ++++-
examples/dotnet/AuthInitialize/startserver.ps1 | 12 ++-
examples/dotnet/AuthInitialize/stopserver.ps1 | 12 ++-
examples/dotnet/CMakeLists.txt | 4 +-
.../PdxAutoSerializer}/CMakeLists.txt | 27 ++++---
examples/dotnet/PdxAutoSerializer/Order.cs | 43 +++++++++++
examples/dotnet/PdxAutoSerializer/Program.cs | 62 ++++++++++++++++
examples/dotnet/PdxAutoSerializer/README.md | 24 ++++++
.../startserver.ps1 | 14 ++--
.../stopserver.ps1 | 14 ++--
.../Apache.Geode.Examples.PutGetRemove.csproj | 77 -------------------
examples/dotnet/PutGetRemove/CMakeLists.txt | 20 ++---
examples/dotnet/PutGetRemove/startserver.ps1 | 12 ++-
examples/dotnet/PutGetRemove/stopserver.ps1 | 12 ++-
19 files changed, 274 insertions(+), 202 deletions(-)
diff --git a/examples/cpp/cmake/Findgeode-native.cmake
b/examples/cmake/FindGeodeNative.cmake
similarity index 52%
rename from examples/cpp/cmake/Findgeode-native.cmake
rename to examples/cmake/FindGeodeNative.cmake
index d4d7328..fc1e0d5 100644
--- a/examples/cpp/cmake/Findgeode-native.cmake
+++ b/examples/cmake/FindGeodeNative.cmake
@@ -14,7 +14,7 @@
# limitations under the License.
#.rst:
-# Findgeode-native
+# FindGeodeNative
# ---------
#
# Find the Geode Native headers and library.
@@ -24,25 +24,24 @@
#
# This module defines the following :prop_tgt:`IMPORTED` targets:
#
-# ``apache.geode::cpp``
+# ``GeodeNative::cpp``
+# ``GeodeNative:dotnet``
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
-# ``GEODE_NATIVE_INCLUDE_DIRS``
-# where to find CacheFactory.hpp, etc.
-# ``GEODE_NATIVE_LIBRARIES``
-# the libraries to link against to use Geode Native.
-# ``GEODE_NATIVE_FOUND``
+# ``GeodeNative_FOUND``
# true if the Geode Native headers and libraries were found.
#
-
+# ``GeodeNative_DOTNET_LIBRARY``
+# Path to .NET assembly file.
+#
set(_GEODE_NATIVE_ROOT "")
-if(GEODE_NATIVE_ROOT AND IS_DIRECTORY "${GEODE_NATIVE_ROOT}")
- set(_GEODE_NATIVE_ROOT "${GEODE_NATIVE_ROOT}")
+if(GeodeNative_ROOT AND IS_DIRECTORY "${GeodeNative_ROOT}")
+ set(_GEODE_NATIVE_ROOT "${GeodeNative_ROOT}")
set(_GEODE_NATIVE_ROOT_EXPLICIT 1)
else()
set(_ENV_GEODE_NATIVE_ROOT "")
@@ -61,52 +60,83 @@ set(_GEODE_NATIVE_PATHS)
if(_GEODE_NATIVE_ROOT)
set(_GEODE_NATIVE_HINTS ${_GEODE_NATIVE_ROOT})
+ set(_GEODE_NATIVE_HINTS ${_GEODE_NATIVE_ROOT})
else()
set(_GEODE_NATIVE_PATHS (
"/opt/local"
"/usr/local"
- "${CMAKE_CURRENT_SOURCE_DIR}/../../../../"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../../"
"C:/program files" ))
endif()
-set(_GEODE_NATIVE_NAMES apache-geode)
+# Begin - component "cpp"
+set(_GEODE_NATIVE_CPP_NAMES apache-geode)
-find_library(GEODE_NATIVE_LIBRARY
- NAMES ${_GEODE_NATIVE_NAMES}
+find_library(GeodeNative_CPP_LIBRARY
+ NAMES ${_GEODE_NATIVE_CPP_NAMES}
HINTS ${_GEODE_NATIVE_HINTS}
PATHS ${_GEODE_NATIVE_PATHS}
- PATH_SUFFIXES geode-native/lib
+ PATH_SUFFIXES geode-native/lib lib
)
-
-
# Look for the header file.
-find_path(GEODE_NATIVE_INCLUDE_DIR NAMES geode/CacheFactory.hpp
+find_path(GeodeNative_CPP_INCLUDE_DIR NAMES geode/CacheFactory.hpp
HINTS ${_GEODE_NATIVE_HINTS}
PATHS ${_GEODE_NATIVE_PATHS}
- PATH_SUFFIXES geode-native/include
+ PATH_SUFFIXES geode-native/include include
+)
+# End - component "cpp"
+
+# Begin - component "dotnet"
+set(_GEODE_NATIVE_DOTNET_NAMES Apache.Geode.dll)
+
+find_file(GeodeNative_DOTNET_LIBRARY
+ NAMES ${_GEODE_NATIVE_DOTNET_NAMES}
+ HINTS ${_GEODE_NATIVE_HINTS}
+ PATHS ${_GEODE_NATIVE_PATHS}
+ PATH_SUFFIXES geode-native/bin bin
)
+# End - component "dotnet"
# TODO find version
set(GEODE_NATIVE_VERSION_STRING 1.0)
+if (GeodeNative_FIND_COMPONENTS)
+ set(_GEODE_NATIVE_REQUIRED_VARS)
+ foreach (component ${GeodeNative_FIND_COMPONENTS})
+ if (component STREQUAL "cpp")
+ list(APPEND _GEODE_NATIVE_REQUIRED_VARS GeodeNative_CPP_LIBRARY
GeodeNative_CPP_INCLUDE_DIR)
+ endif()
+ if (component STREQUAL "dotnet")
+ list(APPEND _GEODE_NATIVE_REQUIRED_VARS GeodeNative_DOTNET_LIBRARY)
+ endif()
+ endforeach()
+endif()
+
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GEODE_NATIVE
- REQUIRED_VARS GEODE_NATIVE_LIBRARY
GEODE_NATIVE_INCLUDE_DIR
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GeodeNative
+ REQUIRED_VARS ${_GEODE_NATIVE_REQUIRED_VARS}
VERSION_VAR GEODE_NATIVE_VERSION_STRING)
# Copy the results to the output variables and target.
-if(GEODE_NATIVE_FOUND)
- set(GEODE_NATIVE_LIBRARIES ${GEODE_NATIVE_LIBRARY})
- set(GEODE_NATIVE_INCLUDE_DIRS ${GEODE_NATIVE_INCLUDE_DIR})
- set(GEODE_NATIVE_CPP_TARGET "apache.geode::cpp")
+if(GeodeNative_FOUND)
if(NOT TARGET ${GEODE_NATIVE_CPP_TARGET})
+ set(GEODE_NATIVE_CPP_TARGET "GeodeNative::cpp")
add_library(${GEODE_NATIVE_CPP_TARGET} UNKNOWN IMPORTED)
set_target_properties(${GEODE_NATIVE_CPP_TARGET} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
- IMPORTED_LOCATION "${GEODE_NATIVE_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${GEODE_NATIVE_INCLUDE_DIRS}")
+ IMPORTED_LOCATION "${GeodeNative_CPP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GeodeNative_CPP_INCLUDE_DIR}")
+ endif()
+ if(NOT TARGET ${GEODE_NATIVE_DOTNET_TARGET})
+ set(GEODE_NATIVE_DOTNET_TARGET "GeodeNative::dotnet")
+ add_library(${GEODE_NATIVE_DOTNET_TARGET} UNKNOWN IMPORTED)
+ set_target_properties(${GEODE_NATIVE_DOTNET_TARGET} PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "CSharp"
+ IMPORTED_LOCATION "${GeodeNative_DOTNET_LIBRARY}")
endif()
+else()
+ message(STATUS "FOUND var not set")
endif()
-mark_as_advanced(GEODE_NATIVE_INCLUDE_DIR GEODE_NATIVE_LIBRARY)
+mark_as_advanced(GeodeNative_CPP_INCLUDE_DIR GeodeNative_CPP_LIBRARY
GeodeNative_DOTNET_LIBRARY)
diff --git a/examples/cpp/customserializable/CMakeLists.txt
b/examples/cpp/customserializable/CMakeLists.txt
index 9ca93a9..22779ba 100644
--- a/examples/cpp/customserializable/CMakeLists.txt
+++ b/examples/cpp/customserializable/CMakeLists.txt
@@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.5)
project(customserializable)
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
@@ -25,7 +25,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
endif()
-find_package(geode-native REQUIRED)
+find_package(GeodeNative REQUIRED COMPONENTS cpp)
add_executable(${PROJECT_NAME}
main.cpp
@@ -33,5 +33,5 @@ add_executable(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PUBLIC
- apache.geode::cpp
+ GeodeNative::cpp
)
diff --git a/examples/cpp/customserializer/CMakeLists.txt
b/examples/cpp/customserializer/CMakeLists.txt
index 7869d9c..ddaa174 100644
--- a/examples/cpp/customserializer/CMakeLists.txt
+++ b/examples/cpp/customserializer/CMakeLists.txt
@@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.5)
project(customserializer)
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
@@ -25,7 +25,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
endif()
-find_package(geode-native REQUIRED)
+find_package(GeodeNative REQUIRED COMPONENTS cpp)
add_executable(${PROJECT_NAME}
main.cpp
@@ -34,5 +34,5 @@ add_executable(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PUBLIC
- apache.geode::cpp
+ GeodeNative::cpp
)
diff --git a/examples/cpp/put-get-remove/CMakeLists.txt
b/examples/cpp/put-get-remove/CMakeLists.txt
index a79eccf..66d62a8 100644
--- a/examples/cpp/put-get-remove/CMakeLists.txt
+++ b/examples/cpp/put-get-remove/CMakeLists.txt
@@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.5)
project(put-get-remove)
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
@@ -25,11 +25,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
endif()
-find_package(geode-native REQUIRED)
+find_package(GeodeNative REQUIRED COMPONENTS cpp)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
PUBLIC
- apache.geode::cpp
+ GeodeNative::cpp
)
diff --git a/examples/dotnet/AuthInitialize/CMakeLists.txt
b/examples/dotnet/AuthInitialize/CMakeLists.txt
index b5bb961..7407fa2 100644
--- a/examples/dotnet/AuthInitialize/CMakeLists.txt
+++ b/examples/dotnet/AuthInitialize/CMakeLists.txt
@@ -13,30 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.8.2)
+cmake_minimum_required(VERSION 3.10.0)
project(AuthInitialize CSharp)
-message(STATUS "Assembly is ${GEODE_ASSEMBLY}")
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
-if ("${GEODE_ASSEMBLY}" STREQUAL "")
- message(FATAL_ERROR "GEODE_ASSEMBLY not set, examples will not build
without it")
-endif()
+find_package(GeodeNative REQUIRED COMPONENTS dotnet)
add_executable(${PROJECT_NAME}
Program.cs
- ExampleAuthInitialize.cs)
-
-message(STATUS "output dir is ${RUNTIME_OUTPUT_DIRECTORY}")
-message(STATUS "project binary dir: ${PROJECT_BINARY_DIR}")
-
-message(STATUS "current source dir is ${CMAKE_CURRENT_SOURCE_DIR}")
-message(STATUS "Attempting to link to
${CMAKE_CURRENT_SOURCE_DIR}/../../../build/clicache/src/Debug/Apache.Geode.dll")
+ ExampleAuthInitialize.cs)
target_link_libraries(${PROJECT_NAME}
- ${GEODE_ASSEMBLY})
+ GeodeNative::dotnet)
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
"System"
- "${GEODE_ASSEMBLY}")
+ "${GeodeNative_DOTNET_LIBRARY}")
diff --git a/examples/dotnet/AuthInitialize/Program.cs
b/examples/dotnet/AuthInitialize/Program.cs
index 2bd7078..200e097 100644
--- a/examples/dotnet/AuthInitialize/Program.cs
+++ b/examples/dotnet/AuthInitialize/Program.cs
@@ -1,4 +1,21 @@
-using System;
+/*
+* 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;
using Apache.Geode.Client;
namespace Apache.Geode.Examples.AuthInitialize
diff --git a/examples/dotnet/AuthInitialize/startserver.ps1
b/examples/dotnet/AuthInitialize/startserver.ps1
index 49d764e..8bbe074 100644
--- a/examples/dotnet/AuthInitialize/startserver.ps1
+++ b/examples/dotnet/AuthInitialize/startserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
diff --git a/examples/dotnet/AuthInitialize/stopserver.ps1
b/examples/dotnet/AuthInitialize/stopserver.ps1
index 361a746..04da3cf 100644
--- a/examples/dotnet/AuthInitialize/stopserver.ps1
+++ b/examples/dotnet/AuthInitialize/stopserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
diff --git a/examples/dotnet/CMakeLists.txt b/examples/dotnet/CMakeLists.txt
index a5ec504..cb2ceff 100644
--- a/examples/dotnet/CMakeLists.txt
+++ b/examples/dotnet/CMakeLists.txt
@@ -14,7 +14,9 @@
# limitations under the License.
cmake_minimum_required(VERSION 3.4)
-project(Apache.Geode.Examples)
+project(Apache.Geode.Examples LANGUAGES NONE)
add_subdirectory(AuthInitialize)
+add_subdirectory(PdxAutoSerializer)
add_subdirectory(PutGetRemove)
+
diff --git a/examples/cpp/put-get-remove/CMakeLists.txt
b/examples/dotnet/PdxAutoSerializer/CMakeLists.txt
similarity index 67%
copy from examples/cpp/put-get-remove/CMakeLists.txt
copy to examples/dotnet/PdxAutoSerializer/CMakeLists.txt
index a79eccf..21195eb 100644
--- a/examples/cpp/put-get-remove/CMakeLists.txt
+++ b/examples/dotnet/PdxAutoSerializer/CMakeLists.txt
@@ -13,23 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10.0)
-project(put-get-remove)
+project(PDXAutoSerializer CSharp)
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
-set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
-if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
- add_compile_options(-m64)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
-endif()
+find_package(GeodeNative REQUIRED COMPONENTS dotnet)
-find_package(geode-native REQUIRED)
-
-add_executable(${PROJECT_NAME} main.cpp)
+add_executable(${PROJECT_NAME}
+ Program.cs
+ Order.cs)
target_link_libraries(${PROJECT_NAME}
- PUBLIC
- apache.geode::cpp
-)
+ GeodeNative::dotnet)
+
+set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
+ "System"
+ "${GeodeNative_DOTNET_LIBRARY}")
+
diff --git a/examples/dotnet/PdxAutoSerializer/Order.cs
b/examples/dotnet/PdxAutoSerializer/Order.cs
new file mode 100644
index 0000000..7ffea67
--- /dev/null
+++ b/examples/dotnet/PdxAutoSerializer/Order.cs
@@ -0,0 +1,43 @@
+/*
+* 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.
+*/
+
+namespace Apache.Geode.Examples.Serializer
+{
+ public class Order
+ {
+ public int OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
+
+ // A default constructor is required for reflection based
autoserialization
+ public Order() { }
+
+ public Order(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
+
+ public override string ToString()
+ {
+ return "Order: [" + OrderId + ", " + Name + ", " + Quantity + "]";
+ }
+ }
+}
+
+
diff --git a/examples/dotnet/PdxAutoSerializer/Program.cs
b/examples/dotnet/PdxAutoSerializer/Program.cs
new file mode 100644
index 0000000..c5290f5
--- /dev/null
+++ b/examples/dotnet/PdxAutoSerializer/Program.cs
@@ -0,0 +1,62 @@
+/*
+* 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;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.Serializer
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var cacheFactory = new CacheFactory()
+ .Set("log-level", "none");
+ var cache = cacheFactory.Create();
+
+ var poolFactory = cache.GetPoolFactory()
+ .AddLocator("localhost", 10334);
+ poolFactory.Create("pool", cache);
+
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var orderRegion = regionFactory.Create<int,
Order>("example_orderobject");
+
+ Serializable.RegisterPdxSerializer(new
ReflectionBasedAutoSerializer());
+
+ Console.WriteLine("Registering for reflection-based auto
serialization");
+
+ Console.WriteLine("Storing order object in the region");
+
+ const int orderKey = 65;
+
+ var order = new Order(orderKey, "Vox AC30", 11);
+
+ Console.WriteLine("order to put is " + order);
+ orderRegion.Put(orderKey, order, null);
+
+ Console.WriteLine("Successfully put order, getting now...");
+ var orderRetrieved = orderRegion.Get(orderKey, null);
+
+ Console.WriteLine("Order key: " + orderKey + " = " +
orderRetrieved);
+
+ cache.Close();
+ }
+ }
+}
+
+
diff --git a/examples/dotnet/PdxAutoSerializer/README.md
b/examples/dotnet/PdxAutoSerializer/README.md
new file mode 100644
index 0000000..bbe7ecd
--- /dev/null
+++ b/examples/dotnet/PdxAutoSerializer/README.md
@@ -0,0 +1,24 @@
+# PdxAutoSerializer Example
+This is a simple example showing how to register for auto-serialization of
custom objects using the ReflectionBasedAutoSerializer class.
+
+## Prerequisites
+* Install [Apache Geode](https://geode.apache.org)
+* Build and install [Apache Geode
Native](https://github.com/apache/geode-native)
+
+## Running
+* Start Geode Server and create region.
+ ```
+ gfsh>start locator --name=locator
+ gfsh>start server --name=server
+ gfsh>create region --name=example_orderobject --type=PARTITION
+ ```
+* Execute `PdxAutoSerializer.exe`.
+
+ output:
+ ```
+ Registering for reflection-based auto serialization
+ Storing order object in the region
+ order to put is Order: [65, Vox AC30, 11]
+ Successfully put order, getting now...
+ Order key: 65 = Order: [65, Vox AC30, 11]
+ ```
diff --git a/examples/dotnet/AuthInitialize/startserver.ps1
b/examples/dotnet/PdxAutoSerializer/startserver.ps1
similarity index 72%
copy from examples/dotnet/AuthInitialize/startserver.ps1
copy to examples/dotnet/PdxAutoSerializer/startserver.ps1
index 49d764e..c3d5735 100644
--- a/examples/dotnet/AuthInitialize/startserver.ps1
+++ b/examples/dotnet/PdxAutoSerializer/startserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
@@ -37,5 +35,5 @@ else
if ($GFSH_PATH -ne "")
{
- Invoke-Expression "$GFSH_PATH -e 'start locator --name=locator
--dir=$PSScriptRoot\locator' -e 'start server --name=server
--dir=$PSScriptRoot\server' -e 'create region --name=region --type=PARTITION'"
+ Invoke-Expression "$GFSH_PATH -e 'start locator --name=locator
--dir=$PSScriptRoot\locator' -e 'start server --name=server
--dir=$PSScriptRoot\server' -e 'create region --name=example_orderobject
--type=PARTITION'"
}
\ No newline at end of file
diff --git a/examples/dotnet/AuthInitialize/stopserver.ps1
b/examples/dotnet/PdxAutoSerializer/stopserver.ps1
similarity index 71%
copy from examples/dotnet/AuthInitialize/stopserver.ps1
copy to examples/dotnet/PdxAutoSerializer/stopserver.ps1
index 361a746..a95b7a7 100644
--- a/examples/dotnet/AuthInitialize/stopserver.ps1
+++ b/examples/dotnet/PdxAutoSerializer/stopserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
@@ -37,5 +35,5 @@ else
if ($GFSH_PATH -ne "")
{
- Invoke-Expression "$GFSH_PATH -e 'connect' -e 'destroy region
--name=region' -e 'stop server --name=server' -e 'stop locator --name=locator'"
+ Invoke-Expression "$GFSH_PATH -e 'connect' -e 'destroy region
--name=example_orderobject' -e 'stop server --name=server' -e 'stop locator
--name=locator'"
}
\ No newline at end of file
diff --git
a/examples/dotnet/PutGetRemove/Apache.Geode.Examples.PutGetRemove.csproj
b/examples/dotnet/PutGetRemove/Apache.Geode.Examples.PutGetRemove.csproj
deleted file mode 100644
index bc3bb04..0000000
--- a/examples/dotnet/PutGetRemove/Apache.Geode.Examples.PutGetRemove.csproj
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-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.
--->
-<Project ToolsVersion="14.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import
Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Apache.Geode.Examples.PutGetRemove</RootNamespace>
- <AssemblyName>Apache.Geode.Examples.PutGetRemove</AssemblyName>
- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x64\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <DebugType>full</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>true</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <OutputPath>bin\x64\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <Optimize>true</Optimize>
- <DebugType>pdbonly</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>true</Prefer32Bit>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Apache.Geode">
-
<HintPath>..\..\..\..\build\clicache\src\Debug\Apache.Geode.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="Microsoft.CSharp" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <ItemGroup>
- <None Include="README.md" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets
below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
diff --git a/examples/dotnet/PutGetRemove/CMakeLists.txt
b/examples/dotnet/PutGetRemove/CMakeLists.txt
index 3a8d7e1..b5a057d 100644
--- a/examples/dotnet/PutGetRemove/CMakeLists.txt
+++ b/examples/dotnet/PutGetRemove/CMakeLists.txt
@@ -13,29 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.8.2)
+cmake_minimum_required(VERSION 3.10.0)
project(PutGetRemove CSharp)
-message(STATUS "Assembly is ${GEODE_ASSEMBLY}")
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
-if ("${GEODE_ASSEMBLY}" STREQUAL "")
- message(FATAL_ERROR "GEODE_ASSEMBLY not set, examples will not build
without it")
-endif()
+find_package(GeodeNative REQUIRED COMPONENTS dotnet)
add_executable(${PROJECT_NAME}
Program.cs)
-message(STATUS "output dir is ${RUNTIME_OUTPUT_DIRECTORY}")
-message(STATUS "project binary dir: ${PROJECT_BINARY_DIR}")
-
-message(STATUS "current source dir is ${CMAKE_CURRENT_SOURCE_DIR}")
-message(STATUS "Attempting to link to
${CMAKE_CURRENT_SOURCE_DIR}/../../../build/clicache/src/Debug/Apache.Geode.dll")
-
target_link_libraries(${PROJECT_NAME}
- ${GEODE_ASSEMBLY})
+ GeodeNative::dotnet)
-set_property(TARGET PutGetRemove PROPERTY VS_DOTNET_REFERENCES
+set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
"System"
- "${GEODE_ASSEMBLY}")
+ "${GeodeNative_DOTNET_LIBRARY}")
diff --git a/examples/dotnet/PutGetRemove/startserver.ps1
b/examples/dotnet/PutGetRemove/startserver.ps1
index cdffe7a..bc14e1b 100644
--- a/examples/dotnet/PutGetRemove/startserver.ps1
+++ b/examples/dotnet/PutGetRemove/startserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
diff --git a/examples/dotnet/PutGetRemove/stopserver.ps1
b/examples/dotnet/PutGetRemove/stopserver.ps1
index 6c78ac8..6ebd665 100644
--- a/examples/dotnet/PutGetRemove/stopserver.ps1
+++ b/examples/dotnet/PutGetRemove/stopserver.ps1
@@ -1,6 +1,4 @@
-#!/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
+# 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
@@ -24,10 +22,10 @@ else
{
if (-not (Test-Path env:GEODE_HOME))
{
- echo "Could not find gfsh. Please set the GEODE_HOME path. e.g. "
- echo "(Powershell) `$env:GEODE_HOME = <path to Geode>"
- echo " OR"
- echo "(Command-line) set %GEODE_HOME% = <path to Geode>"
+ Write-Host "Could not find gfsh. Please set the GEODE_HOME path. e.g.
"
+ Write-Host "(Powershell) `$env:GEODE_HOME = <path to Geode>"
+ Write-Host " OR"
+ Write-Host "(Command-line) set %GEODE_HOME% = <path to Geode>"
}
else
{
--
To stop receiving notification emails like this one, please contact
[email protected].