You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by km...@apache.org on 2017/03/29 00:31:22 UTC
[2/3] geode-native git commit: GEODE-2513 Unbrand .NET API docs
section
http://git-wip-us.apache.org/repos/asf/geode-native/blob/226662f0/docs/geode-native-docs/dotnet-caching-api/using-ipdxinstancefactory.html.md.erb
----------------------------------------------------------------------
diff --git a/docs/geode-native-docs/dotnet-caching-api/using-ipdxinstancefactory.html.md.erb b/docs/geode-native-docs/dotnet-caching-api/using-ipdxinstancefactory.html.md.erb
index f968067..bd46115 100644
--- a/docs/geode-native-docs/dotnet-caching-api/using-ipdxinstancefactory.html.md.erb
+++ b/docs/geode-native-docs/dotnet-caching-api/using-ipdxinstancefactory.html.md.erb
@@ -23,103 +23,5 @@ You can use the `IPdxInstanceFactory` to create an `IPdxInstance` from raw data
This option can be useful when you need an instance of a domain class for plug-in code such as a function or a loader. If you have the raw data for the domain object (the class name and each field's type and data), then you can explicitly create a `IPdxInstance`. The `IPdxInstanceFactory` is very similar to the `IPdxWriter` except that after writing each field, you need to call the create method which returns the created `IPdxInstance.`
-## Creating an IPdxInstance with IPdxInstanceFactory
-
-``` pre
-/*
- * The PdxInstance QuickStart Example.
- * This example takes the following steps:
- *
- * This example shows IPdxInstanceFactory and IPdxInstance usage.
- *
- * 1. Create a Cache.
- * 2. Creates the PdxInstanceFactory for Person class.
- * 3. Then creates instance of PdxInstance
- * 4. It does put.
- * 5. Then it does get and access it fields.
- * 6. Close the Cache.
- *
-*/
-// Use standard namespaces
-using System;
-using System.Reflection;
-// Use the GemFire namespace
-using GemStone.GemFire.Cache.Generic;
-namespace GemStone.GemFire.Cache.Generic.QuickStart {
- public class Person {
- private string name;
- // this is the only field used on server to create hashcode
- // and use in equals method
- [PdxIdentityField]
- private int id;
- private int age;
- public Person() { }
- public Person(string name, int id, int age) {
- this.name = name;
- this.id = id;
- this.age = age;
- }
- #region Public Properties
- public string Name {
- get { return name; }
- }
- public int ID {
- get { return id; }
- }
- public int Age {
- get { return age; }
- }
- #endregion
- }
-
- // The PdxRemoteQuery QuickStart example.
- class PdxInstance {
- static void Main(string[] args) {
- try {
- CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(null);
- Console.WriteLine("Connected to the Distributed System");
- // Create a Cache with the "clientPdxRemoteQuery.xml" Cache XML file.
- // Set SetPdxReadSerialized to true to access PdxInstance
- Cache cache = cacheFactory.Set("cache-xml-file",
- "XMLs/clientPdxInstance.xml").Create();
- Console.WriteLine("Created the Cache");
- // Get the example Region from the Cache which is declared
- // in the Cache XML file.
- IRegion<string, IPdxInstance> region =
- cache.GetRegion<string, IPdxInstance>("Person");
- Console.WriteLine("Obtained the Region from the Cache");
- Person p = new Person("Jack", 7, 21);
- //PdxInstanceFactory for Person class
- IPdxInstanceFactory pif = cache.CreatePdxInstanceFactory("Person");
- pif.WriteString("name", p.Name);
- pif.WriteInt("id", p.ID);
- pif.MarkIdentityField("id");
- pif.WriteInt("age", p.Age);
- IPdxInstance pdxInstance = pif.Create();
- Console.WriteLine("Created PdxInstance for Person class");
- region["Key1"] = pdxInstance;
- Console.WriteLine("Populated PdxInstance Object");
- IPdxInstance retPdxInstance = region["Key1"];
- if ((int)retPdxInstance.GetField("id") == p.ID
- && (int)retPdxInstance.GetField("age") == p.Age
- && (string)retPdxInstance.GetField("name") == p.Name
- && retPdxInstance.IsIdentityField("id") == true)
- Console.WriteLine("PdxInstance returns all fields value expected");
- else
- Console.WriteLine("PdxInstance doesn't returns all fields
- value expected");
-
- // Close the Cache.
- cache.Close();
- Console.WriteLine("Closed the Cache");
- }
- // An exception should not occur
- catch (GemFireException gfex) {
- Console.WriteLine("PdxSerializer Exception: {0}", gfex.Message);
- }
- }
- }
-}
-```
-
+View the PdxInstance QuickStart for an example.