Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public string ToString(EnvParams envParams)
 {
     if (EnvParams.GetBoolParameter(envParams, EnvParamKind.Msgs_SuppressPaths))
     {
         var segs = Uri.Segments;
         return(segs[segs.Length - 1]);
     }
     else
     {
         return(ToString());
     }
 }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
 public void Print(System.IO.TextWriter wr, CancellationToken cancel = default(CancellationToken), EnvParams envParams = null)
 {
     Printing.Print(root, wr, cancel, envParams);
 }
Exemplo n.º 8
0
        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)));
            }
        }
Exemplo n.º 9
0
 internal EnvParams(EnvParams source, Uri baseUri)
 {
     BaseUri  = baseUri;
     settings = source == null ? new Dictionary <EnvParamKind, object>() : source.settings;
 }
Exemplo n.º 10
0
 public Parser(EnvParams envParams = null)
     : base(new Scanner())
 {
     this.envParams = envParams;
 }