/// <summary>Initialize configuration. /// </summary> /// <param>servRoot</param> public static void Init(string servRoot, bool verbose = false) { // c# problem - must use the assembly name for consturcting object instance // JSONAnsonListener.setAssembly(Assembly.GetExecutingAssembly().GetName().Name); JSONAnsonListener.setAssembly("anclient.net"); servRt = servRoot; AnClient.verbose = verbose; }
/// <summary>Initialize configuration. /// </summary> /// <param>servRoot</param> public static void Init(string servRoot) { // c# problem - must use the assembly name for consturcting object instance // JSONAnsonListener.setAssembly(Assembly.GetExecutingAssembly().GetName().Name); JSONAnsonListener.setAssembly("anclient.net"); servRt = servRoot; conn = null; // client can't control engine connect. configured in workflow-meta.xml }
private static IJsonable parse(ICharStream ins) { JSONLexer lexer = new JSONLexer(ins); CommonTokenStream tokens = new CommonTokenStream(lexer); JSONParser parser = new JSONParser(tokens); JsonContext ctx = parser.json(); ParseTreeWalker walker = new ParseTreeWalker(); JSONAnsonListener lstner = new JSONAnsonListener(); walker.Walk(lstner, ctx); return(lstner.ParsedEnvelope()); }
public IJsonable ToBlock(Stream stream, JsonOpt opt = null) { bool quotK = opt == null || opt.quotKey; Type type = GetType(); Utils.WriteByt(stream, '{'); Utils.WriteStr(stream, "type", quotK); Utils.WriteByt(stream, ':', ' '); Utils.WriteStr(stream, GetType().FullName, true); Hashtable fmap = new Hashtable(); Hashtable pmap = new Hashtable(); JSONAnsonListener.MergeFields(type, fmap, pmap); foreach (FieldInfo f in fmap.Values) { if (f.Name.EndsWith("BackingField")) { continue; // properties backing field } AnsonField af = (AnsonField)Attribute.GetCustomAttribute(f, typeof(AnsonField)); object v = f.GetValue(this); WritePair(stream, af, f.GetType(), f.FieldType, f.Name, v, opt); } foreach (PropertyInfo p in pmap.Values) { AnsonField af = (AnsonField)Attribute.GetCustomAttribute(p, typeof(AnsonField)); object v = p.GetValue(this); WritePair(stream, af, p.GetType(), p.PropertyType, p.Name, v, opt); } Utils.WriteByt(stream, '}'); stream.Flush(); return(this); }
/// <summary> /// Setup a register for extinding new port. /// </summary> static Port() { JSONAnsonListener.registFactory(typeof(Port), new PortFactory()); }
static AnsonTest() { JSONAnsonListener.setAssembly(Assembly.GetExecutingAssembly().GetName().Name); }
static AlbumPort() { JSONAnsonListener.registFactory(typeof(AlbumPort), new AlbumPortFactory()); }