Inheritance: IDynamicMetaObjectProvider
 public DynamicObjectMemberNode(ObjectNode parent, DynamicObject item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     base.Name = "DynamicObject";
     base.Summary = item.ToString();
     if (base.Summary.Length > 150)
     {
         base.Summary = base.Summary.Substring(0, 150) + "...";
     }
     IEnumerable<string> dynamicMemberNames = item.GetDynamicMemberNames();
     if (dynamicMemberNames.Any<string>() && (base.CyclicReference == null))
     {
         if (!(!base.IsAtNestingLimit() || (base.Parent is ListNode)))
         {
             base.GraphTruncated = true;
         }
         else
         {
             foreach (string str in dynamicMemberNames)
             {
                 object propValue = this.GetPropValue(item, str);
                 base.Members.Add(new MemberData(str, null, ObjectNode.Create(this, propValue, false, maxDepth, dcDriver)));
             }
         }
     }
 }
Exemplo n.º 2
0
 public void Dump(DynamicObject obj)
 {
     foreach (var memberName in obj.GetDynamicMemberNames())
     {
         _appender(GetDynamicMember(obj, memberName).ToString());
         Print("\n");
     }
 }
 public ExpandoObjectWrapper(object o)
 {
     if (o is DynamicObject)
     {
         _wrapped = (DynamicObject)o;
     }
     else
     {
         _wrapped = new ReflectionDynamicObject(o);
     }
 }
        public NodeHttpRequest(HttpClient client, HttpRequestMessage requestMessage, object options, DynamicObject callback = null)
        {
            _client = client;
            _requestMessage = requestMessage;
            _options = options as NodeHttpRequestOptions ?? new NodeHttpRequestOptions((dynamic)options);

            if (callback != null)
            {
                @on("response", callback);
            }

        }
        public NodeHttpRequestOptions(DynamicObject config)
        {
            host = config.GetMember<string>("host");
            scheme = config.GetMember("scheme", "http");
            hostname = config.GetMember<string>("hostname") ?? host;

            url = config.GetMember<object>("uri") ?? config.GetMember<object>("url");
            method = config.GetMember<string>("method");
            headers = config.GetMember<DynamicObject>("headers");

            port = config.GetMember("port", Convert.ToInt32, 80);
        }
        /// <summary>
        /// 获取动态类型的值
        /// </summary>
        /// <param name="dynamicObject">实例</param>
        /// <param name="key">键名</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        private bool TryGetValue(DynamicObject dynamicObject, string key, out object value)
        {
            var keys = dynamicObject.GetDynamicMemberNames();
            key = keys.FirstOrDefault(item => string.Equals(item, key, StringComparison.OrdinalIgnoreCase));

            if (key != null)
            {
                return dynamicObject.TryGetMember(new KeyBinder(key, false), out value);
            }

            value = null;
            return false;
        }
        public static DynamicViewModel Create(DynamicObject entity)
        {
            var result = new DynamicViewModel();

            foreach (var memberName in entity.GetDynamicMemberNames())
            {
                object value;
                if (entity.TryGetMember(new GetBinder(memberName, false), out value))
                {
                    result.Set(memberName, value);
                }
            }

            return result;
        }
 private object GetPropValue(DynamicObject item, string propName)
 {
     try
     {
         object obj2;
         item.TryGetMember(new MyGetMemberBinder(propName, false), out obj2);
         return obj2;
     }
     catch (Exception innerException)
     {
         if ((innerException is TargetInvocationException) && (innerException.InnerException != null))
         {
             innerException = innerException.InnerException;
         }
         return innerException;
     }
 }
Exemplo n.º 9
0
 public RuleBuilder(IpTablesSystem system, String nfbpf, Dictionary<int, IpTablesRuleSet> ruleSets, FunctionRegistry functions = null)
 {
     if (functions == null)
     {
         functions = new FunctionRegistry();
     }
     _system = system.System;
     _nfbpf = nfbpf;
     var chainsDict =
         ruleSets.Select((a) => new KeyValuePair<int, IpTablesChainSet>(a.Key, a.Value.Chains))
             .ToDictionary((a) => a.Key, (a) => a.Value);
     _dcr = new DynamicChainRegister(system, chainsDict);
     _formatDb = new DynamicDictionary<object>(_mappings);
     _ruleSets = ruleSets;
     _interpreter = new Interpreter();
     _interpreter.SetVariable("var", _mappings);
     functions.LoadFunctions(_interpreter);
 }
        internal static void MakeRequest(DynamicObject config, DynamicObject callback, Microsoft.ClearScript.V8.V8ScriptEngine engine)
        {
            var options = new NodeHttpRequestOptions(config);
            var uriObj = new Uri((config.GetMember<object>("uri") ?? config.GetMember<object>("url")).ToString());
            options.url = (config.GetMember<object>("uri") ?? config.GetMember<object>("url"));
            options.host = uriObj.Host;
            options.hostname = uriObj.Host;
            options.scheme = uriObj.Scheme;
            options.path = uriObj.PathAndQuery;
            options.port = uriObj.Port;
            options.method = config.GetMember("method", "GET");
            options.headers = config.GetMember<DynamicObject>("headers");
            bool isJson = config.GetMember("json", false);

            var req = new NodeHttpRequest(new HttpClient(), new HttpRequestMessage(), options);
            Action<NodeHttpResponse> wrapperCallback = resp =>
            {
                if (callback == null)
                {
                    return;
                }
                //    string body = null;
                object body = null;
                var apiResp = resp.GetHttpResponseMessage();
                if (apiResp.Content != null && apiResp.Content.Headers.ContentLength > 0)
                {
                    if (isJson)
                    {
                        string xxx = apiResp.Content.ReadAsStringAsync().Result;
                        var parser = (dynamic)engine.Evaluate("JSON.parse");
                        body = parser(xxx);
                    }
                    else
                    {
                        body = apiResp.Content.ReadAsStringAsync().Result;
                    }
                }

                callback.AsDynamic().call(null, null, resp, body);
            };
            req.@on("response", wrapperCallback);

            req.end();
        }
Exemplo n.º 11
0
 public PrototypalMethodHolder(DynamicObject prototype)
     : base(prototype)
 {
     StaticMethodWithNoReturnValueOrParametersWasCalled = false;
 }
Exemplo n.º 12
0
Arquivo: Grid.cs Projeto: xzc3ss/Zaza
 internal static bool TryGetDynamicMember(DynamicObject o, string name, out object result)
 {
     return o.TryGetMember(new Binder(name, true), out result);
 }
Exemplo n.º 13
0
Arquivo: Grid.cs Projeto: xzc3ss/Zaza
 internal static object GetDynamicMember(DynamicObject obj, string name)
 {
     object result = new object();
       if (TryGetDynamicMember(obj, name, out result))
       {
     return result;
       }
       throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "Column {0} was not found", name));
 }
Exemplo n.º 14
0
 internal MetaDynamic(Expression expression, DynamicObject value)
     : base(expression, BindingRestrictions.Empty, value) {
 }
Exemplo n.º 15
0
 internal MetaDynamic(Expression expression, DynamicObject value)
     : base(expression, BindingRestrictions.Empty, value)
 {
 }
 public ChainBuilder(DynamicObject originalObject, IDocumentSession session, string collection)
 {
     OriginalObject = originalObject;
     Session = session;
     CollectionName = collection;
 }
Exemplo n.º 17
0
 internal DynamicDictionaryMetaObject(Expression parameter, DynamicObject value)
     : base(parameter, BindingRestrictions.Empty, value)
 {
 }
Exemplo n.º 18
0
		public static object GetValue(string name, DynamicObject dyn, Type objType)
		{
			try
			{
				var callSite = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, name, objType, new[] {CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)}));

				return callSite.Target(callSite, dyn);
			}
			catch (RuntimeBinderException)
			{
				return null;
			}
		}
Exemplo n.º 19
0
        static List<PropertyItem> ParseDynamicObject(DynamicObject target)
        {
            var result = new List<PropertyItem>();

              foreach (var propertyName in target.GetDynamicMemberNames())
              {
            var value = DynamicHelper.GetValue(target, propertyName);
            var propertyType = value != null ? value.GetType() : typeof(object);
            var property = new PropertyItem(target, value, new DynamicPropertyInfo(propertyName, propertyType), false);
            result.Add(property);
              }

              return result;
        }
Exemplo n.º 20
0
 public PrototypalObject(DynamicObject prototype)
 {
     Prototype = prototype;
 }
Exemplo n.º 21
0
 public object GetUserInfo(DynamicObject param)
 {
     dynamic p = param;
     throw new System.NotImplementedException();
 }