示例#1
0
        /// <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;
        }
示例#2
0
        /// <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
        }
示例#3
0
文件: Anson.cs 项目: odys-z/antson
        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());
        }
示例#4
0
文件: Anson.cs 项目: odys-z/antson
        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);
        }
示例#5
0
 /// <summary>
 /// Setup a register for extinding new port.
 /// </summary>
 static Port()
 {
     JSONAnsonListener.registFactory(typeof(Port), new PortFactory());
 }
示例#6
0
 static AnsonTest()
 {
     JSONAnsonListener.setAssembly(Assembly.GetExecutingAssembly().GetName().Name);
 }
示例#7
0
 static AlbumPort()
 {
     JSONAnsonListener.registFactory(typeof(AlbumPort), new AlbumPortFactory());
 }