public bool TrySetMember(IDynamicMetaObjectProvider dynamicProvider, string name, object value)
        {
            dynamicProvider.IsNullThrow(nameof(dynamicProvider));

            var callSite = _callSiteSetters.Get(name);

            var result = callSite.Target(callSite, dynamicProvider, value);

            return(!ReferenceEquals(result, NoThrowExpressionVisitor.ErrorResult));
        }
        public Dictionary <string, object> GetDynamicMemberNameAndValues(IDynamicMetaObjectProvider dynamicObject)
        {
            dynamicObject.IsNullThrow(nameof(dynamicObject));
            var dictionary = new Dictionary <string, object>();
            var names      = dynamicObject.GetMetaObject(Expression.Constant(dynamicObject)).GetDynamicMemberNames();

            foreach (var name in names)
            {
                if (TryGetMember(dynamicObject, name, out var value))
                {
                    dictionary.Add(name, value);
                }
            }
            return(dictionary);
        }
        public bool TryGetMember(IDynamicMetaObjectProvider dynamicProvider, string name, out object value)
        {
            dynamicProvider.IsNullThrow(nameof(dynamicProvider));
            var callSite = _callSiteGetters.Get(name);

            var result = callSite.Target(callSite, dynamicProvider);

            if (!ReferenceEquals(result, NoThrowExpressionVisitor.ErrorResult))
            {
                value = result;
                return(true);
            }
            else
            {
                value = null;
                return(false);
            }
        }
 public List <string> GetDynamicMemberNames(IDynamicMetaObjectProvider dynamicObject)
 {
     dynamicObject.IsNullThrow(nameof(dynamicObject));
     return(dynamicObject.GetMetaObject(Expression.Constant(dynamicObject)).GetDynamicMemberNames().AsList());
 }