예제 #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);
        }
예제 #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;
        }
예제 #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);
        }
예제 #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());
     }
 }
예제 #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;
        }
예제 #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);
        }
예제 #7
0
 public void Print(System.IO.TextWriter wr, CancellationToken cancel = default(CancellationToken), EnvParams envParams = null)
 {
     Printing.Print(root, wr, cancel, envParams);
 }
예제 #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)));
            }
        }
예제 #9
0
 internal EnvParams(EnvParams source, Uri baseUri)
 {
     BaseUri  = baseUri;
     settings = source == null ? new Dictionary <EnvParamKind, object>() : source.settings;
 }
예제 #10
0
파일: Parser.cs 프로젝트: thisiscam/formula
 public Parser(EnvParams envParams = null)
     : base(new Scanner())
 {
     this.envParams = envParams;
 }