public static bool GetBoolParameter(EnvParams prms, EnvParamKind prm) { Contract.Requires(GetParameterType(prm).Equals(typeof(bool))); object val; if (prms != null && prms.settings.TryGetValue(prm, out val)) { return((bool)val); } return((bool)parameters[prm].Item3); }
private static void SetBoolParameter(EnvParams prms, EnvParamKind prm, object value) { if (!(value is bool)) { throw new BadEnvParamException( string.Format( "Bad environment parameter; {0} must have type bool", prm)); } prms.settings[prm] = value; }
public static ReferencePrintKind GetReferencePrintKindParameter(EnvParams prms, EnvParamKind prm) { Contract.Requires(GetParameterType(prm).Equals(typeof(ReferencePrintKind))); object val; if (prms != null && prms.settings.TryGetValue(prm, out val)) { return((ReferencePrintKind)val); } return((ReferencePrintKind)parameters[prm].Item3); }
public string ToString(EnvParams envParams) { if (EnvParams.GetBoolParameter(envParams, EnvParamKind.Msgs_SuppressPaths)) { var segs = Uri.Segments; return(segs[segs.Length - 1]); } else { return(ToString()); } }
private static void SetReferencePrintKindParameter(EnvParams prms, EnvParamKind prm, object value) { if (!(value is ReferencePrintKind)) { throw new BadEnvParamException( string.Format( "Bad environment parameter; {0} must have type {1}", prm, typeof(ReferencePrintKind).Name)); } prms.settings[prm] = value; }
/// <summary> /// Returns a new set of parameters with same parameters as prms, but with kind = value. /// If prms is null, then all parameters start with their default values. /// </summary> public static EnvParams SetParameter(EnvParams prms, EnvParamKind kind, object value) { var clone = new EnvParams(); if (prms != null) { foreach (var kv in prms.settings) { clone.settings[kv.Key] = kv.Value; } } EnvParams.parameters[kind].Item4(clone, kind, value); return(clone); }
public void Print(System.IO.TextWriter wr, CancellationToken cancel = default(CancellationToken), EnvParams envParams = null) { Printing.Print(root, wr, cancel, envParams); }
public void SaveAs(string filename, CancellationToken cancel = default(CancellationToken), EnvParams envParams = null) { Contract.Assert(filename != null); var file = new System.IO.FileInfo(filename); using (var sw = new System.IO.StreamWriter(file.FullName)) { Print(sw, cancel, new EnvParams(envParams, new Uri(file.FullName, UriKind.Absolute))); } }
internal EnvParams(EnvParams source, Uri baseUri) { BaseUri = baseUri; settings = source == null ? new Dictionary <EnvParamKind, object>() : source.settings; }
public Parser(EnvParams envParams = null) : base(new Scanner()) { this.envParams = envParams; }