You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2018/08/06 21:49:38 UTC
[geode-native] branch develop updated: Geode 4336 (#324)
This is an automated email from the ASF dual-hosted git repository.
echobravo 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 07bd702 Geode 4336 (#324)
07bd702 is described below
commit 07bd702d526a050791b228ae76cbdc012336cd58
Author: Blake Bender <ek...@hotmail.com>
AuthorDate: Mon Aug 6 14:49:36 2018 -0700
Geode 4336 (#324)
* Add C++ custom DataSerializable example
* Clean up toString methods and rename createDeserializable.
* Add DataSerializable example to install
* Rename C++ examples so they make a little more sense.
* Add PdxSerializable example for C# that uses custom PDX serialization
rather than reflection.
* Add C# version of OQL example
Co-authored-by: Ivan Godwin <ig...@pivotal.io>
---
examples/cpp/CMakeLists.txt | 8 ++-
examples/cpp/CMakeLists.txt.in | 4 +-
.../dataserializable/CMakeLists.txt} | 21 ++++--
.../Order.cpp | 46 ++++++------
.../Order.hpp | 28 +++-----
.../main.cpp | 2 +-
.../startserver.sh | 0
.../stopserver.sh | 2 +-
.../Order.cpp | 9 ++-
.../Order.hpp | 2 +-
.../main.cpp | 2 +-
.../startserver.sh | 0
.../stopserver.sh | 0
.../remotequery/CMakeLists.txt} | 21 ++++--
.../{customserializable => remotequery}/Order.cpp | 4 +-
.../{customserializable => remotequery}/Order.hpp | 10 +--
.../{customserializable => remotequery}/main.cpp | 36 ++++++----
.../startserver.sh | 0
.../stopserver.sh | 0
examples/dotnet/CMakeLists.txt | 9 +++
examples/dotnet/CMakeLists.txt.in | 3 +
examples/dotnet/DataSerializableCs/Order.cs | 74 +++++++++++++++++++
examples/dotnet/DataSerializableCs/Program.cs | 62 ++++++++++++++++
examples/dotnet/DataSerializableCs/README.md | 24 +++++++
examples/dotnet/DataSerializableCs/startserver.ps1 | 39 ++++++++++
.../DataSerializableCs/stopserver.ps1} | 38 ++++++----
examples/dotnet/PdxSerializableCs/Order.cs | 83 ++++++++++++++++++++++
examples/dotnet/PdxSerializableCs/Program.cs | 62 ++++++++++++++++
examples/dotnet/PdxSerializableCs/README.md | 24 +++++++
examples/dotnet/PdxSerializableCs/startserver.ps1 | 39 ++++++++++
.../PdxSerializableCs/stopserver.ps1} | 38 ++++++----
.../CMakeLists.txt} | 16 +++--
examples/dotnet/RemoteQueryCs/Order.cs | 83 ++++++++++++++++++++++
examples/dotnet/RemoteQueryCs/README.md | 24 +++++++
examples/dotnet/RemoteQueryCs/startserver.ps1 | 39 ++++++++++
.../RemoteQueryCs/stopserver.ps1} | 38 ++++++----
36 files changed, 756 insertions(+), 134 deletions(-)
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 12e7484..950519d 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -46,7 +46,10 @@ function(add_example)
DESTINATION examples/cpp/${ADD_EXAMPLE_NAME})
endfunction()
-add_example(NAME customserializable
+add_example(NAME dataserializable
+ SOURCE main.cpp Order.cpp Order.hpp)
+
+add_example(NAME pdxserializable
SOURCE main.cpp Order.cpp Order.hpp)
add_example(NAME customserializer
@@ -54,3 +57,6 @@ add_example(NAME customserializer
add_example(NAME put-get-remove
SOURCE main.cpp)
+
+add_example(NAME remotequery
+ SOURCE main.cpp Order.cpp Order.hpp)
diff --git a/examples/cpp/CMakeLists.txt.in b/examples/cpp/CMakeLists.txt.in
index 0af6f2c..fed540f 100644
--- a/examples/cpp/CMakeLists.txt.in
+++ b/examples/cpp/CMakeLists.txt.in
@@ -17,6 +17,8 @@ cmake_minimum_required(VERSION 3.10)
project(@PRODUCT_DLL_NAME@.Cpp.Examples LANGUAGES NONE)
-add_subdirectory(customserializable)
+add_subdirectory(dataserializable)
+add_subdirectory(pdxserializable)
add_subdirectory(customserializer)
add_subdirectory(put-get-remove)
+add_subdirectory(remotequery)
diff --git a/examples/dotnet/CMakeLists.txt.in b/examples/cpp/dataserializable/CMakeLists.txt
similarity index 61%
copy from examples/dotnet/CMakeLists.txt.in
copy to examples/cpp/dataserializable/CMakeLists.txt
index fb4695d..ea1a552 100644
--- a/examples/dotnet/CMakeLists.txt.in
+++ b/examples/cpp/dataserializable/CMakeLists.txt
@@ -13,11 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.5)
-project(@PRODUCT_DLL_NAME@.DotNet.Examples LANGUAGES NONE)
+project(customdataserializable LANGUAGES CXX)
-add_subdirectory(AuthInitialize)
-add_subdirectory(PdxAutoSerializer)
-add_subdirectory(PutGetRemove)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
+set(CMAKE_CXX_STANDARD 11)
+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 cpp)
+
+add_executable(${PROJECT_NAME} main.cpp;Order.cpp;Order.hpp)
+
+target_link_libraries(${PROJECT_NAME}
+ PUBLIC
+ GeodeNative::cpp)
diff --git a/examples/cpp/customserializable/Order.cpp b/examples/cpp/dataserializable/Order.cpp
similarity index 50%
copy from examples/cpp/customserializable/Order.cpp
copy to examples/cpp/dataserializable/Order.cpp
index 78322d5..e58acdb 100644
--- a/examples/cpp/customserializable/Order.cpp
+++ b/examples/cpp/dataserializable/Order.cpp
@@ -15,33 +15,31 @@
* limitations under the License.
*/
+#include <sstream>
#include "Order.hpp"
-#include <geode/PdxReader.hpp>
-#include <geode/PdxWriter.hpp>
+#include <geode/DataInput.hpp>
+#include <geode/DataOutput.hpp>
namespace customserializable {
-void Order::fromData(PdxReader& pdxReader) {
- order_id_ = static_cast<uint32_t>(pdxReader.readLong(ORDER_ID_KEY_));
- name_ = pdxReader.readString(NAME_KEY_);
- quantity_ = static_cast<uint16_t>(pdxReader.readInt(QUANTITY_KEY_));
+void Order::fromData(DataInput& dataInput) {
+ order_id_ = static_cast<uint32_t>(dataInput.readInt32());
+ name_ = dataInput.readString();
+ quantity_ = static_cast<uint16_t>(dataInput.readInt16());
}
-void Order::toData(PdxWriter& pdxWriter) const {
- pdxWriter.writeLong(ORDER_ID_KEY_, order_id_);
- pdxWriter.markIdentityField(ORDER_ID_KEY_);
-
- pdxWriter.writeString(NAME_KEY_, name_);
- pdxWriter.markIdentityField(NAME_KEY_);
-
- pdxWriter.writeInt(QUANTITY_KEY_, quantity_);
- pdxWriter.markIdentityField(QUANTITY_KEY_);
+void Order::toData(DataOutput& dataOutput) const {
+ dataOutput.writeInt(order_id_);
+ dataOutput.writeString(name_);
+ dataOutput.writeInt(quantity_);
}
std::string Order::toString() const {
- return "OrderID: " + std::to_string(order_id_) + " Product Name: " + name_ +
- " Quantity: " + std::to_string(quantity_);
+ std::stringstream strm;
+
+ strm << "OrderID: " << order_id_ << " Product Name: " << name_ << " Quantity: " << quantity_;
+ return strm.str();
}
size_t Order::objectSize() const {
@@ -50,17 +48,13 @@ size_t Order::objectSize() const {
return objectSize;
}
-const std::string& Order::getClassName() const {
- static const std::string CLASS_NAME = "com.example.Order";
- return CLASS_NAME;
-}
-
-std::shared_ptr<PdxSerializable> Order::createDeserializable() {
+std::shared_ptr<DataSerializable> Order::create() {
return std::make_shared<Order>();
}
-const std::string Order::ORDER_ID_KEY_ = "order_id";
-const std::string Order::NAME_KEY_ = "name";
-const std::string Order::QUANTITY_KEY_ = "quantity";
+int32_t Order::getClassId() const {
+ // No longer used by the interface
+ return 7;
+}
} // namespace customserializable
diff --git a/examples/cpp/customserializable/Order.hpp b/examples/cpp/dataserializable/Order.hpp
similarity index 71%
copy from examples/cpp/customserializable/Order.hpp
copy to examples/cpp/dataserializable/Order.hpp
index a5183cf..242ebd1 100644
--- a/examples/cpp/customserializable/Order.hpp
+++ b/examples/cpp/dataserializable/Order.hpp
@@ -17,18 +17,18 @@
#pragma once
-#ifndef CUSTOMSERIALIZABLE_ORDER_H
-#define CUSTOMSERIALIZABLE_ORDER_H
+#ifndef CUSTOMDATASERIALIZABLE_ORDER_H
+#define CUSTOMDATASERIALIZABLE_ORDER_H
#include <string>
-#include <geode/PdxSerializable.hpp>
+#include <geode/DataSerializable.hpp>
namespace customserializable {
using namespace apache::geode::client;
-class Order : public PdxSerializable {
+class Order : public DataSerializable {
public:
inline Order() : Order(0, "", 0) {}
@@ -43,27 +43,19 @@ class Order : public PdxSerializable {
inline uint16_t getQuantity() const { return quantity_; }
- using PdxSerializable::fromData;
+ void fromData(DataInput& dataInput) override;
- using PdxSerializable::toData;
-
- void fromData(PdxReader& pdxReader) override;
-
- void toData(PdxWriter& pdxWriter) const override;
+ void toData(DataOutput& dataOutput) const override;
std::string toString() const override;
size_t objectSize() const override;
- const std::string& getClassName() const override;
-
- static std::shared_ptr<PdxSerializable> createDeserializable();
+ static std::shared_ptr<DataSerializable> create();
+
+ int32_t getClassId() const override;
private:
- static const std::string ORDER_ID_KEY_;
- static const std::string NAME_KEY_;
- static const std::string QUANTITY_KEY_;
-
uint32_t order_id_;
std::string name_;
uint16_t quantity_;
@@ -71,4 +63,4 @@ class Order : public PdxSerializable {
} // namespace customserializable
-#endif // CUSTOMSERIALIZABLE_ORDER_H
+#endif // CUSTOMDATASERIALIZABLE_ORDER_H
diff --git a/examples/cpp/customserializable/main.cpp b/examples/cpp/dataserializable/main.cpp
similarity index 97%
copy from examples/cpp/customserializable/main.cpp
copy to examples/cpp/dataserializable/main.cpp
index ec14839..5105cda 100644
--- a/examples/cpp/customserializable/main.cpp
+++ b/examples/cpp/dataserializable/main.cpp
@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
auto regionFactory = cache.createRegionFactory(RegionShortcut::PROXY);
auto region = regionFactory.setPoolName("pool").create("custom_orders");
- cache.getTypeRegistry().registerPdxType(Order::createDeserializable);
+ cache.getTypeRegistry().registerType(Order::create);
std::cout << "Create orders" << std::endl;
auto order1 = std::make_shared<Order>(1, "product x", 23);
diff --git a/examples/cpp/customserializable/startserver.sh b/examples/cpp/dataserializable/startserver.sh
old mode 100755
new mode 100644
similarity index 100%
copy from examples/cpp/customserializable/startserver.sh
copy to examples/cpp/dataserializable/startserver.sh
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/cpp/dataserializable/stopserver.sh
old mode 100755
new mode 100644
similarity index 89%
copy from examples/cpp/customserializable/stopserver.sh
copy to examples/cpp/dataserializable/stopserver.sh
index f406a23..3b90a16
--- a/examples/cpp/customserializable/stopserver.sh
+++ b/examples/cpp/dataserializable/stopserver.sh
@@ -28,4 +28,4 @@ else
fi
fi
-$GFSH_PATH -e "connect" -e "stop server --name=server" -e "stop locator --name=locator"
+$GFSH_PATH -e "connect" -e "destroy region --name=custom_orders" -e "stop server --name=server" -e "stop locator --name=locator"
diff --git a/examples/cpp/customserializable/Order.cpp b/examples/cpp/pdxserializable/Order.cpp
similarity index 90%
copy from examples/cpp/customserializable/Order.cpp
copy to examples/cpp/pdxserializable/Order.cpp
index 78322d5..7a1bd04 100644
--- a/examples/cpp/customserializable/Order.cpp
+++ b/examples/cpp/pdxserializable/Order.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <sstream>
#include "Order.hpp"
@@ -40,8 +41,10 @@ void Order::toData(PdxWriter& pdxWriter) const {
}
std::string Order::toString() const {
- return "OrderID: " + std::to_string(order_id_) + " Product Name: " + name_ +
- " Quantity: " + std::to_string(quantity_);
+ std::stringstream strm;
+
+ strm << "OrderID: " << order_id_ << " Product Name: " << name_ << " Quantity: " << quantity_;
+ return strm.str();
}
size_t Order::objectSize() const {
@@ -55,7 +58,7 @@ const std::string& Order::getClassName() const {
return CLASS_NAME;
}
-std::shared_ptr<PdxSerializable> Order::createDeserializable() {
+std::shared_ptr<PdxSerializable> Order::create() {
return std::make_shared<Order>();
}
diff --git a/examples/cpp/customserializable/Order.hpp b/examples/cpp/pdxserializable/Order.hpp
similarity index 96%
copy from examples/cpp/customserializable/Order.hpp
copy to examples/cpp/pdxserializable/Order.hpp
index a5183cf..eaced74 100644
--- a/examples/cpp/customserializable/Order.hpp
+++ b/examples/cpp/pdxserializable/Order.hpp
@@ -57,7 +57,7 @@ class Order : public PdxSerializable {
const std::string& getClassName() const override;
- static std::shared_ptr<PdxSerializable> createDeserializable();
+ static std::shared_ptr<PdxSerializable> create();
private:
static const std::string ORDER_ID_KEY_;
diff --git a/examples/cpp/customserializable/main.cpp b/examples/cpp/pdxserializable/main.cpp
similarity index 97%
copy from examples/cpp/customserializable/main.cpp
copy to examples/cpp/pdxserializable/main.cpp
index ec14839..420ba33 100644
--- a/examples/cpp/customserializable/main.cpp
+++ b/examples/cpp/pdxserializable/main.cpp
@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
auto regionFactory = cache.createRegionFactory(RegionShortcut::PROXY);
auto region = regionFactory.setPoolName("pool").create("custom_orders");
- cache.getTypeRegistry().registerPdxType(Order::createDeserializable);
+ cache.getTypeRegistry().registerPdxType(Order::create);
std::cout << "Create orders" << std::endl;
auto order1 = std::make_shared<Order>(1, "product x", 23);
diff --git a/examples/cpp/customserializable/startserver.sh b/examples/cpp/pdxserializable/startserver.sh
similarity index 100%
copy from examples/cpp/customserializable/startserver.sh
copy to examples/cpp/pdxserializable/startserver.sh
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/cpp/pdxserializable/stopserver.sh
similarity index 100%
copy from examples/cpp/customserializable/stopserver.sh
copy to examples/cpp/pdxserializable/stopserver.sh
diff --git a/examples/dotnet/CMakeLists.txt.in b/examples/cpp/remotequery/CMakeLists.txt
similarity index 61%
copy from examples/dotnet/CMakeLists.txt.in
copy to examples/cpp/remotequery/CMakeLists.txt
index fb4695d..a9d5efc 100644
--- a/examples/dotnet/CMakeLists.txt.in
+++ b/examples/cpp/remotequery/CMakeLists.txt
@@ -13,11 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 3.5)
-project(@PRODUCT_DLL_NAME@.DotNet.Examples LANGUAGES NONE)
+project(remotequery LANGUAGES CXX)
-add_subdirectory(AuthInitialize)
-add_subdirectory(PdxAutoSerializer)
-add_subdirectory(PutGetRemove)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
+set(CMAKE_CXX_STANDARD 11)
+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 cpp)
+
+add_executable(${PROJECT_NAME} main.cpp;Order.cpp;Order.hpp)
+
+target_link_libraries(${PROJECT_NAME}
+ PUBLIC
+ GeodeNative::cpp)
diff --git a/examples/cpp/customserializable/Order.cpp b/examples/cpp/remotequery/Order.cpp
similarity index 97%
rename from examples/cpp/customserializable/Order.cpp
rename to examples/cpp/remotequery/Order.cpp
index 78322d5..9f4b35a 100644
--- a/examples/cpp/customserializable/Order.cpp
+++ b/examples/cpp/remotequery/Order.cpp
@@ -20,7 +20,7 @@
#include <geode/PdxReader.hpp>
#include <geode/PdxWriter.hpp>
-namespace customserializable {
+namespace remotequery {
void Order::fromData(PdxReader& pdxReader) {
order_id_ = static_cast<uint32_t>(pdxReader.readLong(ORDER_ID_KEY_));
@@ -63,4 +63,4 @@ const std::string Order::ORDER_ID_KEY_ = "order_id";
const std::string Order::NAME_KEY_ = "name";
const std::string Order::QUANTITY_KEY_ = "quantity";
-} // namespace customserializable
+} // namespace remotequery
diff --git a/examples/cpp/customserializable/Order.hpp b/examples/cpp/remotequery/Order.hpp
similarity index 91%
rename from examples/cpp/customserializable/Order.hpp
rename to examples/cpp/remotequery/Order.hpp
index a5183cf..953fd9d 100644
--- a/examples/cpp/customserializable/Order.hpp
+++ b/examples/cpp/remotequery/Order.hpp
@@ -17,14 +17,14 @@
#pragma once
-#ifndef CUSTOMSERIALIZABLE_ORDER_H
-#define CUSTOMSERIALIZABLE_ORDER_H
+#ifndef REMOTEQUERY_ORDER_H
+#define REMOTEQUERY_ORDER_H
#include <string>
#include <geode/PdxSerializable.hpp>
-namespace customserializable {
+namespace remotequery {
using namespace apache::geode::client;
@@ -69,6 +69,6 @@ class Order : public PdxSerializable {
uint16_t quantity_;
};
-} // namespace customserializable
+} // namespace remotequery
-#endif // CUSTOMSERIALIZABLE_ORDER_H
+#endif // REMOTEQUERY_ORDER_H
diff --git a/examples/cpp/customserializable/main.cpp b/examples/cpp/remotequery/main.cpp
similarity index 66%
rename from examples/cpp/customserializable/main.cpp
rename to examples/cpp/remotequery/main.cpp
index ec14839..7bdd051 100644
--- a/examples/cpp/customserializable/main.cpp
+++ b/examples/cpp/remotequery/main.cpp
@@ -20,6 +20,7 @@
#include <geode/CacheFactory.hpp>
#include <geode/PoolManager.hpp>
+#include <geode/QueryService.hpp>
#include <geode/RegionFactory.hpp>
#include <geode/RegionShortcut.hpp>
#include <geode/TypeRegistry.hpp>
@@ -27,7 +28,7 @@
#include "Order.hpp"
using namespace apache::geode::client;
-using namespace customserializable;
+using namespace remotequery;
int main(int argc, char** argv) {
auto cacheFactory = CacheFactory();
@@ -46,26 +47,31 @@ int main(int argc, char** argv) {
std::cout << "Create orders" << std::endl;
auto order1 = std::make_shared<Order>(1, "product x", 23);
auto order2 = std::make_shared<Order>(2, "product y", 37);
+ auto order3 = std::make_shared<Order>(3, "product z", 1);
+ auto order4 = std::make_shared<Order>(4, "product z", 102);
+ auto order5 = std::make_shared<Order>(5, "product x", 17);
+ auto order6 = std::make_shared<Order>(6, "product z", 42);
std::cout << "Storing orders in the region" << std::endl;
- region->put("Customer1", order1);
- region->put("Customer2", order2);
+ region->put("Order1", order1);
+ region->put("Order2", order2);
+ region->put("Order3", order3);
+ region->put("Order4", order4);
+ region->put("Order5", order5);
+ region->put("Order6", order6);
+
+ std::shared_ptr<QueryService> queryService = nullptr;
+ queryService = pool->getQueryService();
std::cout << "Getting the orders from the region" << std::endl;
+ auto query = queryService->newQuery("SELECT * FROM /custom_orders WHERE quantity > 30");
+ auto queryResults = query->execute();
- if (auto order1retrieved =
- std::dynamic_pointer_cast<Order>(region->get("Customer1"))) {
- std::cout << "OrderID: " << order1retrieved->getOrderId() << std::endl;
- std::cout << "Product Name: " << order1retrieved->getName() << std::endl;
- std::cout << "Quantity: " << order1retrieved->getQuantity() << std::endl;
- } else {
- std::cout << "Order 1 not found." << std::endl;
- }
+ std::cout << "The following orders have a quantity greater than 30:" << std::endl;
- if (auto order2retrieved = region->get("Customer2")) {
- std::cout << order2retrieved->toString() << std::endl;
- } else {
- std::cout << "Order 2 not found." << std::endl;
+ for (auto&& value : *queryResults) {
+ auto&& order = std::dynamic_pointer_cast<Order>(value);
+ std::cout << order->toString() << std::endl;
}
cache.close();
diff --git a/examples/cpp/customserializable/startserver.sh b/examples/cpp/remotequery/startserver.sh
similarity index 100%
rename from examples/cpp/customserializable/startserver.sh
rename to examples/cpp/remotequery/startserver.sh
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/cpp/remotequery/stopserver.sh
similarity index 100%
copy from examples/cpp/customserializable/stopserver.sh
copy to examples/cpp/remotequery/stopserver.sh
diff --git a/examples/dotnet/CMakeLists.txt b/examples/dotnet/CMakeLists.txt
index 75c572b..6427179 100644
--- a/examples/dotnet/CMakeLists.txt
+++ b/examples/dotnet/CMakeLists.txt
@@ -50,8 +50,17 @@ endfunction()
add_example(NAME AuthInitialize
SOURCE ExampleAuthInitialize.cs Program.cs)
+add_example(NAME DataSerializableCs
+ SOURCE Order.cs Program.cs)
+
add_example(NAME PdxAutoSerializer
SOURCE Order.cs Program.cs)
+add_example(NAME PdxSerializableCs
+ SOURCE Order.cs Program.cs)
+
add_example(NAME PutGetRemove
SOURCE Program.cs)
+
+add_example(NAME RemoteQueryCs
+ SOURCE Order.cs Program.cs)
diff --git a/examples/dotnet/CMakeLists.txt.in b/examples/dotnet/CMakeLists.txt.in
index fb4695d..53a2998 100644
--- a/examples/dotnet/CMakeLists.txt.in
+++ b/examples/dotnet/CMakeLists.txt.in
@@ -18,6 +18,9 @@ cmake_minimum_required(VERSION 3.10)
project(@PRODUCT_DLL_NAME@.DotNet.Examples LANGUAGES NONE)
add_subdirectory(AuthInitialize)
+add_subdirectory(DataSerializableCs)
add_subdirectory(PdxAutoSerializer)
+add_subdirectory(PdxSerializableCs)
add_subdirectory(PutGetRemove)
+add_subdirectory(RemoteQueryCs)
diff --git a/examples/dotnet/DataSerializableCs/Order.cs b/examples/dotnet/DataSerializableCs/Order.cs
new file mode 100644
index 0000000..5359391
--- /dev/null
+++ b/examples/dotnet/DataSerializableCs/Order.cs
@@ -0,0 +1,74 @@
+/*
+* 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 Apache.Geode.Client;
+using System;
+
+namespace Apache.Geode.Examples.Serializer
+{
+ public class Order : IDataSerializable
+ {
+ public int OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
+
+ // A default constructor is required for deserialization
+ public Order() { }
+
+ public Order(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
+ }
+
+ public void ToData(DataOutput output)
+ {
+ output.WriteInt32(OrderId);
+ output.WriteUTF(Name);
+ output.WriteInt16(Quantity);
+ }
+
+ public void FromData(DataInput input)
+ {
+ OrderId = input.ReadInt32();
+ Name = input.ReadUTF();
+ Quantity = input.ReadInt16();
+ }
+
+ public Int32 ClassId
+ {
+ get { return 0x42; }
+ }
+
+ public ulong ObjectSize
+ {
+ get { return 0x04; }
+ }
+
+ public static ISerializable CreateDeserializable()
+ {
+ return new Order();
+ }
+ }
+}
+
+
diff --git a/examples/dotnet/DataSerializableCs/Program.cs b/examples/dotnet/DataSerializableCs/Program.cs
new file mode 100644
index 0000000..4b2647d
--- /dev/null
+++ b/examples/dotnet/DataSerializableCs/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();
+
+ Console.WriteLine("Registering for data serialization");
+
+ cache.TypeRegistry.RegisterType(Order.CreateDeserializable);
+
+ var poolFactory = cache.GetPoolFactory()
+ .AddLocator("localhost", 10334);
+ poolFactory.Create("pool");
+
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var orderRegion = regionFactory.Create<int, Order>("example_orderobject");
+
+ Console.WriteLine("Storing order object in the region");
+
+ const int orderKey = 65;
+
+ var order = new Order(orderKey, "Donuts", 12);
+
+ 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/DataSerializableCs/README.md b/examples/dotnet/DataSerializableCs/README.md
new file mode 100644
index 0000000..bbe7ecd
--- /dev/null
+++ b/examples/dotnet/DataSerializableCs/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/DataSerializableCs/startserver.ps1 b/examples/dotnet/DataSerializableCs/startserver.ps1
new file mode 100644
index 0000000..c3d5735
--- /dev/null
+++ b/examples/dotnet/DataSerializableCs/startserver.ps1
@@ -0,0 +1,39 @@
+# 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.
+
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
+
+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=example_orderobject --type=PARTITION'"
+}
\ No newline at end of file
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/dotnet/DataSerializableCs/stopserver.ps1
old mode 100755
new mode 100644
similarity index 50%
copy from examples/cpp/customserializable/stopserver.sh
copy to examples/dotnet/DataSerializableCs/stopserver.ps1
index f406a23..a95b7a7
--- a/examples/cpp/customserializable/stopserver.sh
+++ b/examples/dotnet/DataSerializableCs/stopserver.ps1
@@ -1,4 +1,4 @@
-# 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
@@ -13,19 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!/bin/env bash
-GFSH_PATH=""
-which gfsh 2> /dev/null
-
-if [ $? -eq 0 ]; then
- GFSH_PATH="gfsh"
-else
- if [ "$GEODE_HOME" == "" ]; then
- echo "Could not find gfsh. Please set the GEODE_HOME path."
- echo "e.g. export GEODE_HOME=<path to Geode>"
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
- GFSH_PATH=$GEODE_HOME/bin/gfsh
- fi
-fi
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
-$GFSH_PATH -e "connect" -e "stop server --name=server" -e "stop locator --name=locator"
+if ($GFSH_PATH -ne "")
+{
+ 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/PdxSerializableCs/Order.cs b/examples/dotnet/PdxSerializableCs/Order.cs
new file mode 100644
index 0000000..332316d
--- /dev/null
+++ b/examples/dotnet/PdxSerializableCs/Order.cs
@@ -0,0 +1,83 @@
+/*
+* 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 Apache.Geode.Client;
+using System;
+
+namespace Apache.Geode.Examples.Serializer
+{
+ public class Order : IPdxSerializable
+ {
+ private const string ORDER_ID_KEY_ = "order_id";
+ private const string NAME_KEY_ = "name";
+ private const string QUANTITY_KEY_ = "quantity";
+
+ public long OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
+
+ // A default constructor is required for deserialization
+ public Order() { }
+
+ public Order(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
+ }
+
+ public void ToData(IPdxWriter output)
+ {
+ output.WriteLong(ORDER_ID_KEY_, OrderId);
+ output.MarkIdentityField(ORDER_ID_KEY_);
+
+ output.WriteString(NAME_KEY_, Name);
+ output.MarkIdentityField(NAME_KEY_);
+
+ output.WriteInt(QUANTITY_KEY_, Quantity);
+ output.MarkIdentityField(QUANTITY_KEY_);
+ }
+
+ public void FromData(IPdxReader input)
+ {
+ OrderId = input.ReadLong(ORDER_ID_KEY_);
+ Name = input.ReadString(NAME_KEY_);
+ Quantity = (short)input.ReadInt(QUANTITY_KEY_);
+ }
+
+ public Int32 ClassId
+ {
+ get { return 0x42; }
+ }
+
+ public ulong ObjectSize
+ {
+ get { return 0x04; }
+ }
+
+ public static IPdxSerializable CreateDeserializable()
+ {
+ return new Order();
+ }
+ }
+}
+
+
diff --git a/examples/dotnet/PdxSerializableCs/Program.cs b/examples/dotnet/PdxSerializableCs/Program.cs
new file mode 100644
index 0000000..ffed9dd
--- /dev/null
+++ b/examples/dotnet/PdxSerializableCs/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();
+
+ Console.WriteLine("Registering for data serialization");
+
+ cache.TypeRegistry.RegisterPdxType(Order.CreateDeserializable);
+
+ var poolFactory = cache.GetPoolFactory()
+ .AddLocator("localhost", 10334);
+ poolFactory.Create("pool");
+
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var orderRegion = regionFactory.Create<int, Order>("example_orderobject");
+
+ Console.WriteLine("Storing order object in the region");
+
+ const int orderKey = 65;
+
+ var order = new Order(orderKey, "Donuts", 12);
+
+ 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/PdxSerializableCs/README.md b/examples/dotnet/PdxSerializableCs/README.md
new file mode 100644
index 0000000..bbe7ecd
--- /dev/null
+++ b/examples/dotnet/PdxSerializableCs/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/PdxSerializableCs/startserver.ps1 b/examples/dotnet/PdxSerializableCs/startserver.ps1
new file mode 100644
index 0000000..c3d5735
--- /dev/null
+++ b/examples/dotnet/PdxSerializableCs/startserver.ps1
@@ -0,0 +1,39 @@
+# 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.
+
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
+
+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=example_orderobject --type=PARTITION'"
+}
\ No newline at end of file
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/dotnet/PdxSerializableCs/stopserver.ps1
old mode 100755
new mode 100644
similarity index 50%
copy from examples/cpp/customserializable/stopserver.sh
copy to examples/dotnet/PdxSerializableCs/stopserver.ps1
index f406a23..a95b7a7
--- a/examples/cpp/customserializable/stopserver.sh
+++ b/examples/dotnet/PdxSerializableCs/stopserver.ps1
@@ -1,4 +1,4 @@
-# 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
@@ -13,19 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!/bin/env bash
-GFSH_PATH=""
-which gfsh 2> /dev/null
-
-if [ $? -eq 0 ]; then
- GFSH_PATH="gfsh"
-else
- if [ "$GEODE_HOME" == "" ]; then
- echo "Could not find gfsh. Please set the GEODE_HOME path."
- echo "e.g. export GEODE_HOME=<path to Geode>"
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
- GFSH_PATH=$GEODE_HOME/bin/gfsh
- fi
-fi
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
-$GFSH_PATH -e "connect" -e "stop server --name=server" -e "stop locator --name=locator"
+if ($GFSH_PATH -ne "")
+{
+ 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/CMakeLists.txt.in b/examples/dotnet/RemoteQueryCs/CMakeLists.txt
similarity index 65%
copy from examples/dotnet/CMakeLists.txt.in
copy to examples/dotnet/RemoteQueryCs/CMakeLists.txt
index fb4695d..7809b2f 100644
--- a/examples/dotnet/CMakeLists.txt.in
+++ b/examples/dotnet/RemoteQueryCs/CMakeLists.txt
@@ -15,9 +15,17 @@
cmake_minimum_required(VERSION 3.10)
-project(@PRODUCT_DLL_NAME@.DotNet.Examples LANGUAGES NONE)
+project(RemoteQueryCs LANGUAGES CSharp)
-add_subdirectory(AuthInitialize)
-add_subdirectory(PdxAutoSerializer)
-add_subdirectory(PutGetRemove)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
+find_package(GeodeNative REQUIRED COMPONENTS dotnet)
+
+add_executable(${PROJECT_NAME} Order.cs;Program.cs)
+
+target_link_libraries(${PROJECT_NAME}
+ GeodeNative::dotnet)
+
+set_target_properties(${PROJECT_NAME} PROPERTIES
+ VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2"
+ VS_DOTNET_REFERENCES "System;${GeodeNative_DOTNET_LIBRARY}")
diff --git a/examples/dotnet/RemoteQueryCs/Order.cs b/examples/dotnet/RemoteQueryCs/Order.cs
new file mode 100644
index 0000000..332316d
--- /dev/null
+++ b/examples/dotnet/RemoteQueryCs/Order.cs
@@ -0,0 +1,83 @@
+/*
+* 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 Apache.Geode.Client;
+using System;
+
+namespace Apache.Geode.Examples.Serializer
+{
+ public class Order : IPdxSerializable
+ {
+ private const string ORDER_ID_KEY_ = "order_id";
+ private const string NAME_KEY_ = "name";
+ private const string QUANTITY_KEY_ = "quantity";
+
+ public long OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
+
+ // A default constructor is required for deserialization
+ public Order() { }
+
+ public Order(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
+ }
+
+ public void ToData(IPdxWriter output)
+ {
+ output.WriteLong(ORDER_ID_KEY_, OrderId);
+ output.MarkIdentityField(ORDER_ID_KEY_);
+
+ output.WriteString(NAME_KEY_, Name);
+ output.MarkIdentityField(NAME_KEY_);
+
+ output.WriteInt(QUANTITY_KEY_, Quantity);
+ output.MarkIdentityField(QUANTITY_KEY_);
+ }
+
+ public void FromData(IPdxReader input)
+ {
+ OrderId = input.ReadLong(ORDER_ID_KEY_);
+ Name = input.ReadString(NAME_KEY_);
+ Quantity = (short)input.ReadInt(QUANTITY_KEY_);
+ }
+
+ public Int32 ClassId
+ {
+ get { return 0x42; }
+ }
+
+ public ulong ObjectSize
+ {
+ get { return 0x04; }
+ }
+
+ public static IPdxSerializable CreateDeserializable()
+ {
+ return new Order();
+ }
+ }
+}
+
+
diff --git a/examples/dotnet/RemoteQueryCs/README.md b/examples/dotnet/RemoteQueryCs/README.md
new file mode 100644
index 0000000..bbe7ecd
--- /dev/null
+++ b/examples/dotnet/RemoteQueryCs/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/RemoteQueryCs/startserver.ps1 b/examples/dotnet/RemoteQueryCs/startserver.ps1
new file mode 100644
index 0000000..0738fd6
--- /dev/null
+++ b/examples/dotnet/RemoteQueryCs/startserver.ps1
@@ -0,0 +1,39 @@
+# 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.
+
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
+
+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=custom_orders --type=PARTITION'"
+}
\ No newline at end of file
diff --git a/examples/cpp/customserializable/stopserver.sh b/examples/dotnet/RemoteQueryCs/stopserver.ps1
old mode 100755
new mode 100644
similarity index 50%
rename from examples/cpp/customserializable/stopserver.sh
rename to examples/dotnet/RemoteQueryCs/stopserver.ps1
index f406a23..fed864b
--- a/examples/cpp/customserializable/stopserver.sh
+++ b/examples/dotnet/RemoteQueryCs/stopserver.ps1
@@ -1,4 +1,4 @@
-# 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
@@ -13,19 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!/bin/env bash
-GFSH_PATH=""
-which gfsh 2> /dev/null
-
-if [ $? -eq 0 ]; then
- GFSH_PATH="gfsh"
-else
- if [ "$GEODE_HOME" == "" ]; then
- echo "Could not find gfsh. Please set the GEODE_HOME path."
- echo "e.g. export GEODE_HOME=<path to Geode>"
+$GFSH_PATH = ""
+if (Get-Command gfsh -ErrorAction SilentlyContinue)
+{
+ $GFSH_PATH = "gfsh"
+}
+else
+{
+ if (-not (Test-Path env:GEODE_HOME))
+ {
+ 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
- GFSH_PATH=$GEODE_HOME/bin/gfsh
- fi
-fi
+ {
+ $GFSH_PATH = "$env:GEODE_HOME\bin\gfsh.bat"
+ }
+}
-$GFSH_PATH -e "connect" -e "stop server --name=server" -e "stop locator --name=locator"
+if ($GFSH_PATH -ne "")
+{
+ Invoke-Expression "$GFSH_PATH -e 'connect' -e 'destroy region --name=custom_orders' -e 'stop server --name=server' -e 'stop locator --name=locator'"
+}
\ No newline at end of file