public static void Deserialize(JObject v, DynObject o)
        {
            foreach (var item in v)
            {
                var j = new DynObject()
                {
                };
                o.Items.Add(item.Key, j);

                if (item.Value is JValue v1)
                {
                    j.SetValue(v1.Value.ToString());
                }

                else if (item.Value is JObject v2)
                {
                    Deserialize(v2, o);
                }

                else if (item.Value is JArray v3)
                {
                    Deserialize(v3, o);
                }

                else
                {
                }
            }
        }
Esempio n. 2
0
    public static VarDeque HashIterRaw(int mode, Variable v)
    {
        IP6 o = NominalCheck("$x", Kernel.AnyMO, v);
        VarHash d = Kernel.UnboxAny<VarHash>(o);

        VarDeque lv = new VarDeque();

        foreach (KeyValuePair<string,Variable> kv in d) {
            switch (mode) {
                case 0:
                    lv.Push(Kernel.BoxAnyMO<string>(kv.Key, Kernel.StrMO));
                    break;
                case 1:
                    lv.Push(kv.Value);
                    break;
                case 2:
                    lv.Push(Kernel.BoxAnyMO<string>(kv.Key, Kernel.StrMO));
                    lv.Push(kv.Value);
                    break;
                case 3:
                    DynObject p = new DynObject(Kernel.PairMO);
                    p.slots[0] = Kernel.BoxAnyMO<string>(kv.Key, Kernel.StrMO);
                    p.slots[1] = kv.Value;
                    lv.Push(Kernel.NewROScalar(p));
                    break;
            }
        }
        return lv;
    }
Esempio n. 3
0
        public void ExtendedSetTest()
        {
            dynamic dyn = new DynObject();

            dyn.foo.bar.baz = "bar";
            Assert.AreEqual("bar", dyn.foo.bar.baz);
        } // end ExtendedSetTest
        public static void Deserialize(JArray v, DynObject o)
        {
            o.IsArray = true;

            foreach (var item in v)
            {
                var j = new DynObject()
                {
                };
                o.Items.Add(o.Items.Count.ToString(), j);

                if (item is JValue v1)
                {
                    j.SetValue(v1.Value.ToString());
                }

                else if (item is JObject v2)
                {
                    Deserialize(v2, j);
                }

                else if (item is JArray v3)
                {
                    Deserialize(v3, j);
                }
            }
        }
Esempio n. 5
0
 private void AddProperty(string name, string value, DynObject serialization)
 {
     if (value != null && value.Length > 0)
     {
         serialization[name] = value;
     }
 }
Esempio n. 6
0
            public bool ReadFile(string path)
            {
                this.path = path;
                try
                {
                    if (File.Exists(path))
                    {
                        using (FileStream fr = File.OpenRead(path))
                        {
                            using (BinaryReader br = new BinaryReader(fr))
                            {
                                Heder = br.ReadBytes(4);
                                int count = br.ReadInt32();
                                objects = new DynObject[count];
                                for (int i = 0; i < count; i++)
                                {
                                    DynObject dinamic = new DynObject();
                                    dinamic.id = br.ReadInt32();
                                    int length = br.ReadInt32();
                                    dinamic.Path = new AngelicaSTRING(length, br, Encoding.GetEncoding("gb2312"));
                                    objects[i]   = dinamic;
                                }
                            }
                        }

                        return(true);
                    }
                }
                catch { }
                return(false);
            }
Esempio n. 7
0
        public void BasicSetTest()
        {
            dynamic dyn = new DynObject();

            dyn.foo = "bar";
            Assert.AreEqual("bar", dyn.foo);
        } // end BasicSetTest
Esempio n. 8
0
        public TestTankClient(DynObject startResponse, TankAction expectedAction, DynObject takeActionResponse = null)
        {
            this.expectedAction = expectedAction;
            this.startResponse  = startResponse;

            if (takeActionResponse == null)
            {
                takeActionResponse = DynObject.Parse(@"{
                    'status': 'won',
                    'health': 200,
                    'energy': 10,
                    'orientation': 'north',
                    'grid': '________________________
___W_____WWWWWWWW_______
___W_W__________________
___W_W_______B__________
___W_W__________________
___W_W__________________
_WWWWWWWWW___L____O_____
_____W__________________
_____W_WWWWW____________
_________WWWWWWWW_______
________________________
___________WWWW_________
__X_____________________
________________________
____WWW_________________
________________________'
                }");
            }

            this.takeActionResponse = takeActionResponse;
        }
        private string GenerateRelationFormJsCode(DynObject relationForm, string templateName)
        {
            List <Rock.Dyn.Core.DynObject> masterFormItems      = relationForm["MasterFormItems"] as List <Rock.Dyn.Core.DynObject>;
            List <Rock.Dyn.Core.DynObject> masterGridColumns    = relationForm["MasterGridColumns"] as List <Rock.Dyn.Core.DynObject>;
            List <Rock.Dyn.Core.DynObject> slaveGridColumns     = relationForm["SlaveGridColumns"] as List <Rock.Dyn.Core.DynObject>;
            List <Rock.Dyn.Core.DynObject> slaveWaitGridColumns = relationForm["SlaveWaitGridColumns"] as List <Rock.Dyn.Core.DynObject>;

            if (masterFormItems.Count == 0)
            {
                return("主实体类型未添加表单项");
            }
            if (masterGridColumns.Count == 0)
            {
                return("主实体类型未添加表格列集合");
            }
            if (slaveGridColumns.Count == 0)
            {
                return("从实体类型未添加表格列集合");
            }
            if (slaveWaitGridColumns.Count == 0)
            {
                return("从实体类型未添加待选表格列集合");
            }

            Dictionary <string, object> item = new Dictionary <string, object>();
            Template dictTemplate            = Template.Create("RelationTemplatet", File.ReadAllText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "bin\\Templatet\\" + templateName + ".txt", Encoding.UTF8));

            item.Add("relationForm", relationForm);
            return(dictTemplate.Render("RelationTemplatet", item));
        }
        public string GenerateJsCode(DynObject fromModel, string templateType, string templateName)
        {
            string result;

            switch (templateType)
            {
            case "DictForm":
                result = GenerateDictFormJsCode(fromModel, templateName);
                break;

            case "BillListForm":
                result = GenerateBillListFormJsCode(fromModel, templateName);
                break;

            case "BillForm":
                result = GenerateBillFormJsCode(fromModel, templateName);
                break;

            case "TreeForm":
                result = GenerateTreeFormJsCode(fromModel, templateName);
                break;

            case "RelationForm":
                result = GenerateRelationFormJsCode(fromModel, templateName);
                break;

            default:
                result = "模板类型不存在!";
                break;
            }
            return(result);
        }
Esempio n. 11
0
        public void OpenWorkflow(int workflowID)
        {
            Workflow = SystemService.GetDynObjectByID("Workflow", workflowID);
            if (Workflow != null)
            {
                _designer   = new WorkflowDesigner();
                _undoEngine = _designer.Context.Services.GetService <UndoEngine>();
                _undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                {
                    _designer.Flush();
                    CanUndo = true;
                };

                DesignerView    = _designer.View;
                PropertyContent = _designer.PropertyInspectorView;
                _designer.Text  = Workflow["Definition"].ToString();
                _designer.Load();
                WorkflowName = Workflow["WorkflowName"].ToString();
                EditState    = "modify";
                CanUndo      = false;
                CanRedo      = false;
                DeleteCommand.RaiseCanExecuteChanged();
            }
            else
            {
                MessageBox.Show("所选的工作流在数据库中不存在,请检查!");
            }
        }
Esempio n. 12
0
 private void AddProperty(string name, string value, DynObject serialization)
 {
     if (value != null && value.Length > 0)
     {
         serialization[name] = value;
     }
 }
Esempio n. 13
0
        private DynObject Transfer(ushort serverPort, byte[] buffer, int count)
        {
            //发送数据
            Send(serverPort, buffer);

            ZmqMessage message = _ftpSocket.ReceiveMessage(new TimeSpan(0, 1, 30));

            if (message.FrameCount == 0)
            {
                _isWorking = false;
                ReStart();
                throw new TimeoutException("发送超时,请检查你的网络是否有问题,稍后重新上传");
            }
            else
            {
                //反序列化,取出服务端响应数据
                byte[]      respData   = message[message.FrameCount - 1].Buffer;
                TSerializer serializer = new TBinarySerializer();
                serializer.FromBytes(respData);
                DynObject fileFragment = DynSerialize.ReadDynObject(serializer);
                serializer.Flush();

                //105:发生异常
                if ((byte)fileFragment["State"] == 105)
                {
                    _isWorking = false;
                    throw new ApplicationException(fileFragment["ExcepMsg"] as string);
                }

                return(fileFragment);
            }
        }
Esempio n. 14
0
        public void MethodTest()
        {
            dynamic dyn = new DynObject();

            dyn.Add("foo", "bar");
            Assert.AreEqual("bar", dyn.foo);
        } // end AccessorTest
Esempio n. 15
0
        public TestTankClient(DynObject startResponse, TankAction expectedAction, DynObject takeActionResponse = null)
        {
            this.expectedAction = expectedAction;
            this.startResponse = startResponse;

            if (takeActionResponse == null)
            {
                takeActionResponse = DynObject.Parse(@"{
                    'status': 'won',
                    'health': 200,
                    'energy': 10,
                    'orientation': 'north',
                    'grid': '________________________
            ___W_____WWWWWWWW_______
            ___W_W__________________
            ___W_W_______B__________
            ___W_W__________________
            ___W_W__________________
            _WWWWWWWWW___L____O_____
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            __X_____________________
            ________________________
            ____WWW_________________
            ________________________'
                }");
            }

            this.takeActionResponse = takeActionResponse;
        }
        public static DynObject Deserialize(string text)
        {
            var o      = JObject.Parse(text);
            var result = new DynObject();

            Deserialize(o, result);
            return(result);
        }
Esempio n. 17
0
 public static Variable HashIter(int mode, Variable v)
 {
     VarDeque lv = HashIterRaw(mode, v);
     DynObject l = new DynObject(Kernel.ListMO);
     l.slots[0] = lv;
     l.slots[1] = new VarDeque();
     return Kernel.NewRWListVar(l);
 }
Esempio n. 18
0
        public void GetValueTest()
        {
            dynamic dyn = new DynObject();

            dyn.Add("foo", "bar");
            Assert.AreEqual("bar", dyn.GetValue("foo"));
            Assert.AreEqual(null, dyn.GetValue("baz"));
            Assert.AreEqual("notbar", dyn.GetValue("baz", "notbar"));
        } // end AccessorTest
        public DynObject GetBillListFormByID(int billListFormID)
        {
            DynObject result       = null;
            DynEntity billListForm = GatewayFactory.Default.Find("BillListForm", billListFormID);

            if (billListForm != null)
            {
                result = DynObjectTransverter.JsonToDynObject(billListForm["Model"] as string);
            }
            return(result);
        }
        public DynObject GetDictFormByID(int dictFormID)
        {
            DynObject result   = null;
            DynEntity dictForm = GatewayFactory.Default.Find("DictForm", dictFormID);

            if (dictForm != null)
            {
                result = DynObjectTransverter.JsonToDynObject(dictForm["Model"] as string);
            }
            return(result);
        }
        public DynObject GetRelationFormByID(int relationFormID)
        {
            DynObject result       = null;
            DynEntity relationForm = GatewayFactory.Default.Find("RelationForm", relationFormID);

            if (relationForm != null)
            {
                result = DynObjectTransverter.JsonToDynObject(relationForm["Model"] as string);
            }
            return(result);
        }
 public void AddTemplate(string key, DynObject o)
 {
     if (_dic.ContainsKey(key))
     {
         _dic[key] = (r) => o.Clone();
     }
     else
     {
         _dic.Add(key, (r) => o.Clone());
     }
 }
        public static string SerializeToText(this DynObject value)
        {
            var result = value.Serialize();

            if (result == null)
            {
                return(string.Empty);
            }

            return(result.ToString(Newtonsoft.Json.Formatting.None));
        }
Esempio n. 24
0
        public DynObject Serialize()
        {
            DynObject serialization = new DynObject();
            AddProperty("name", name, serialization);
            AddProperty("description", description, serialization);
            AddProperty("method", method, serialization);
            AddProperty("requestPattern", requestPattern, serialization);
            AddProperty("requestExample", requestExample, serialization);
            AddObject("requestExampleBody", requestExampleBody, serialization);
            AddObject("responseExample", responseExample, serialization);

            return serialization;
        }
Esempio n. 25
0
            public DynObject onFileDownload(DynObject fileFragment)
            {
                byte ctlCode    = (byte)fileFragment["State"];
                int  dataLength = (int)fileFragment["DataLength"];

                switch (ctlCode)
                {
                case 100:     //请求下载文件
                    string filePath = Path.Combine(fileFragment["Path"] as string, fileFragment["FileName"] as string);
                    string md5      = GetMD5HashFromFile(filePath);
                    _fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);

                    fileFragment["MD5"]        = md5;
                    fileFragment["FileLength"] = _fileStream.Length;
                    fileFragment["DataLength"] = 0;
                    fileFragment["Data"]       = null;
                    break;

                case 101:    //文件传送中
                    if (_fileStream == null)
                    {
                        throw new FtpException("FtpServer文件流已被中断,请重新传送");
                    }

                    _fileStream.Seek((int)fileFragment["MsgID"] * _bufferLength, SeekOrigin.Begin);
                    dataLength = _fileStream.Read(buffer, 0, buffer.Length);

                    fileFragment["DataLength"] = dataLength;
                    fileFragment["Data"]       = buffer;
                    break;

                case 102:     //文件传送结束
                    _isRunning = false;

                    fileFragment["DataLength"] = 0;
                    fileFragment["Data"]       = null;

                    _fileStream.Close();
                    _fileStream = null;
                    break;

                case 103:     //中断文件传送
                    _isRunning = false;

                    _fileStream.Close();
                    _fileStream = null;
                    break;
                }

                return(fileFragment);
            }
Esempio n. 26
0
 private void AddObject(string name, string value, DynObject serialization)
 {
     if (value != null && value.Length > 0)
     {
         if (value[0] == '{')
         {
             serialization[name] = DynObject.Parse(value);
         }
         else
         {
             serialization[name] = value;
         }
     }
 }
Esempio n. 27
0
        public DynObject Serialize()
        {
            DynObject serialization = new DynObject();

            AddProperty("name", name, serialization);
            AddProperty("description", description, serialization);
            AddProperty("method", method, serialization);
            AddProperty("requestPattern", requestPattern, serialization);
            AddProperty("requestExample", requestExample, serialization);
            AddObject("requestExampleBody", requestExampleBody, serialization);
            AddObject("responseExample", responseExample, serialization);

            return(serialization);
        }
Esempio n. 28
0
 private void AddObject(string name, string value, DynObject serialization)
 {
     if (value != null && value.Length > 0)
     {
         if (value[0] == '{')
         {
             serialization[name] = DynObject.Parse(value);
         }
         else
         {
             serialization[name] = value;
         }
     }
 }
        public void AddTreeForm(DynObject treeForm)
        {
            Check.Require(treeForm != null, "TreeForm对象不允许为空!");
            DynEntity treeFormEntity = new DynEntity("TreeForm");

            treeFormEntity["TreeFormID"]    = treeForm["TreeFormID"];
            treeFormEntity["TreeFormName"]  = treeForm["TreeFormName"];
            treeFormEntity["ModelType"]     = treeForm["ModelType"];
            treeFormEntity["ModelTypeName"] = treeForm["ModelTypeName"];
            treeFormEntity["ReferTypes"]    = treeForm["ReferTypes"];
            treeFormEntity["ColumnCount"]   = treeForm["ColumnCount"];
            treeFormEntity["Comment"]       = treeForm["Comment"];
            treeFormEntity["Model"]         = DynObjectTransverter.DynObjectToJson(treeForm);
            GatewayFactory.Default.Save(treeFormEntity);
        }
        public void AddRelationForm(DynObject relationForm)
        {
            Check.Require(relationForm != null, "RelationForm对象不允许为空!");
            DynEntity relationFormEntity = new DynEntity("RelationForm");

            relationFormEntity["RelationFormID"]   = relationForm["RelationFormID"];
            relationFormEntity["RelationFormName"] = relationForm["RelationFormName"];
            relationFormEntity["RelationType"]     = relationForm["RelationType"];
            relationFormEntity["MasterType"]       = relationForm["MasterType"];
            relationFormEntity["SlaveType"]        = relationForm["SlaveType"];
            relationFormEntity["MasterTypeName"]   = relationForm["MasterTypeName"];
            relationFormEntity["SlaveTypeName"]    = relationForm["SlaveTypeName"];
            relationFormEntity["ColumnCount"]      = relationForm["ColumnCount"];
            relationFormEntity["Comment"]          = relationForm["Comment"];
            relationFormEntity["Model"]            = DynObjectTransverter.DynObjectToJson(relationForm);
            GatewayFactory.Default.Save(relationFormEntity);
        }
        public void ModifyDictForm(DynObject dictForm)
        {
            Check.Require(dictForm != null, "DictForm对象不允许为空!");
            DynEntity dictFormEntity = GatewayFactory.Default.Find("DictForm", dictForm["DictFormID"]);

            Check.Require(dictFormEntity != null, "DictForm在数据库中不存在无法修改!");

            dictFormEntity["DictFormName"]  = dictForm["DictFormName"];
            dictFormEntity["ModelType"]     = dictForm["ModelType"];
            dictFormEntity["ModelTypeName"] = dictForm["ModelTypeName"];
            dictFormEntity["ReferTypes"]    = dictForm["ReferTypes"];
            dictFormEntity["ColumnCount"]   = dictForm["ColumnCount"];
            dictFormEntity["Comment"]       = dictForm["Comment"];
            dictFormEntity["Model"]         = DynObjectTransverter.DynObjectToJson(dictForm);
            //dictFormEntity["Script"] = GenerateDictFormJsCode(dictForm);
            GatewayFactory.Default.Save(dictFormEntity);
        }
        public void AddBillListForm(DynObject billListForm)
        {
            Check.Require(billListForm != null, "BillListForm对象不允许为空!");
            DynEntity billListFormEntity = new DynEntity("BillListForm");

            billListFormEntity["BillListFormID"]      = billListForm["BillListFormID"];
            billListFormEntity["BillListFormName"]    = billListForm["BillListFormName"];
            billListFormEntity["MasterType"]          = billListForm["MasterType"];
            billListFormEntity["DetailType"]          = billListForm["DetailType"];
            billListFormEntity["ReferTypes"]          = billListForm["ReferTypes"];
            billListFormEntity["BillName"]            = billListForm["BillName"];
            billListFormEntity["DetailMainReferType"] = billListForm["DetailMainReferType"];
            billListFormEntity["DetailMainReferName"] = billListForm["DetailMainReferName"];
            billListFormEntity["Comment"]             = billListForm["Comment"];
            billListFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(billListForm);
            GatewayFactory.Default.Save(billListFormEntity);
        }
Esempio n. 33
0
        public void SerializeOutputAction()
        {
            string uuid = Guid.NewGuid().ToString();

            DynObject.Create("Name", Constants.PushReminder)
            .Add("delay", WorkflowClock.Now().AddMinutes(10).ToString())
            .Add("canal", (ctx) => "IncomingEvent") // --read configuration where canal can be found
            .Add("Message",
                 DynObject.Create("Uuid", uuid)
                 .Add("Name", Constants.Events.ExpiredEventName)
                 .Add("EventDate", (ctx) => WorkflowClock.Now().AddMinutes(10).ToString())
                 .Add("CreationDate", (ctx) => WorkflowClock.Now().ToString())
                 .Add("ExternalId", (ctx) => ctx.Workflow.ExternalId)
                 .Add("CurrentState", (ctx) => ctx.Workflow.CurrentState))

            ;
        }
Esempio n. 34
0
        /// <summary>
        /// 向服务端发送下载文件的请求
        /// </summary>
        /// <param name="destVPort">目的端口</param>
        /// <param name="downloadPath">要下载的文件在服务端的路径</param>
        /// <returns>将要下载文件的基本信息</returns>
        private DynObject RequestDownload(ushort destVPort, string downloadPath)
        {
            DynObject fileFragment = new DynObject("FileFragment");

            fileFragment["Path"]       = Path.GetDirectoryName(downloadPath);
            fileFragment["FileName"]   = Path.GetFileName(downloadPath);
            fileFragment["Extension"]  = Path.GetExtension(downloadPath);
            fileFragment["State"]      = (byte)100;
            fileFragment["MsgID"]      = -1;
            fileFragment["DataLength"] = 0;
            fileFragment["Data"]       = null;

            //序列化要发送的数据
            TSerializer serializer = new TBinarySerializer();

            DynSerialize.WriteDynObject(serializer, fileFragment);
            byte[] buffer = serializer.ToBytes();
            serializer.Flush();

            Send(_serverPort, buffer);
            ZmqMessage msg = _ftpSocket.ReceiveMessage(new TimeSpan(0, 1, 30));

            if (msg.FrameCount == 0)
            {
                _isWorking = false;
                ReStart();
                throw new TimeoutException("发送超时,请检查你的网络是否有问题,稍后重新下载");
            }

            //反序列化,服务器返回的数据
            serializer = new TBinarySerializer();
            serializer.FromBytes(msg[msg.FrameCount - 1].Buffer);
            DynObject respFragment = DynSerialize.ReadDynObject(serializer);

            serializer.Flush();

            //发生异常
            if ((byte)respFragment["State"] == 105)
            {
                _isWorking = false;
                throw new FtpException(respFragment["ExcepMsg"] as string);
            }

            return(respFragment);
        }
Esempio n. 35
0
            /// <summary>
            /// 处理接收到的数据
            /// </summary>
            /// <param name="msgData">接收到的消息</param>
            private byte[] DealMessage(byte[] msgData)
            {
                //反序列化,取出数据
                TSerializer serializer = new TBinarySerializer();

                serializer.FromBytes(msgData);
                DynObject reqFragment = DynSerialize.ReadDynObject(serializer);

                serializer.Flush();

                try
                {
                    DynObject repFragment = OnFileDataReceived(reqFragment);

                    //序列化并把数据返回给客户端
                    serializer = new TBinarySerializer();
                    DynSerialize.WriteDynObject(serializer, repFragment);
                    byte[] repData = serializer.ToBytes();
                    serializer.Flush();

                    return(repData);
                }
                catch (Exception ex)
                {
                    //如果服务端需要记录日志,则由本事件把异常信息发出
                    if (OnException != null)
                    {
                        OnException(ex);
                    }

                    _isRunning = false;

                    DynObject repFragment = new DynObject("FileFragment");
                    repFragment["State"]    = (byte)105;
                    repFragment["ExcepMsg"] = "FtpServer端异常," + ex.Message;

                    //序列化并把异常数据返回给客户端
                    serializer = new TBinarySerializer();
                    DynSerialize.WriteDynObject(serializer, repFragment);
                    byte[] repData = serializer.ToBytes();
                    serializer.Flush();

                    return(repData);
                }
            }
Esempio n. 36
0
        public DynObject GetBody()
        {
            if (body == null)
            {
                using (StreamReader reader = new StreamReader(baseRequest.InputStream, IOUtil.Utf8Encoding))
                {
                    string bodyText = reader.ReadToEnd();
                    if (bodyText == null || bodyText.Length == 0)
                    {
                        bodyText = "{}";
                    }

                    body = DynObject.Parse(bodyText);
                }
            }

            return(body);
        }
Esempio n. 37
0
    public Frame Backtrack(Frame th)
    {
        // throw away cut or mark-only frames
        while (bt != rootf && (bt.ip < 0))
            bt = bt.prev;
        if (st.pos > global.highwater)
            global.IncHighwater(st.pos);
        if (bt == rootf) {
            if (return_one) {
                if (Cursor.Trace)
                    Console.WriteLine("Failing {0}@{1} after no matches",
                            name, from);
                return Kernel.Take(th, Kernel.NewROScalar(Kernel.EMPTYP));
            } else {
                if (Cursor.Trace)
                    Console.WriteLine("Failing {0}@{1} after some matches",
                            name, from);
                if (EmptyList == null) {
                    DynObject lst = new DynObject(Kernel.ListMO);
                    lst.slots[0 /*items*/] = new VarDeque();
                    lst.slots[1 /*rest*/ ] = new VarDeque();
                    EmptyList = Kernel.NewRWListVar(lst);
                }
                th.caller.resultSlot = EmptyList;
            }

            return th.caller;
        } else {
            th.ip = bt.ip;
            st = bt.st;
            bt = bt.prev;
            return th;
        }
    }
Esempio n. 38
0
 // currently just used for protoregex
 public Frame EndWith(Frame th, Cursor m)
 {
     if (st.pos > global.highwater)
         global.IncHighwater(st.pos);
     if (return_one) {
         return Kernel.Take(th, Kernel.NewROScalar(m));
     } else {
         th.MarkSharedChain();
         return_one = true;
         VarDeque ks = new VarDeque();
         ks.Push(Kernel.NewROScalar(m));
         th.lex = new Dictionary<string,object>();
         th.lex["!return"] = null;
         DynObject it  = new DynObject(Kernel.GatherIteratorMO);
         it.slots[0 /*frame*/] = Kernel.NewRWScalar(Kernel.AnyMO, th);
         it.slots[1 /*reify*/] = Kernel.NewRWScalar(Kernel.AnyMO, Kernel.AnyP);
         VarDeque iss = new VarDeque();
         iss.Push(Kernel.NewROScalar(it));
         DynObject lst = new DynObject(Kernel.ListMO);
         lst.slots[0 /*items*/] = ks;
         lst.slots[1 /*rest*/ ] = iss;
         th.caller.resultSlot = Kernel.NewRWListVar(lst);
     }
     return th.caller;
 }
Esempio n. 39
0
        public DynObject GetBody()
        {
            if (body == null)
            {
                using (StreamReader reader = new StreamReader(baseRequest.InputStream, IOUtil.Utf8Encoding))
                {
                    string bodyText = reader.ReadToEnd();
                    if (bodyText == null || bodyText.Length == 0)
                    {
                        bodyText = "{}";
                    }

                    body = DynObject.Parse(bodyText);
                }
            }

            return body;
        }
Esempio n. 40
0
 public WebServerRequest(Dictionary<string, string> pathParams, HttpListenerRequest baseRequest, HttpListenerResponse baseResponse, DynObject logEntry)
 {
     this.pathParams = pathParams;
     this.baseRequest = baseRequest;
     this.baseResponse = baseResponse;
 }
Esempio n. 41
0
    public Variable O(VarHash caps)
    {
        Cursor nw = At(pos);
        foreach (KeyValuePair<string,Variable> kv in caps)
            nw.captures = new CapInfo(nw.captures, new string[] { kv.Key }, kv.Value);
        VarDeque ks = new VarDeque();

        DynObject lst = new DynObject(Kernel.ListMO);
        lst.slots[0 /*items*/] = ks;
        lst.slots[1 /*rest*/ ] = new VarDeque();

        ks.Push(Kernel.NewROScalar(nw));
        return Kernel.NewRWListVar(lst);
    }
Esempio n. 42
0
    public Variable SimpleWS()
    {
        string backing = global.orig_s;
        char[] backing_ca = global.orig_a;
        int l = backing_ca.Length;
        int p = pos;

        VarDeque ks = new VarDeque();

        DynObject lst = new DynObject(Kernel.ListMO);
        lst.slots[0 /*items*/] = ks;
        lst.slots[1 /*rest*/ ] = new VarDeque();

        if (p != 0 && p != l && CC.Word.Accepts(backing[p]) &&
                CC.Word.Accepts(backing[p-1])) {
            if (Trace)
                Console.WriteLine("! no match <ws> at {0}", pos);
        } else {
            while (p != l && Char.IsWhiteSpace(backing, p)) { p++; }
            if (Trace)
                Console.WriteLine("* match <ws> at {0} to {1}", pos, p);
            ks.Push(Kernel.NewROScalar(At(p)));
        }

        return Kernel.NewRWListVar(lst);
    }
Esempio n. 43
0
 private Variable FixupList(VarDeque caps)
 {
     if (caps.Count() != 0 && caps[0] == null) {
         caps.Shift();
         DynObject l = new DynObject(Kernel.ListMO);
         l.slots[0 /*items*/] = caps;
         l.slots[1 /*rest*/ ] = new VarDeque();
         return Kernel.NewROScalar(l);
     } else {
         return caps.Count() != 0 ? caps[0] :
             Kernel.NewROScalar(Kernel.AnyP);
     }
 }