Пример #1
0
        public void BindTest(string vtn, string vtp, string ax, string bx, double?s, string eVtn, string eVtp)
        {
            var aBox = ax.Split(',')
                       .Select(k => string.IsNullOrEmpty(k) ? (decimal?)null : k.ParseDecimalWithSiPrefix()).ToArray();

            var bBox = bx.Split(',')
                       .Select(k => string.IsNullOrEmpty(k) ? (decimal?)null : k.ParseDecimalWithSiPrefix()).ToArray();
            var config = new TransistorPair {
                Vtn = new Transistor {
                    Threshold     = aBox[0],
                    Sigma         = aBox[1],
                    NumberOfSigma = aBox[2]
                },
                Vtp = new Transistor {
                    Threshold     = bBox[0],
                    Sigma         = bBox[1],
                    NumberOfSigma = bBox[2]
                }
            };
            var opt = new Opt {
                VtnStrings = vtn.Split(','),
                VtpStrings = vtp.Split(','),
                Sigma      = s
            };

            var actual = opt.Bind(config);
            var nBox   = eVtn.Split(',').Select(r => r.ParseDecimalWithSiPrefix()).ToArray();
            var pBox   = eVtp.Split(',').Select(r => r.ParseDecimalWithSiPrefix()).ToArray();
            var expect = new TransistorPair(nBox[0], nBox[1], nBox[2], pBox[0], pBox[1], pBox[2]);

            Assert.Equal(JsonConvert.SerializeObject(expect), JsonConvert.SerializeObject(actual));
        }
Пример #2
0
        /// <summary>
        /// Bind Transistor setting
        /// </summary>
        /// <param name="this"></param>
        /// <param name="config">config value</param>
        /// <returns></returns>
        public static TransistorPair Bind(this ITransistorOption @this, TransistorPair config)
        {
            var vtnOpt = @this.VtnStrings
                         .Select(s => string.IsNullOrEmpty(s) ? (decimal?)null : s.ParseDecimalWithSiPrefix()).ToArray();
            var vtpOpt = @this.VtpStrings
                         .Select(s => string.IsNullOrEmpty(s) ? (decimal?)null : s.ParseDecimalWithSiPrefix()).ToArray();

            return(new TransistorPair {
                Vtn = new Transistor(
                    Bind(VtnThreshold, vtnOpt[0], config?.Vtn?.Threshold),
                    Bind(Sigma, vtnOpt[1], (decimal?)@this.Sigma, config?.Vtn?.Sigma),
                    Bind(NumberOfSigma, vtnOpt[2], config?.Vtn?.NumberOfSigma)
                    ),

                Vtp = new Transistor(
                    Bind(VtpThreshold, vtpOpt[0], config?.Vtp?.Threshold),
                    Bind(Sigma, vtpOpt[1], (decimal?)@this.Sigma, config?.Vtp?.Sigma),
                    Bind(NumberOfSigma, vtpOpt[2], config?.Vtp?.NumberOfSigma)
                    ),
            });
        }