Example #1
0
        public async Task <object> GetItemAsync(LambdaExpression getItem, string handle = null)
        {
            if (getItem == null)
            {
                throw new ArgumentNullException(nameof(getItem));
            }

            var settingInfo     = MemberVisitor.GetMemberInfo(getItem);
            var settingMetadata = new SettingMetadata(settingInfo, GetMemberName);

            var(uri, metadata) = SettingRequestFactory.CreateSettingRequest(settingMetadata, handle);
            return(await _settings.GetItemAsync <object>(uri, metadata.Set(Use <IResourceNamespace> .Namespace, x => x.Type, settingMetadata.MemberType)));
        }
Example #2
0
        public async Task SetItemAsync(LambdaExpression setItem, object newValue, string handle = null)
        {
            if (setItem == null)
            {
                throw new ArgumentNullException(nameof(setItem));
            }

            var settingInfo     = MemberVisitor.GetMemberInfo(setItem);
            var settingMetadata = new SettingMetadata(settingInfo, GetMemberName);

            var(uri, metadata) = SettingRequestFactory.CreateSettingRequest(settingMetadata, handle);
            Validate(newValue, settingMetadata.Validations, uri);
            await _settings.SetItemAsync(uri, newValue, metadata.Set(Use <IResourceNamespace> .Namespace, x => x.Type, settingMetadata.MemberType));
        }