Пример #1
0
 private static NakoVarArray ArrayToNakoVarArray(object obj)
 {
     NakoVarArray a = new NakoVarArray();
     if(obj is IDictionary<string,object>){
         Dictionary<string,object> dic = (Dictionary<string,object>)obj;
         foreach (KeyValuePair<string, object> item in dic) {
             if((item.Value is IDictionary<string,object>) || (item.Value is object[]) || (item.Value is IList<object>)){
                 a.SetValueFromKey(item.Key,ArrayToNakoVarArray(item.Value));
             }else{
                 a.SetValueFromKey(item.Key,item.Value);
             }
         }
     }else if(obj is object[]){
         object[] li = (object[])obj;
         foreach(object item in li) {
             if((item is IDictionary<string,object>) || (item is object[]) || (item is IList<object>)){
                 a.SetValue(a.Count,ArrayToNakoVarArray(item));
             }else{
                 a.SetValue(a.Count,item);
             }
         }
     }else if(obj is IList<object>){
         List<object> li = (List<object>)obj;
         foreach(object item in li) {
             if((item is IDictionary<string,object>) || (item is object[]) || (item is IList<object>)){
                 a.SetValue(a.Count,ArrayToNakoVarArray(item));
             }else{
                 a.SetValue(a.Count,item);
             }
         }
     }
     return a;
 }
Пример #2
0
 public object _getHeaderHash(INakoFuncCallInfo info)
 {
     string url = info.StackPopAsString();
     WebRequest req = WebRequest.Create(url);
     req.Method = "HEAD";
     HttpWebResponse response = (HttpWebResponse) req.GetResponse();
     NakoVarArray returnArray = new NakoVarArray();
     foreach(var key in response.Headers.Keys){
         string[] values = response.Headers.GetValues((string)key);
         NakoVarArray arrays = new NakoVarArray();
         arrays.SetValuesFromStrings(values);
         returnArray.SetValueFromKey((string)key,arrays);
     }
     returnArray.SetValueFromKey((string)"HTTP.Response",response.StatusCode.GetHashCode().ToString());
     returnArray.SetValueFromKey((string)"Status",response.StatusCode.GetHashCode().ToString());
     return returnArray;
 }