public TrackableList <T> ConvertToTrackableList(BsonArray bson) { var list = new TrackableList <T>(); ConvertToList(bson, list); return(list); }
public SimpleAbilities(IEnumerable<Static> simpleAbilities) { _all = new TrackableList<SimpleAbility>( simpleAbilities.Select(x => new SimpleAbility(x))); _active = new TrackableSet<Static>(simpleAbilities); }
private static void RunTrackableList() { Log.WriteLine("***** TrackableList (Json) *****"); var list = new TrackableList<string>(); list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); var json = JsonConvert.SerializeObject(list.Tracker, JsonSerializerSettings); Log.WriteLine(json); list.Tracker.Clear(); list.RemoveAt(0); list[1] = "TwoTwo"; list.Add("Four"); var json2 = JsonConvert.SerializeObject(list.Tracker, JsonSerializerSettings); Log.WriteLine(json2); list.Tracker.Clear(); Log.WriteLine(); }
public SimpleAbilities(IEnumerable <Static> simpleAbilities) { _all = new TrackableList <SimpleAbility>( simpleAbilities.Select(x => new SimpleAbility(x))); _active = new TrackableSet <Static>(simpleAbilities); }
private static void RunTrackableList() { Log.WriteLine("***** TrackableList (Json) *****"); var list = new TrackableList <string>(); list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); var json = JsonConvert.SerializeObject(list.Tracker, JsonSerializerSettings); Log.WriteLine(json); list.Tracker.Clear(); list.RemoveAt(0); list[1] = "TwoTwo"; list.Add("Four"); var json2 = JsonConvert.SerializeObject(list.Tracker, JsonSerializerSettings); Log.WriteLine(json2); list.Tracker.Clear(); Log.WriteLine(); }
private void Target_TypeHasBecomeCrisp(object sender, EventArgs args) { var alts = Target.GetMethods(Name); // f**k varargs for now alts = alts.Where(mi => mi.Args.Length == Args.Count()); alts.ForEach(alt => alt.Host = Host); alts.ForEach(alt => alt.ContradictionReported += (o, e) => { Alternatives.Remove(alt); Engine.Dispose(alt); }); Alternatives = new TrackableList<FuzzyMethod>(alts); Alternatives.ListChanged += (o, e) => FireAlternativesGotChanged(); foreach (var alt in alts) { // atm unnecessary since alt.Target == Target for all alts // this.BindToOneOfAlternatives(Target, alt.Target); this.BindToOneOfAlternatives(ReturnValue, alt.ReturnValue); // f**k varargs for now for (var i = 0; i < alt.Args.Length; i++) { var bindingArg = Args[i]; var altArg = alt.Args[i]; this.BindToOneOfAlternatives(bindingArg, altArg); } } }
private static void RunTrackableList() { Console.WriteLine("***** TrackableList (Protobuf) *****"); var list = new TrackableList<string>(); list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); var buf = PrintBytes(Serialize(list.Tracker)); Console.WriteLine(Deserialize<TrackableListTracker<string>>(buf)); list.Tracker.Clear(); list.RemoveAt(0); list[1] = "TwoTwo"; list.Add("Four"); var buf2 = PrintBytes(Serialize(list.Tracker)); Console.WriteLine(Deserialize<TrackableListTracker<string>>(buf2)); list.Tracker.Clear(); Console.WriteLine(); }
private TrackableList<string> CreateTestList() { var list = new TrackableList<string>(); list.Add("One"); list.Add("Two"); list.Add("Three"); return list; }
private void InitializeEntries(bool startTrackingImmediately) { this._entries = new TrackableList <ZipEntry>(); if (startTrackingImmediately) { this._entries.ListChanged += EntriesChanged; } }
private TrackableList <string> CreateTestList() { var list = new TrackableList <string>(); list.Add("One"); list.Add("Two"); list.Add("Three"); return(list); }
private TrackableList<string> CreateTestList(bool withTracker) { var list = new TrackableList<string>(); if (withTracker) list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); return list; }
private void AssertEqual(TrackableList <TagData> a, TrackableList <TagData> b) { Assert.Equal(a.Count, b.Count); for (var i = 0; i < a.Count; i++) { var a_v = a[i]; var b_v = b[i]; Assert.Equal(a_v.Text, b_v.Text); Assert.Equal(a_v.Priority, b_v.Priority); } }
private void AssertEqual(TrackableList<JobData> a, TrackableList<JobData> b) { Assert.Equal(a.Count, b.Count); for (int i = 0; i < a.Count; i++) { var a_v = a[i]; var b_v = b[i]; Assert.Equal(a_v.Kind, b_v.Kind); Assert.Equal(a_v.Count, b_v.Count); Assert.Equal(a_v.Note, b_v.Note); } }
private void AssertEqual(TrackableList <JobData> a, TrackableList <JobData> b) { Assert.Equal(a.Count, b.Count); for (int i = 0; i < a.Count; i++) { var a_v = a[i]; var b_v = b[i]; Assert.Equal(a_v.Kind, b_v.Kind); Assert.Equal(a_v.Count, b_v.Count); Assert.Equal(a_v.Note, b_v.Note); } }
public TrackableList <T> ConvertToTrackableList(BsonDocument doc, params object[] partialKeys) { var partialDoc = DocumentHelper.QueryValue(doc, partialKeys); if (partialDoc == null) { return(null); } var list = new TrackableList <T>(); ConvertToList(partialDoc.AsBsonArray, list); return(list); }
private TrackableList<JobData> CreateTestList() { var list = new TrackableList<JobData>(); var value1 = new JobData(); value1.Kind = 101; value1.Count = 1; value1.Note = "Handmade Sword"; list.Add(value1); var value2 = new JobData(); value2.Kind = 102; value2.Count = 3; value2.Note = "Lord of Ring"; list.Add(value2); return list; }
public void Serialize(ref MessagePackWriter writer, TrackableList <T> value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); } else { IMessagePackFormatter <T> formatter = options.Resolver.GetFormatterWithVerify <T>(); var c = value.Count; writer.WriteArrayHeader(c); for (int i = 0; i < c; i++) { writer.CancellationToken.ThrowIfCancellationRequested(); formatter.Serialize(ref writer, value[i], options); } } }
private TrackableList <JobData> CreateTestList() { var list = new TrackableList <JobData>(); var value1 = new JobData(); value1.Kind = 101; value1.Count = 1; value1.Note = "Handmade Sword"; list.Add(value1); var value2 = new JobData(); value2.Kind = 102; value2.Count = 3; value2.Note = "Lord of Ring"; list.Add(value2); return(list); }
private static void RunTrackableList() { Console.WriteLine("***** TrackableList *****"); var list = new TrackableList<string>(); list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); Console.WriteLine(list.Tracker); list.Tracker.Clear(); list.RemoveAt(0); list[1] = "TwoTwo"; list.Add("Four"); Console.WriteLine(list.Tracker); list.Tracker.Clear(); Console.WriteLine(); }
// Update is called once per frame void Update() { //Debug.Log ("List of trackables currently active: "+TrackableList.countTrackers()); if (TrackableList.countTrackers() == 0) { trackerText.text = "Tracking: Not tracker found"; restartExtTrack(); } else if (TrackableList.countTrackers() == 1) { if (loadOnceCamera == false) { loadOnceCamera = true; if (currentTrackers.Count > 0) { restartExtTrack(); } TrackerManager.Instance.GetTracker <ObjectTracker> ().Start(); foreach (TrackableBehaviour tb in TrackableList.getActiveTrackables()) { trackerText.text = "Tracking: " + tb.TrackableName; Debug.Log("Tracking: " + tb.TrackableName + " status: " + tb.CurrentStatus); if (startAugmentation(tb)) { office3D.transform.parent = tb.gameObject.transform; Debug.Log("Cool1"); tb.GetComponent <ObjectTargetBehaviour> ().ObjectTarget.StartExtendedTracking(); Debug.Log("Cool2"); } } } } else if (TrackableList.countTrackers() > 1) { restartExtTrack(); } }
private static void RunTrackableList() { Console.WriteLine("***** TrackableList *****"); var list = new TrackableList <string>(); list.SetDefaultTracker(); list.Add("One"); list.Add("Two"); list.Add("Three"); Console.WriteLine(list.Tracker); list.Tracker.Clear(); list.RemoveAt(0); list[1] = "TwoTwo"; list.Add("Four"); Console.WriteLine(list.Tracker); list.Tracker.Clear(); Console.WriteLine(); }
public CombatRules(IEnumerable <CombatRule> combatRules) { _combatRules = new TrackableList <CombatRule>(combatRules); }
public ContiniousEffects(IEnumerable<ContinuousEffect> continuousEffects) { _continiousEffects = new TrackableList<ContinuousEffect>(continuousEffects); }
public ContiniousEffects() { _continiousEffects = new TrackableList <ContinuousEffect>(); }
public async Task <TrackableList <T> > LoadAsync(IDatabase db, RedisKey key) { var list = new TrackableList <T>(); return(await LoadAsync(db, list, key).ConfigureAwait(false) ? list : null); }
public Protections(IEnumerable<CardColor> colors, IEnumerable<string> cardTypes) { _colors = new TrackableList<CardColor>(colors); _cardTypes = new TrackableList<string>(cardTypes); }
private TTrackableContainer CreateTestContainer(bool withTracker) { dynamic container = new TTrackableContainer(); dynamic person = new TTrackablePerson(); container.Person = person; var missions = new TrackableDictionary <int, MissionData>(); container.Missions = missions; var tags = new TrackableList <TagData>(); if (_useList) { container.Tags = tags; } var aliases = new TrackableSet <string>(); if (_useSet) { container.Aliases = aliases; } if (withTracker) { ((ITrackable)container).SetDefaultTracker(); } // Person { person.Name = "Testor"; person.Age = 10; } // Missions { var value1 = new MissionData(); value1.Kind = 101; value1.Count = 1; value1.Note = "Handmade Sword"; missions.Add(1, value1); var value2 = new MissionData(); value2.Kind = 102; value2.Count = 3; value2.Note = "Lord of Ring"; missions.Add(2, value2); } // Tags if (_useList) { tags.Add(new TagData { Text = "Hello", Priority = 1 }); tags.Add(new TagData { Text = "World", Priority = 2 }); } // Aliases if (_useSet) { aliases.Add("alpha"); aliases.Add("beta"); aliases.Add("gamma"); } return(container); }
public TriggeredAbilities(IEnumerable <TriggeredAbility> triggeredAbilities) { _abilities = new TrackableList <TriggeredAbility>(triggeredAbilities); }
public ActivatedAbilities(IEnumerable <ActivatedAbility> activatedAbilities) { _abilities = new TrackableList <ActivatedAbility>(activatedAbilities); }
protected override Task SaveAsync(TrackableList <JobData> list) { return(_mapper.SaveAsync(_db, list.Tracker, _testId)); }
public ActivatedAbilities(IEnumerable<ActivatedAbility> activatedAbilities) { _abilities = new TrackableList<ActivatedAbility>(activatedAbilities); }
protected abstract Task SaveAsync(TrackableList <JobData> list);
protected override Task SaveAsync(TrackableList <JobData> list) { return(_mapper.SaveAsync(_collection, list.Tracker, _testId, "V")); }
public ContiniousEffects(IEnumerable <ContinuousEffect> continuousEffects) { _continiousEffects = new TrackableList <ContinuousEffect>(continuousEffects); }
public CombatRules(IEnumerable<CombatRule> combatRules) { _combatRules = new TrackableList<CombatRule>(combatRules); }
public TriggeredAbilities(IEnumerable<TriggeredAbility> triggeredAbilities) { _abilities = new TrackableList<TriggeredAbility>(triggeredAbilities); }
protected abstract Task SaveAsync(TrackableList <string> list);
protected abstract Task SaveAsync(TrackableList<JobData> list);
protected abstract Task SaveAsync(TrackableList<string> list);
public StaticAbilities(IEnumerable<StaticAbility> abilities) { _abilities = new TrackableList<StaticAbility>(abilities); }
public static MethodInfo InferGenericTypeParams(this MethodInfo mi, TypeInferenceContext ctx) { var originalSignature = mi; TypeInferenceEngine preview = null; try { preview = new TypeInferenceEngine(ctx); ctx.Root.CallArgs().ForEach(child => preview.InferTypes(child)); var fail = Array.FindIndex(ctx.Root.CallArgs().ToArray(), c => preview.Inferences[c] is Variant); if (fail != -1) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.VariantArg, originalSignature, mi, preview, fail); } else { Func<IEnumerable<RelinqScriptType>> args = () => ctx.Root.ToXArgs(preview.Inferences); Func<IEnumerable<Type>> @params = () => mi.ToXArgs(args().Count()); var argc = args().Count(); if (argc != @params().Count()) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.ArgcMismatch, originalSignature, mi, preview); } else { var processed = new TrackableList<bool>(Enumerable.Repeat(false, argc)); var fresh = new List<bool>(Enumerable.Repeat(true, argc)); processed.ListChanged += (o, e) => fresh[e.Index] = true; while (fresh.Any(b => b) && !processed.All(b => b)) { Enumerable.Range(0, argc).ForEach(i => fresh[i] = false); foreach (var i in processed.ToArray() .Select((b, j) => new { b, j }).Where(_ => !_.b).Select(_ => _.j)) { var ai_r = args().ElementAt(i); var pi = @params().ElementAt(i); var argIndex = mi.IsExtension() ? i : i - 1; if (!pi.IsOpenGeneric()) { if (pi.IsFunctionType() && ai_r is Lambda) { var ai_s = ((Lambda)ai_r).Type.GetFunctionSignature(); var pi_s = pi.GetFunctionSignature(); // todo. support varargs here as well if (ai_s.GetParameters().Length == pi_s.GetParameters().Length) { var preview2 = new TypeInferenceEngine(ctx); // todo. the line below is only possible because we don't process lambda extension calls var callArg = ctx.Root.CallArgs().ElementAt(i - 1); preview2.Ctx.Inferences.Add(callArg, new Lambda( (LambdaExpression)callArg, (pi_s.GetParameters() .Select(pi2 => pi2.ParameterType.IsGenericParameter ? typeof(Variant) : pi2.ParameterType) .Concat(typeof(Variant).AsArray())) .ForgeFuncType())); try { preview2.InferTypes(callArg); } catch (RelinqException rex) { if (rex.IsUnexpected) { throw; } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaInconsistentBody, originalSignature, mi, preview, i, rex); } } catch (Exception ex) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.Unexpected, originalSignature, mi, preview, i, ex); } var lambdaBody = ((LambdaExpression)callArg).Body; var retval = preview2.Inferences[lambdaBody]; if (retval is ClrType) { var ai_ret = ((ClrType)retval).Type; var pi_ret = pi_s.ReturnType; if (!ai_ret.HasImplicitCastTo(pi_ret)) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaIncompatibleRetval, originalSignature, mi, preview, i); } } else { // lambdas that return lambdas or method groups // are not implemented, since they're not supported by C# spec. throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaInvalidRetval, originalSignature, mi, preview, i); } } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaArgcMismatch, originalSignature, mi, preview, i); } } processed[i] = true; } else { if (ai_r is ClrType) { var ai = ((ClrType)ai_r).Type; // todo. also check implicit casts here? var inf = ai.LookupInheritanceChain() .Select(aij => pi.InferFrom(aij)) .FirstOrDefault(inf2 => inf2 != null); if (inf != null) { mi = mi.InferStructuralUnits(inf.ToDictionary( kvp => "a" + argIndex + kvp.Key, kvp => kvp.Value)); if (mi != null) { processed[i] = true; } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.InferencesContradictGenericConstraints, originalSignature, mi, preview, i); } } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.FormalArgCannotBeInferredFromActualArg, originalSignature, mi, preview, i); } } else if (ai_r is Lambda) { if (pi.IsFunctionType()) { var ai_s = ((Lambda)ai_r).Type.GetFunctionSignature(); var pi_s = pi.GetFunctionSignature(); // todo. support varargs here as well if (ai_s.GetParameters().Length == pi_s.GetParameters().Length) { var preview2 = new TypeInferenceEngine(ctx); // todo. the line below is only possible because we don't process lambda extension calls var callArg = ctx.Root.CallArgs().ElementAt(i - 1); preview2.Ctx.Inferences.Add(callArg, new Lambda( (LambdaExpression)callArg, (pi_s.GetParameters() .Select(pi2 => pi2.ParameterType.IsGenericParameter ? typeof(Variant) : pi2.ParameterType) .Concat(typeof(Variant).AsArray())) .ForgeFuncType())); try { preview2.InferTypes(callArg); } catch (RelinqException rex) { if (rex.IsUnexpected) { throw; } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaInconsistentBody, originalSignature, mi, preview, i, rex); } } catch (Exception ex) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.Unexpected, originalSignature, mi, preview, i, ex); } var lambdaBody = ((LambdaExpression)callArg).Body; var retval = preview2.Inferences[lambdaBody]; if (retval is ClrType) { var ai_ret = ((ClrType)retval).Type; var pi_ret = pi_s.ReturnType; if (pi_ret.IsOpenGeneric()) { var inf = ai_ret.LookupInheritanceChain() .Select(ai_retj => pi_ret.InferFrom(ai_retj)) .FirstOrDefault(inf2 => inf2 != null); if (inf != null) { var map = pi.GetStructuralTree(); mi = mi.InferStructuralUnits(inf.ToDictionary( kvp => "a" + argIndex + map.Single(kvp2 => kvp2.Value == pi_ret.SelectStructuralUnit(kvp.Key)).Key, kvp => kvp.Value)); if (mi != null) { processed[i] = true; } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.InferencesContradictGenericConstraints, originalSignature, mi, preview, i); } } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.FormalArgCannotBeInferredFromActualArg, originalSignature, mi, preview, i); } } else { processed[i] = true; } } else if (retval is Variant) { continue; } // lambdas that return lambdas or method groups // are not implemented, since they're not supported by C# spec. else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaInvalidRetval, originalSignature, mi, preview, i); } } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.LambdaArgcMismatch, originalSignature, mi, preview, i); } } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.FormalArgCannotBeInferredFromActualArg, originalSignature, mi, preview, i); } } // unlike lambdas, method groups don't participate in type args inference // neither they can help to infer type args, // nor can they be inferred themselves. else { processed[i] = true; } } } } if (!mi.IsOpenGeneric()) { return mi; } else { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.IncompleteInferenceSet, originalSignature, mi, preview); } } } } catch (GenericArgumentsInferenceException) { throw; } catch (Exception ex) { throw new GenericArgumentsInferenceException( GenericArgumentsInferenceExceptionType.Unexpected, originalSignature, mi, preview ?? new TypeInferenceEngine(ctx), ex); } }
public ContiniousEffects() { _continiousEffects = new TrackableList<ContinuousEffect>(); }
public Protections(IEnumerable <CardColor> colors, IEnumerable <string> cardTypes) { _colors = new TrackableList <CardColor>(colors); _cardTypes = new TrackableList <string>(cardTypes); }
public StaticAbilities(IEnumerable <StaticAbility> abilities) { _abilities = new TrackableList <StaticAbility>(abilities); }