source: trunk/zoo-project/zoo-api/mono/ZMaps.cs @ 866

Last change on this file since 866 was 794, checked in by djay, 8 years ago

Add the initial C# language support.

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1/*
2 * Author : Gérald FENOY
3 *
4 * Copyright (c) 2016 GeoLabs SARL
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24using System;
25using System.Collections.Generic;
26using System.Runtime.InteropServices;
27using System.Runtime.CompilerServices;
28
29public static class ZOO_API{
30    public static int SERVICE_SUCCEEDED=3;
31    public static int SERVICE_FAILED=4;
32    [MethodImplAttribute(MethodImplOptions.InternalCall)]
33    extern public static string Translate(string str);
34    [MethodImplAttribute(MethodImplOptions.InternalCall)]
35    extern public static void UpdateStatus([In] ZooGenerics.ZMaps obj,string str,int p);
36};
37
38namespace ZooGenerics
39{
40    public class KeysList : List<String> { };
41    public class ZMap : Dictionary<String,String> {
42        public int getKeysCount(){
43            List<String> tmp=new List<String>(this.Keys);
44            return tmp.Count;
45        }
46        public String getKey(int i){
47            List<String> tmp=new List<String>(this.Keys);
48            return tmp[i];
49        }
50        public void addToMap(String name,String value){
51            this.Add(name,value);
52        }
53        public String getMap(String name){
54            String test;
55            if(this.TryGetValue(name, out test)){
56                return test;
57            }
58            return null;
59        }
60        public byte[] getMapAsBytes(String name){
61            String test;
62            if(this.TryGetValue(name, out test)){
63                return System.Text.Encoding.UTF8.GetBytes(test);
64            }
65            return null;
66        }
67        public int getSize(){
68            String test;
69            if(this.TryGetValue("size", out test)){
70                return int.Parse(test);
71            }
72            return -1;
73        }
74    };
75    public class _ZMaps
76    {
77        private ZMap content; 
78        private Dictionary<string,_ZMaps> child;
79        public _ZMaps(){
80            this.content=null;
81            this.child=null;
82        }
83        public void setContent(ZMap content){
84            this.content=content;
85        }
86        public void setChild(Dictionary<string,_ZMaps> content){
87            this.child=content;
88        }
89        public void AddContent(String key,String value){
90            this.content.Add(key,value);
91        }
92        public ZMap getContent(){
93            return this.content;
94        }
95        public Dictionary<string,_ZMaps> getChild(){
96            return this.child;
97        }
98    }
99    public class ZMaps : Dictionary<String,_ZMaps> {
100        public int getKeysCount(){
101            List<String> tmp=new List<String>(this.Keys);
102            return tmp.Count;
103        }
104        public String getKey(int i){
105            List<String> tmp=new List<String>(this.Keys);
106            return tmp[i];
107        }
108        public _ZMaps getValue(String key){
109            return this[key];
110        }
111        public List<String> getKeys(){
112            return new List<String>(this.Keys);
113        }
114        public void addToMaps(String name,_ZMaps content){
115            this.Add(name,content);
116        }
117        public void setMapsInMaps(String mname,String name,String value){
118            _ZMaps test;
119            if (this.TryGetValue(mname, out test)) // Returns true.
120            {
121                ZMap content=test.getContent();
122                content.addToMap(name,value);
123            }
124        }
125        public _ZMaps getMaps(String name){
126            _ZMaps test;
127            if(this.TryGetValue(name, out test)){
128                return test;
129            }
130            return null;
131        }
132    };
133}
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png