public override object Call(IObj that, object[] args) { if (!HasArgs(args) || args[0] == null || args[0] is Undefined) throw new ArgumentException(); return HttpUtility.UrlDecode(JsTypeConverter.ToString(args[0])); }
private List <IObj> GetReferentialObjs(IObj target) { List <IObj> result = new List <IObj>(); foreach (Reference reference in target.References) { bool makeRevert = false; if (whenMakeRefRevert != null) { makeRevert = whenMakeRefRevert.Count(e => e == reference.Name) > 0; } Obj refObj = null; if (makeRevert) { refObj = reference.To; if (refObj == target) { result.Add(reference.From); } continue; } refObj = reference.From; if (refObj == target) { result.Add(reference.To); } } return(result); }
public override object Call(IObj that, object[] args) { if(!HasArgs(args, 1)) throw new NotImplementedException(); var newArray = Context.ArrayConstructor.Construct(); var len = JsTypeConverter.ToNumber(that.Get("length")); var start = JsTypeConverter.ToNumber(args[0]); var ks = (start < 0.0) ? Math.Max(len + start, 0.0D) : Math.Min(start, len); var end = args.Length > 1 ? JsTypeConverter.ToNumber(args[1]) : len; var ke = (end < 0.0) ? Math.Max(len + end, 0.0D) : Math.Min(end, len); var n = 0.0D; object val; while(ks < ke) { if (that.TryGet(ks, out val)) newArray.SetOwnProperty(n, val); ++ks; ++n; } return newArray; }
public Expr Parse(ParserContext pcon, object frm) { // frm is: (reify this-name? [interfaces] (method-name [args] body)* ) ISeq form = (ISeq)frm; ObjMethod enclosingMethod = (ObjMethod)Compiler.MethodVar.deref(); string baseName = enclosingMethod != null ? (ObjExpr.TrimGenId(enclosingMethod.Objx.Name) + "$") : (Compiler.munge(Compiler.CurrentNamespace.Name.Name) + "$"); string simpleName = "reify__" + RT.nextID(); string className = baseName + simpleName; ISeq rform = RT.next(form); IPersistentVector interfaces = ((IPersistentVector)RT.first(rform)).cons(Symbol.intern("clojure.lang.IObj")); rform = RT.next(rform); ObjExpr ret = Build(interfaces, null, null, className, Symbol.intern(className), null, rform, frm); IObj iobj = frm as IObj; if (iobj != null && iobj.meta() != null) { return(new MetaExpr(ret, MapExpr.Parse(pcon.EvalOrExpr(), iobj.meta()))); } else { return(ret); } }
public override object Call(IObj that, object[] args) { if (that.Class != ObjClass.Number || !that.HasValue()) throw new ShouldThrowTypeError(); return (that as ValueObj).Value; }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); return Math.Sqrt(JsTypeConverter.ToNumber(args[0])); }
public override object Call(IObj that, object[] args) { var str = JsTypeConverter.ToString(that); var results = Context.ArrayConstructor.Construct(); if (!HasArgs(args)) { results.Put(0.0D, str); return results; } var arg0 = args[0]; var limit = args.Length > 1 ? JsTypeConverter.ToInt32(args[1]) : int.MaxValue; string split = ""; if ((arg0 is IObj) && (arg0 as IObj).Class == ObjClass.RegExp) { throw new NotImplementedException(); } else { split = JsTypeConverter.ToString(arg0); var parts = str.Split(new[] { split }, limit, StringSplitOptions.None); var k = 0.0D; foreach (var part in parts) results.Put(k++, part); } return results; }
public void withMeta_has_correct_meta() { InitMocks(); IObj obj2 = _obj.withMeta(_meta); Expect(obj2.meta(), SameAs(_meta)); }
public void Add(IObj obj) { if (NHibernateUnitOfWork.CurrentSession == null) throw new Exception("No unit of work present"); NHibernateUnitOfWork.CurrentSession.Save(obj); }
public Intersection(IObj obj, IFace face, float distance, Point3D point) { this.Obj = obj; this.Face = face; this.Distance = distance; this.Point = point; }
public override object Call(IObj that, object[] args) { if (HasArgs(args)) return that.HasOwnProperty(args[0]); return false; }
public override object Call(IObj that, object[] args) { if (that.Class != ObjClass.Boolean || !that.HasValue()) throw new ShouldThrowTypeError(); return JsTypeConverter.ToBoolean((that as ValueObj).Value) ? "true" : "false"; }
protected bool checkExistanceOfReferent(IObj obj, string referenceName, string referentName) { bool result = false; bool hasRef = obj.References.Count(e => e.Name == referenceName) > 0; if (hasRef) { List <Reference> neededObjRefs = obj.References.Where(e => e.Name == referenceName).ToList(); if (neededObjRefs.Count >= 0) { foreach (Reference reference in neededObjRefs) { Obj referent = reference.From; if (referent == obj) { referent = reference.To; } if (referent.Name == referentName) { result = true; break; } } } } return(result); }
public override object Call(IObj that, object[] args) { if (!(that is RegExpObj)) throw new ShouldThrowTypeError(); return (that.Get("exec") as IFunction).Call(that, args) != null; }
public override object Call(IObj that, object[] args) { if (args.Length > 0) return JsTypeConverter.ToString(args[0]); return ""; }
public override object Call(IObj that, object[] args) { //TODO: This is just a quick version that handles most cases, not 100% yet if (!HasArgs(args) || args[0] == null || args[0] is Undefined) return Undefined.Instance; var strNumber = JsTypeConverter.ToString(args[0]).Trim(); int sign = 1; int radix = 10; if(HasArgs(args, 2) && (args[1] != null) && !(args[1] is Undefined)) radix = JsTypeConverter.ToInt32(args[1]); if(strNumber.Length == 0 || radix < 2 || radix > 36) return double.NaN; if(strNumber[0] == '-') { strNumber = strNumber.Substring(1); sign = -1; } try { return (double)(sign * Convert.ToInt32(strNumber, radix)); } catch(FormatException) { return double.NaN; } }
public override object Call(IObj that, object[] args) { var arrayObj = Context.ArrayConstructor.Construct(); var k = 0.0D; args = ArrayUtils.Insert((object)that, args); foreach (var arg in args) { if (arg is ArrayObj) { var arr = arg as ArrayObj; var len = (double)arr.Length; for (var i = 0.0D; i < len; ++i) { if (arr.HasOwnProperty(i)) arrayObj.SetOwnProperty(k++, arr.Get(i)); } } else { arrayObj.SetOwnProperty(k++, JsTypeConverter.ToString(arg)); } } return arrayObj; }
public override object Call(IObj that, object[] args) { var len = JsTypeConverter.ToNumber(that.Get("length")); if (len == 0.0D) { that.SetOwnProperty("length", 0.0D); return Undefined.Instance; } object shifted = that.Get(0.0D); var d = 1.0D; for (; d < len; ++d) { object val; if (that.TryGet(d, out val)) { that.SetOwnProperty(d - 1.0D, val); that.Delete(d); } else { that.Delete(d - 1.0D); } } that.SetOwnProperty("length", d - 1.0D); return shifted; }
protected override object Read(PushbackTextReader r, char leftparen) { int line = -1; if (r is LineNumberingTextReader) { line = ((LineNumberingTextReader)r).LineNumber; } IList <Object> list = readDelimitedList(')', r, true); if (list.Count == 0) { return(PersistentList.EMPTY); } IObj s = (IObj)PersistentList.create((IList)list); // IObj s = (IObj) RT.seq(list); if (line != -1) { return(s.withMeta(RT.map(RT.LINE_KEY, line))); } else { return(s); } }
public override object Call(IObj that, object[] args) { if (HasArgs(args) && args[0] is IObj) return (args[0] as IObj).Prototype == that; return false; }
protected override void DoWhithElementOnPath(IObj obj) { if (checkExistanceOfReferent(obj, "is_instance", "Автомобиль")) { result.Add(obj.Name); } }
public void Meta_ctor_has_meta() { IPersistentMap meta = new DummyMeta(); IObj r = ((IObj)_createFn(2L, 5L)).withMeta(meta); Expect(r.meta(), EqualTo(meta)); }
public override object Call(IObj that, object[] args) { if (!(that is ArrayObj)) throw new ShouldThrowTypeError(); return ((that as IObj).Get("join") as IFunction).Call(that, new object[] { }); }
public override object Call(IObj that, object[] args) { Console.WriteLine("net.createServer() called."); Net.NetServer server = new Net.NetServer(( UserFunction )args[0], Context); Console.WriteLine(server); return(server); }
protected override void DoWhithElementOnPath(IObj obj) { if (checkExistanceOfReferent(obj, "is_a", "Качество автомобиля")) { result = obj.Name; } }
public Obj(IObj container = null) { this.mContainer = container; var t = this.GetType(); var props = t.GetProperties(); Debug.Log("count1 " + props.Length); for (int i = 0; i < props.Length; i++) { var item = props[i]; var att = item.GetCustomAttributes(injectType, false); if (att == null) { continue; } Debug.Log("name " + item.Name); Debug.Log("PropertyType " + item.PropertyType); Debug.Log("item " + item); } var attributes = this.GetType().GetCustomAttributes(typeof(InjectAttribute), true); Debug.Log("count2 " + attributes.Length); //Debug.Log(attributes[0].GetType().Name); }
public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { if (obj == null) { if (main.unassigned.Count == 0) { return; } obj = main.unassigned.Dequeue(); obj.SetParent(a.transform); Debug.Log(obj.GetGameObject().transform.localScale); } Debug.Log("hh"); captureButton.SetMode(Mode.DELETE); main.t = this; obj.update(); } else { if (main.t == this) { main.t = null; } captureButton.SetMode(Mode.ADD); } }
public void withMeta_has_correct_meta() { InitMocks(); IObj obj2 = _obj.withMeta(_meta); Expect(Object.ReferenceEquals(obj2.meta(), _meta)); }
private bool checkOfFindingSevPathsNeed(IObj obj) { if (findSeveralPaths) { return(obj != start); } return(true); }
public override object Call(IObj that, object[] args) { args = ArrayUtils.Insert((object)that, args); return String.Concat( args.Select(x => JsTypeConverter.ToString(x)) ); }
public override object Call(IObj that, object[] args) { if (that.Class != ObjClass.Number || !that.HasValue()) throw new ShouldThrowTypeError(); //TODO: this should handle args[0] (radix) correctly. return JsTypeConverter.ToString((that as ValueObj).Value); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); var num = JsTypeConverter.ToNumber(args[0]); return !double.IsInfinity(num) && !double.IsNaN(num); }
public void withMeta_returns_self_if_no_change() { if (_testNoChange) { IObj obj2 = _obj.withMeta(_obj.meta()); Expect(obj2, SameAs(_obj)); } }
public void withMeta_returns_self_if_no_change() { if (_testNoChange) { IObj obj2 = _obj.withMeta(_obj.meta()); Expect(Object.ReferenceEquals(obj2, _obj)); } }
public void EmptyPreservesMeta() { IPersistentMap meta = new DummyMeta(); IPersistentCollection p = (IPersistentCollection) new PersistentList("abc").withMeta(meta); IObj obj = (IObj)p.empty(); Expect(Object.ReferenceEquals(obj.meta(), meta)); }
public override object Call(IObj that, object[] args) { var max = double.PositiveInfinity; foreach (var arg in args) max = Math.Min(max, JsTypeConverter.ToNumber(args)); return max; }
public override object Call(IObj that, object[] args) { var n = (double) JsTypeConverter.ToInt32(that.Get("length")); foreach (var arg in args) that.Put(n++, arg); return n; }
public override object Call(IObj that, object[] args) { if (that.Class != ObjClass.Number || !that.HasValue()) throw new ShouldThrowTypeError(); var fractions = HasArgs(args) ? JsTypeConverter.ToInt32(args[0]) : 0; var dbl = JsTypeConverter.ToNumber((that as ValueObj).Value); return dbl.ToString("f" + fractions, CultureInfo.InvariantCulture); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); var target = JsTypeConverter.ToString(args[0]); var str = JsTypeConverter.ToString(that); return str.CompareTo(target); }
public void SeqWithMetaHasMeta() { IPersistentMap meta = new DummyMeta(); CPV v = new CPV(new object[] { 4, 5, 6 }); IObj s = (IObj)v.seq(); IObj obj = s.withMeta(meta); Expect(Object.ReferenceEquals(obj.meta(), meta)); }
void IObj <T> .Merge(IObj <T> other) { var casted = other as TImplementor; if (casted == null) { throw new ArgumentException("Incorrect type."); } Merge(casted); }
public void RSeqWithMetaHasMeta() { IPersistentMap meta = new DummyMeta(); CPV v = new CPV(new object[] { 4, 5, 6 }); IObj s = (IObj)v.rseq(); IObj obj = s.withMeta(meta); Expect(obj.meta(), SameAs(meta)); }
public bool MakeDepthSearch(IObj start, IObj goal, bool findSeveralPaths, DoWhithElementOnPath action, List <string> whenMakeRefRevert = null) { visited = new HashSet <IObj>(); this.start = start; this.goal = goal; this.findSeveralPaths = findSeveralPaths; this.action = action; this.whenMakeRefRevert = whenMakeRefRevert; return(MakeDepthSearch(start)); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); var target = JsTypeConverter.ToString(that); var search = JsTypeConverter.ToString(args[0]); var index = JsTypeConverter.ToInt32(args.Length > 1 ? args[1] : int.MaxValue); return (double)target.LastIndexOf(search, index == int.MaxValue ? target.Length - 1 : index); }
// 15.2.1.1 public override object Call(IObj that, object[] args) { // step 1 if (args.Length == 0 || args[0] == null || args[0] is Undefined) return Construct(args); // step 2 return JsTypeConverter.ToObject(args[0], Context); }
public void withMeta_returns_correct_type() { if (_expectedType == null) { return; } InitMocks(); IObj obj2 = _obj.withMeta(_meta); Expect(obj2.GetType()).To.Equal(_expectedType); }
public string Answer(string carName) { IObj start = Wm.Objects.First(e => e.Name == carName); IObj goal = Wm.Objects.First(e => e.Name == "Качество автомобиля"); searcher.MakeDepthSearch(start, goal, false, DoWhithElementOnPath); string res = result; result = ""; return(res); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); double result; if (DoubleExt.TryParseInvariant(JsTypeConverter.ToString(args[0]), out result)) return result; return double.NaN; }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); var str = JsTypeConverter.ToString(that); var pos = JsTypeConverter.ToInt32(args[0]); if (pos < str.Length) return (double)(int)str[pos]; return double.NaN; }
protected override void DoWhithElementOnPath(IObj obj) { bool checking = checkExistanceOfReferent(obj, "is_a", "двигатель") || checkExistanceOfReferent(obj, "is_instance", "двигатель"); if (checking) { if (obj.Name == engineType) { result = true; } } }
public void EmptyPreservesMeta() { MockRepository mocks = new MockRepository(); IPersistentMap meta = mocks.StrictMock <IPersistentMap>(); mocks.ReplayAll(); IPersistentCollection p = (IPersistentCollection) new PersistentList("abc").withMeta(meta); IObj obj = (IObj)p.empty(); Expect(obj.meta(), SameAs(meta)); mocks.VerifyAll(); }
public void withMeta_returns_correct_type() { if (_expectedType == null) { return; } InitMocks(); IObj obj2 = _obj.withMeta(_meta); Expect(obj2, TypeOf(_expectedType)); _mocks.VerifyAll(); }
public void RSeqWithMetaHasMeta() { MockRepository mocks = new MockRepository(); IPersistentMap meta = mocks.StrictMock <IPersistentMap>(); mocks.ReplayAll(); CPV v = new CPV(new object[] { 4, 5, 6 }); IObj s = (IObj)v.rseq(); IObj obj = s.withMeta(meta); Expect(obj.meta(), SameAs(meta)); mocks.VerifyAll(); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args)) throw new ArgumentException(); var target = JsTypeConverter.ToString(that); var regex = JsTypeConverter.ToRegExp(args[0], Context); var match = regex.Match.Match(target); if (match.Success) return (double) match.Index; return -1.0D; }
public async Task <T> Add(IObj obj) { try { var response = await client.CreateDocumentAsync(CollUri, obj); return(JsonConvert.DeserializeObject <T>(response.Resource.ToString())); } catch (Exception e) { logger.Error(e); } return(default(T)); }
public override object Call(IObj that, object[] args) { if (!(that is RegExpObj)) throw new ShouldThrowTypeError(); var regExpObj = that as RegExpObj; var multiline = JsTypeConverter.ToBoolean(regExpObj.Get("multiline")); var global = JsTypeConverter.ToBoolean(regExpObj.Get("global")); var ignoreCase = JsTypeConverter.ToBoolean(regExpObj.Get("ignoreCase")); return "/" + JsTypeConverter.ToString(that.Get("source")) + "/" + (multiline ? "m" : "") + (global ? "g" : "") + (ignoreCase ? "i" : ""); }
public override object Call(IObj that, object[] args) { var len = JsTypeConverter.ToInt32(that.Get("length")); if (len != 0) { var result = that.Get((double)len - 1); that.Delete(len); that.Put("length", (double)len - 1); return result; } that.Put("length", (double)len); return Undefined.Instance; }
public override object Call(IObj that, object[] args) { if (!(that is RegExpObj)) throw new ShouldThrowTypeError(); if (!HasArgs(args)) throw new ArgumentException(); var regexp = that as RegExpObj; var str = JsTypeConverter.ToString(args[0]); var length = str.Length; var lastIndex = JsTypeConverter.ToInt32(that.Get("lastIndex")); var global = JsTypeConverter.ToBoolean(that.Get("global")); if (global) lastIndex = 0; if (lastIndex < 0 || lastIndex > length) { lastIndex = 0; return null; } var match = regexp.Match.Match(str, lastIndex); if (!match.Success) { lastIndex = 0; return null; } int n = match.Groups.Count; int e = match.Index + match.Length; if (global) lastIndex = e; var resultArray = Context.ArrayConstructor.Construct(); resultArray.SetOwnProperty("index", match.Index); resultArray.SetOwnProperty("input", str); resultArray.SetOwnProperty("length", n); var d = 0.0D; foreach (Group group in match.Groups) resultArray.SetOwnProperty(d++, group.Value); return resultArray; }
public List <string> Answer(string country) { IObj start = Wm.Objects.First(e => e.Name == country); IObj goal = Wm.Objects.First(e => e.Name == "Автомобиль"); List <string> whenMakeRefRevert = new List <string> { "locative" }; searcher.MakeDepthSearch(start, goal, true, DoWhithElementOnPath, whenMakeRefRevert); string[] res = new string[result.Count]; result.CopyTo(res); result = new List <string>(); return(res.ToList()); }
public override object Call(IObj that, object[] args) { if (!HasArgs(args) || args[0] == null || args[0] is Undefined) throw new ArgumentException(); var encoded = HttpUtility.UrlEncode(JsTypeConverter.ToString(args[0])); //TODO: unroll loop foreach (char c in Global_obj_encodeURI.RESERVED_COMPONENT) { var str = c.ToString(); encoded = encoded.Replace(HttpUtility.UrlEncode(str), str); } return encoded; }