/// <summary> /// Adds a <see cref="System.Uri"/> to a request. /// </summary> public Address(IScalar <System.Uri> uri) : base(() => new Joined( new Scheme(uri.Value().Scheme), new Conditional(() => uri.Value().UserInfo != string.Empty, new User(uri.Value().UserInfo) ), new Host(uri.Value().Host), new Conditional(() => uri.Value().Port != 0, new Port(uri.Value().Port) ), new Conditional(() => uri.Value().AbsolutePath != string.Empty, new Path(uri.Value().AbsolutePath) ), new Conditional(() => uri.Value().Query != string.Empty, new QueryParams(uri.Value().Query) ), new Conditional(() => uri.Value().Fragment != string.Empty, new Fragment(uri.Value().Fragment) ) ) ) { }
/// <summary> Patched XML.</summary> /// <param name="xml"> XML to patch </param> /// <param name="xambler"> Xambler to modify xml </param> public XMLPatched(IScalar <XNode> xml, Xambler xambler) : this( new ScalarOf <IXML>(() => new XMLCursor(xambler.Apply(xml.Value())) ) ) { }
public T Value() { lock (_lock) { return(_source.Value()); } }
/// <summary> /// Gets the value. /// </summary> /// <returns>New dictionary instance.</returns> public IReadOnlyDictionary <string, Type[]> Value() { var types = _source.Value() .Select(item => (new SimpleName(item.Key).Name, item.Value)) .ToArray(); var dictionary = new Dictionary <string, Type[]>(); for (int i = 0; i < types.Length; i++) { (var key, var value) = types[i]; if (dictionary.ContainsKey(key)) { Type[] type = dictionary[key]; var newitem = new Type[type.Length + 1]; for (int j = 0; j < type.Length; j++) { newitem[j] = type[j]; } newitem[type.Length] = value; dictionary[key] = newitem; } else { dictionary[key] = new Type[] { value }; } } return(dictionary); }
public BadCredentialViewModel(IScalar <Dictionary <string, string> > source, Reason reason) { var errors = source.Value(); switch (reason) { case Reason.InvalidLogin: Message = errors["invalid_login"]; break; case Reason.InvalidPassword: Message = errors["invalid_password"]; break; case Reason.EmptyLogin: Message = errors["empty_login"]; break; case Reason.EmptyPassword: Message = errors["empty_password"]; break; default: break; } }
/// <summary> Patched XML.</summary> /// <param name="xml"> XML to patch </param> /// <param name="xambler"> Patching Xambler </param> public XMLPatched(IScalar <string> xml, Xambler xambler) : this( new ScalarOf <XNode>(() => { return(XDocument.Parse(xml.Value())); } ), xambler ) { }
/// <summary> /// Gets the cached value. /// </summary> /// <returns>Cached value.</returns> public T Value() { if (!evaluated) { evaluated = true; value = _scalar.Value(); } return(value); }
private IList <string> EncodedProps(string prop) { var values = new List <string>(memoryProps.Value().Values(prop)); for (int i = 0; i < values.Count; i++) { values[i] = XmlConvert.EncodeLocalName(values[i]); } return(values); }
/// <summary> /// An item which exists in memory. /// This cell has its internal memory stored in the itemMap. So: If you make two cells /// using this ctor, they will have the same memory. /// </summary> /// <param name="path">path to the item (key to the map)</param> /// <param name="itemMap">map with content for many items</param> internal RamCell(IScalar <string> name, IScalar <IMnemonic> mem) { lock (mem) { this.id = Guid.NewGuid().ToString(); this.name = new Solid <string>( () => new StrictCellName(name.Value()).AsString() ); this.mem = mem; } }
public T Value() { try { return(_value.Value()); } catch (Exception e) { failed = true; _error = e; return(_fallback.Value()); } }
/// <summary> /// Returns an enumerator that iterates through the collection. /// </summary> /// <returns>An enumerator that can be used to iterate through the collection.</returns> public IEnumerator <Type> GetEnumerator() { Assembly assembly = _assembly.Value(); var types = assembly.DefinedTypes .Cast <Type>() .Concat(assembly.ExportedTypes) .Distinct(); if (_omitAbstract) { types = types.Where(type => !type.Name.StartsWith("I")); } return(types.GetEnumerator()); }
private bool Available() { var isAvailable = true; foreach (var listener in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners()) { if (listener.Port == port.Value()) { isAvailable = false; break; } } return(isAvailable); }
/// <summary> /// A cell which exists in memory. /// Note: This memory cell lives only as long as this object lives. /// If you create two cells with the same path using this ctor, /// they will not have the same content. /// </summary> public RamCell(IScalar <string> path, MemoryStream content) : this( path, new Solid <IMnemonic>(() => { var mem = new RamMnemonic(); mem.Contents() .UpdateBytes( path.Value(), new BytesOf( new InputOf(content) ).AsBytes() ); return(mem); }) ) { }
/// <summary> /// "Main" equivalent. /// </summary> /// <returns>New <see cref="Task"/> object.</returns> private async Task Proceed() { if (!Validate(Login, Reason.EmptyLogin) || !Validate(Password, Reason.EmptyPassword)) { return; } //artificial delay await AsynchronousDelay(); NavigateTo(new PleaseWaitViewModel(this)); var login = new ErrorSafeAsyncScalar <IResult <bool> >( () => _api.Value().LoginAsync(), () => Result.Fail <bool>("an exception was thrown") ); var loginResult = await login.Value(); if (loginResult.Succeeded) { var profileViewModel = new ProfileViewModel("The message", this); NavigateTo(profileViewModel); //no code is running below except an asynchronous operation, so use ConfigureAwait(false) await profileViewModel.FetchData().ConfigureAwait(false); } else { GoBack(); if (login.HasErrors()) { NavigateTo("dock", new BadCredentialViewModel(login)); } else { NavigateTo("dock", new BadCredentialViewModel(loginResult.Info.Message)); } Set(nameof(Login), ref _login, string.Empty); Set(nameof(Password), ref _password, string.Empty); } }
/// <summary> /// Gets the string value. /// </summary> /// <returns>New name, with inferred namespace.</returns> public string String() { string result = _source.String(); string targetNamespace = null; if (!new IsNamespaced(result).Value()) { IReadOnlyDictionary <string, Type[]> value = _typeCacheWithoutNamespace.Value(); if (value.ContainsKey(result)) { return(value[result][_handleDuplicatesIndex].FullName); } if (new IsBlank(targetNamespace).Value()) { throw new InvalidOperationException($"Unable to infer the namespace for {result}"); } } return(result); }
internal XMLCursor(IScalar <XNode> node, IScalar <IXmlNamespaceResolver> context) { this.stringTransform = nd => { StringBuilder sb = new StringBuilder(); XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = nd.NodeType != XmlNodeType.Document; xws.Indent = false; using (XmlWriter xw = XmlWriter.Create(sb, xws)) { nd.Document.WriteTo(xw); } return(sb.ToString()); }; this.xml = new ScalarOf <string>( () => { return(this.stringTransform.Invoke(node.Value())); }); this.cache = new ScalarOf <XNode>(node); this.context = new ScalarOf <IXmlNamespaceResolver>(context); }
public T Value() { T value = default(T); for (int i = 0; i < _attempts; i++) { try { value = _source.Value(); } catch (Exception e) { _errors.Add(e); if (i == _attempts - 1) { throw; } } } return(value); }
public byte Value() { return(byte.Parse(_source.Value(), CultureInfo.InvariantCulture)); }
public bool Value() => !_value.Value();
/// <summary> /// Gets the bytes. /// </summary> /// <returns>The bytes.</returns> public byte[] Bytes() { return(BitConverter.GetBytes(_source.Value())); }
public bool Value() => _left.Value() || _right.Value();
/// <summary> /// Adds a query parameter to a request. /// </summary> public QueryParam(IScalar <string> key, IScalar <string> value) : this( () => key.Value(), () => value.Value() ) { }
/// <summary> /// A property which has a name and a value. /// </summary> public BxProp(string name, IScalar <string> value) : this(name, () => value.Value()) { }
public long Value() { return(long.Parse(_source.Value(), System.Globalization.CultureInfo.InvariantCulture)); }
/// <summary> /// Adds the scheme part of a <see cref="System.Uri"/> to a request. /// </summary> public Scheme(IScalar <string> scheme) : this(() => scheme.Value()) { }
/// <summary> /// Adds a <see cref="System.Uri"/> to a request. /// </summary> public Address(IScalar <string> uri) : this(new ScalarOf <System.Uri>(new System.Uri(uri.Value()))) { }
public XNode AsNode() { return(xml.Value().AsNode()); }
public string String() { return(_source.Value().ToString()); }
public float Value() { return(float.Parse(_source.Value(), CultureInfo.InvariantCulture)); }
public int Value() { return(int.Parse(_source.Value(), CultureInfo.InvariantCulture)); }