Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SyncProperty(syncPath, syncValue) {
- hier=syncPath.Split("/"[0]);
- level=hier.Length;
- if (level==0) return;
- prop=hier[level-1];
- curPath=stateView;
- for (nest=0;(nest+1)<level;++nest) {
- dir=hier[nest];
- if (!curPath.Contains(dir)) {
- curPath[dir]=new Hashtable();
- }
- //print("dir="+dir);
- newPath=curPath[dir];
- t=""+typeof(newPath);
- //print("type(dir)="+t);
- if (t != "System.Collections.Hashtable") {
- var msg : String;
- msg="The path '"+syncPath+"' descends thru non-descendable data key '"+dir+"' (contains data: "+newPath+").";
- throw(msg);
- } else {
- curPath=newPath;
- }
- }
- if (syncValue!=null) {
- curPath[prop]=syncValue;
- } else {
- if (curPath.Contains(prop)) curPath.Remove(prop);
- }
- }
- // Dump state view in JSON format
- function StateToString(rootPath : Hashtable) : String {
- str="{";
- dir=rootPath;
- cur=0;
- count=dir.Keys.Count;
- for (key in dir.Keys) {
- delim=",";
- if (cur+1>=count) delim="";
- obj=dir[key];
- objType=""+typeof(obj);
- if (objType=="System.Collections.Hashtable") {
- str+=key+StateToString(obj)+delim;
- } else {
- str+=(key+":"+obj+delim);
- }
- ++cur;
- }
- str+="}";
- return str;
- }
- function StateToString() : String {
- return StateToString(stateView);
- }
Add Comment
Please, Sign In to add comment