本文整理汇总了C#中IEnvironment.CreateBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# IEnvironment.CreateBoolean方法的具体用法?C# IEnvironment.CreateBoolean怎么用?C# IEnvironment.CreateBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnvironment
的用法示例。
在下文中一共展示了IEnvironment.CreateBoolean方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Construct
public override sealed IObject Construct(IEnvironment environment, IArgs args)
{
var patternArg = args[0];
var flagsArg = args[1];
var pattern = "";
var flags = "";
bool global, ignoreCase, multiline;
var patternObject = patternArg as IObject;
if (patternObject != null && patternObject.Class == "RegExp")
{
if (flagsArg.TypeCode != LanguageTypeCode.Undefined)
{
throw environment.CreateTypeError("");
}
global = ((IBoolean)patternObject.Get("global")).BaseValue;
ignoreCase = ((IBoolean)patternObject.Get("ignoreCase")).BaseValue;
multiline = ((IBoolean)patternObject.Get("multiline")).BaseValue;
pattern = ((IString)patternObject.Get("source")).BaseValue;
if (global) flags += "g";
if (ignoreCase) flags += "i";
if (multiline) flags += "m";
}
else
{
if (patternArg.TypeCode != LanguageTypeCode.Undefined)
{
pattern = patternArg.ConvertToString().BaseValue;
}
if (flagsArg.TypeCode != LanguageTypeCode.Undefined)
{
flags = flagsArg.ConvertToString().BaseValue;
}
global = flags.Contains("g");
ignoreCase = flags.Contains("i");
multiline = flags.Contains("m");
}
var regExpObj = new NRegExp(environment);
regExpObj.Class = "RegExp";
regExpObj.Extensible = true;
regExpObj.Prototype = environment.RegExpPrototype;
regExpObj.Body = pattern;
regExpObj.Flags = flags;
regExpObj.RegExpMatcher = Machete.Compiler.RegExpParser.Parse(Environment, pattern, flags);
regExpObj.DefineOwnProperty("source", environment.CreateDataDescriptor(environment.CreateString(pattern), false, false, false), false);
regExpObj.DefineOwnProperty("global", environment.CreateDataDescriptor(environment.CreateBoolean(global), false, false, false), false);
regExpObj.DefineOwnProperty("ignoreCase", environment.CreateDataDescriptor(environment.CreateBoolean(ignoreCase), false, false, false), false);
regExpObj.DefineOwnProperty("multiline", environment.CreateDataDescriptor(environment.CreateBoolean(multiline), false, false, false), false);
regExpObj.DefineOwnProperty("lastIndex", environment.CreateDataDescriptor(environment.CreateNumber(0.0), true, false, false), false);
return regExpObj;
}
示例2: Next
public override IDynamic Next(IEnvironment environment, IArgs args)
{
if (Generator.Complete)
return environment.CreateBoolean(false);
environment.Context.LexicalEnviroment = Scope;
environment.Context.VariableEnviroment = Scope;
if (!Generator.Initialized)
{
environment.BindVariableDeclarations(VariableDeclarations, true, true);
Generator.Initialized = true;
}
var step = Generator.Steps.Dequeue();
var iterated = step(environment, Generator);
Generator.Complete = !iterated || Generator.Steps.Count == 0;
return environment.CreateBoolean(iterated);
}
示例3: IsArray
internal static IDynamic IsArray(IEnvironment environment, IArgs args)
{
// 15.4.3.2 Array.isArray ( arg )
var arg = args[0] as IObject;
return environment.CreateBoolean(arg != null && arg.Class == "Array");
}
示例4: HasOwnProperty
private static IDynamic HasOwnProperty(IEnvironment environment, IArgs args)
{
if (args.IsEmpty) return environment.False;
var obj = environment.Context.ThisBinding.ConvertToObject();
var desc = obj.GetOwnProperty(args[0].ConvertToString().BaseValue);
return environment.CreateBoolean(desc != null);
}
示例5: IsNan
internal static IDynamic IsNan(IEnvironment environment, IArgs args)
{
var n = args[0].ConvertToNumber().BaseValue;
return environment.CreateBoolean(double.IsNaN(n));
}
示例6: PropertyIsEnumerable
private static IDynamic PropertyIsEnumerable(IEnvironment environment, IArgs args)
{
if (args.IsEmpty) return environment.False;
var obj = environment.Context.ThisBinding.ConvertToObject();
var desc = obj.GetOwnProperty(args[0].ConvertToString().ToString());
return environment.CreateBoolean(desc != null && (desc.Enumerable ?? false));
}
示例7: IsPrototypeOf
private static IDynamic IsPrototypeOf(IEnvironment environment, IArgs args)
{
var value = args[0] as LObject;
var thisObj = environment.Context.ThisBinding.ConvertToObject();
return environment.CreateBoolean(value != null && value.Prototype != null && value.Prototype == thisObj);
}
示例8: IsSealed
internal static IDynamic IsSealed(IEnvironment environment, IArgs args)
{
if (args[0].TypeCode != LanguageTypeCode.Object)
{
throw environment.CreateTypeError("");
}
var obj = args[0].ConvertToObject();
foreach (var name in obj)
{
var desc = obj.GetOwnProperty(name);
if (desc.Configurable ?? false)
{
return environment.False;
}
}
return environment.CreateBoolean(!obj.Extensible);
}
示例9: IsFrozen
internal static IDynamic IsFrozen(IEnvironment environment, IArgs args)
{
if (args[0].TypeCode != LanguageTypeCode.Object)
{
throw environment.CreateTypeError("");
}
var obj = args[0].ConvertToObject();
foreach (var name in obj)
{
var desc = obj.GetOwnProperty(name);
if (desc.Configurable ?? false)
{
return environment.False;
}
if (desc.IsDataDescriptor)
{
if (desc.Writable ?? false)
{
return environment.False;
}
}
obj.DefineOwnProperty(name, desc, true);
}
return environment.CreateBoolean(!obj.Extensible);
}
示例10: IsExtensible
internal static IDynamic IsExtensible(IEnvironment environment, IArgs args)
{
if (args[0].TypeCode != LanguageTypeCode.Object)
{
throw environment.CreateTypeError("");
}
var obj = args[0].ConvertToObject();
return environment.CreateBoolean(obj.Extensible);
}