public void Set(ParserValue obj, string varName, ParserValue indexer, ParserValue result) { if (!this.Enabled) { return; } if (obj is StaticClass) { StaticClass staticClass = (StaticClass)obj; Type type = staticClass.Type; if (type == null) { Fail("Couldn't get type for: " + staticClass.Type.FullName); } if (!SetStaticField(type, varName, result)) { obj = CurrentScope.Get(staticClass.Name); } else { return; } } if (indexer.IsNotNull) { obj = Get(obj, varName, ParserValue.Empty); SetIndex(obj, indexer, result); } else { if (obj.IsNull) { CurrentScope.Set(varName, result); } else { if (!SetField(obj, varName, result)) { Fail("Couldn't find field: " + varName); } } } }
public ParserValue Get(ParserValue obj, string token) { if (!Enabled) { return(ParserValue.Empty); } if (obj.IsNull) { if (token == "#") { obj = new StaticClass(token, ShortCut); } else if (TypeBinding.ContainsKey(token)) { Type type = (Type)TypeBinding[token]; obj = new StaticClass(token, type); } else if (CurrentScope.Contains(token)) { obj = CurrentScope.Get(token); } else if (Namespaces.Contains(token)) { obj = new ScopeClass(token, (ResourceScope)Namespaces[token]); } else { Fail("Can't find field or type: " + token); } return(obj); } ParserValue result = ParserValue.Empty; if (obj is StaticClass) { Type type = (obj as StaticClass).Type; if (GetStaticField(type, token, out result)) { return(result); } obj = CurrentScope.Get((obj as StaticClass).Name); } else if (obj is ScopeClass) { ResourceScope scope = (obj as ScopeClass).Scope; if (scope.Contains(token)) { return(scope.Get(token)); } string newScopeName = scope.Name + "." + token; if (Namespaces.Contains(newScopeName)) { return(new ScopeClass(newScopeName, (ResourceScope)Namespaces[newScopeName])); } else { obj = CurrentScope.Get(scope.Name); } } if (!GetField(obj, token, out result)) { Fail("Couldn't get field/property " + token + " for type " + obj.Type.ToString()); } return(result); }