当前位置: 首页>>代码示例>>C#>>正文


C# Env类代码示例

本文整理汇总了C#中Env的典型用法代码示例。如果您正苦于以下问题:C# Env类的具体用法?C# Env怎么用?C# Env使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Env类属于命名空间,在下文中一共展示了Env类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

        protected override Node Evaluate(Env env)
        {
            Guard.ExpectMinArguments(2, Arguments.Count, this, Index);
            Guard.ExpectMaxArguments(3, Arguments.Count, this, Index);
            Guard.ExpectAllNodes<Color>(Arguments.Take(2), this, Index);

            double weight = 50;
            if (Arguments.Count == 3)
            {
                Guard.ExpectNode<Number>(Arguments[2], this, Index);

                weight = ((Number) Arguments[2]).Value;
            }

            var colors = Arguments.Take(2).Cast<Color>().ToArray();

            // Note: this algorithm taken from http://github.com/nex3/haml/blob/0e249c844f66bd0872ed68d99de22b774794e967/lib/sass/script/functions.rb

            var p = weight/100.0;
            var w = p*2 - 1;
            var a = colors[0].Alpha - colors[1].Alpha;

            var w1 = (((w*a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0;
            var w2 = 1 - w1;

            var rgb = colors[0].RGB.Select((x, i) => x*w1 + colors[1].RGB[i]*w2).ToArray();

            var alpha = colors[0].Alpha*p + colors[1].Alpha*(1 - p);

            var color = new Color(rgb[0], rgb[1], rgb[2], alpha);
            return color;
        }
开发者ID:Tigraine,项目名称:dotless,代码行数:32,代码来源:MixFunction.cs

示例2: Evaluate

        public override Node Evaluate(Env env)
        {
            int blockIndex = env.MediaBlocks.Count;
            env.MediaBlocks.Add(this);
            env.MediaPath.Push(this);

            env.Frames.Push(Ruleset);
            NodeHelper.ExpandNodes<Import>(env, Ruleset.Rules);
            env.Frames.Pop();

            var features = Features.Evaluate(env);
            var ruleset = Ruleset.Evaluate(env) as Ruleset;

            var media = new Media(features, ruleset,Extensions).ReducedFrom<Media>(this);

            env.MediaPath.Pop();
            env.MediaBlocks[blockIndex] = media;

            if (env.MediaPath.Count == 0)
            {
                return media.EvalTop(env);
            }
            else
            {
                return media.EvalNested(env, features, ruleset);
            }
        }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:27,代码来源:Media.cs

示例3: Evaluate

        public override Node Evaluate(Env env)
        {
            if(Evaluated) return this;

            try
            {
                env = env ?? new Env();

                env.Frames.Push(this);
                NodeHelper.ExpandNodes<Import>(env, Rules);
                env.Frames.Pop();

                var clone = new Root(new NodeList(Rules), Error, OriginalRuleset);

                clone = DoVisiting(clone, env, VisitorPluginType.BeforeEvaluation);

                clone.ReducedFrom<Root>(this);
                clone.EvaluateRules(env);
                clone.Evaluated = true;

                clone = DoVisiting(clone, env, VisitorPluginType.AfterEvaluation);
                return clone;
            }
            catch (ParsingException e)
            {
                throw Error(e);
            }
        }
开发者ID:jamesfoster,项目名称:dotless,代码行数:28,代码来源:Root.cs

示例4: AppendCSS

 public override void AppendCSS(Env env)
 {
     env.Output
         .Append('(')
         .Append(Value)
         .Append(')');
 }
开发者ID:helephant,项目名称:dotless,代码行数:7,代码来源:Paren.cs

示例5: Evaluate

        public override Node Evaluate(Env env)
        {
            var a = First.Evaluate(env);
            var b = Second.Evaluate(env);

            if (a is Number && b is Color)
            {
                if (Operator == "*" || Operator == "+")
                {
                    var temp = b;
                    b = a;
                    a = temp;
                }
                else
                    throw new ParsingException("Can't substract or divide a color from a number", Index);
            }

            try
            {
                var operable = a as IOperable;
                if (operable != null)
                    return operable.Operate(this, b).ReducedFrom<Node>(this);

                throw new ParsingException(string.Format("Cannot apply operator {0} to the left hand side: {1}", Operator, a.ToCSS(env)), Index);
            }
            catch (DivideByZeroException e)
            {
                throw new ParsingException(e, Index);
            }
            catch (InvalidOperationException e)
            {
                throw new ParsingException(e, Index);
            }
        }
开发者ID:rmariuzzo,项目名称:dotless,代码行数:34,代码来源:Operation.cs

示例6: Evaluate

        protected override Node Evaluate(Env env)
        {
            if (Arguments.Count == 0)
                return new Quoted("", false);

            Func<Node, string> stringValue = n => n is Quoted ? ((Quoted)n).Value : n.ToCSS(env);

            var str = stringValue(Arguments[0]);

            var args = Arguments.Skip(1).ToArray();
            var i = 0;

            MatchEvaluator replacement = m =>
                                             {
                                                 var value = (m.Value == "%s") ?
                                                                stringValue(args[i++]) :
                                                                args[i++].ToCSS(env);

                                                 return char.IsUpper(m.Value[1]) ?
                                                     Uri.EscapeDataString(value) :
                                                     value;
                                             };

            str = Regex.Replace(str, "%[sda]", replacement, RegexOptions.IgnoreCase);

            var quote = Arguments[0] is Quoted ? (Arguments[0] as Quoted).Quote : null;

            return new Quoted(str, quote);
        }
开发者ID:Bounder,项目名称:dotless,代码行数:29,代码来源:StringFunctions.cs

示例7: Evaluate

        public override Node Evaluate(Env env)
        {
            if (Values.Count == 1 && string.IsNullOrEmpty(Important))
                return Values[0].Evaluate(env);

            return new Value(Values.Select(n => n.Evaluate(env)), Important);
        }
开发者ID:trevorsg,项目名称:dotless,代码行数:7,代码来源:Value.cs

示例8: Evaluate

        protected override Node Evaluate(Env env)
        {
            Guard.ExpectNumArguments(1, Arguments.Count, this, Location);
            var color = Guard.ExpectNode<Color>(Arguments[0], this, Location);

            return new TextNode(color.ToArgb());
        }
开发者ID:rytmis,项目名称:dotless,代码行数:7,代码来源:ArgbFunction.cs

示例9: BDB43

		public BDB43(string file, string table, bool create, DBFormat format, bool allowDuplicates, Env environment) {
			this.env = environment;
			
			db_create(out dbp, environment.envptr, 0);
			funcs = (dbstruct)Marshal.PtrToStructure((IntPtr)((int)dbp+268), typeof(dbstruct));
			
			uint dbflags = DB_DIRECT_DB;
			if (allowDuplicates)
				dbflags |= DB_DUP; // DB_DUPSORT; 
			
			funcs.set_flags(dbp, dbflags);
			
			int type = (int)format;
			uint flags = DB_DIRTY_READ; // | DB_AUTO_COMMIT;
			int chmod_mode = 0;
			
			if (create)
				flags |= DB_CREATE;
			
			// if file & database are null, db is held in-memory
			// on file is taken as UTF8 (is this call right?)
			int ret = funcs.open(dbp, env.Txn, file, table, type, flags, chmod_mode);
			CheckError(ret);
			
			binfmt = new Serializer();
		}
开发者ID:JoshData,项目名称:semweb-dotnet,代码行数:26,代码来源:BDB.cs

示例10: AppendCSS

        protected override void AppendCSS(Env env, Context context)
        {
            env.Output.Append(Name);

            if (Rules != null)
            {
                env.Output
                    .Append(env.Compress ? "{" : " {\n")

                    .Push()
                    .AppendMany(Rules, "\n")
                    .Trim()
                    .Indent(env.Compress ? 0 : 2)
                    .PopAndAppend()

                    .Append(env.Compress ? "}" : "\n}\n");

                return;
            }

            env.Output
                .Append(" ")
                .Append(Value)
                .Append(";\n");
        }
开发者ID:trevorsg,项目名称:dotless,代码行数:25,代码来源:Directive.cs

示例11: Find

        public List<Closure> Find(Env env, Selector selector, Ruleset self)
        {
            self = self ?? this;
            var rules = new List<Closure>();
            var key = selector.ToCSS(env);

            if (_lookups.ContainsKey(key))
                return _lookups[key];

            foreach (var rule in Rulesets().Where(rule => rule != self))
            {
                if (rule.Selectors && rule.Selectors.Any(selector.Match))
                {
                    if (selector.Elements.Count > 1)
                    {
                        var remainingSelectors = new Selector(new NodeList<Element>(selector.Elements.Skip(1)));
                        var closures = rule.Find(env, remainingSelectors, self);

                        foreach (var closure in closures)
                        {
                            closure.Context.Insert(0, rule);
                        }

                        rules.AddRange(closures);
                    }
                    else
                        rules.Add(new Closure { Ruleset = rule, Context = new List<Ruleset> { rule } });
                }
            }
            return _lookups[key] = rules;
        }
开发者ID:Tigraine,项目名称:dotless,代码行数:31,代码来源:Ruleset.cs

示例12: AppendCSS

        public override void AppendCSS(Env env)
        {
            if (!Rules.Any())
                return;

            ((Ruleset) Evaluate(env)).AppendCSS(env, new Context());
        }
开发者ID:chrisortman,项目名称:dotless,代码行数:7,代码来源:Ruleset.cs

示例13: UtilsManager

 private UtilsManager(Env env, string serverName, string catalog)
 {
     _serverName = serverName;
     _catalog = catalog;
     this._env = env;
     _valuesForCombo = new Dictionary<string, IEnumerable<string>>();
 }
开发者ID:alpagas,项目名称:outlook-addin,代码行数:7,代码来源:UtilsManager.cs

示例14: Evaluate

        protected override Node Evaluate(Env env)
        {
            Guard.ExpectNumArguments(1, Arguments.Count, this, Location);
            Guard.ExpectNode<TextNode>(Arguments[0], this, Location);

            var argument = ((TextNode) Arguments[0]);

            string rgb;
            if (!argument.Value.StartsWith("#")) {
                var color = Color.GetColorFromKeyword(argument.Value);
                if (color != null) {
                    return color;
                }

                rgb = argument.Value;
            } else {
                rgb = argument.Value.TrimStart('#');
            }

            try
            {
                return new Color(rgb);
            }
            catch (FormatException ex)
            {
                throw new ParsingException(string.Format("Invalid RGB color string '{0}'", rgb), ex, Location, null);
            }
        }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:28,代码来源:ColorFunction.cs

示例15: AppendCSS

 public override void AppendCSS(Env env)
 {
     env.Output
         .Append(First)
         .Append("/")
         .Append(Second);
 }
开发者ID:rmariuzzo,项目名称:dotless,代码行数:7,代码来源:Shorthand.cs


注:本文中的Env类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。