public override bool TryParse(string input, ref RangeInt cursor, out IWatchContext ctx) { var c = cursor; if (ParserUtils.TryExtractPropertyPathPart(input, ref c, out var partRange, out var identifierRange)) { var visitor = new TryParseVisitor() { Parent = this, Root = RootPathContext, Container = Container, PropertyIdentifier = input.Substring(identifierRange), PropertyPart = input.Substring(partRange), RootPath = PropPath == null ? new PropertyPath() : PropPath }; if (identifierRange.length == 0) { if (PropPath == null || PropPath.PartsCount == 0) { ctx = default; return(false); } visitor.PropertyIdentifier = PropPath[PropPath.PartsCount - 1].Name; } PropertyUtils.VisitAtPath(ref Container, PropPath, visitor); if (visitor.Result != null) { cursor = c; ctx = visitor.Result; return(true); } } ctx = default; return(false); }
public WorldDictionary(IWatchContext parent, string relativePath, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(WorldDictionary))) ) { }
public PropertyWatch(IWatchContext context, TContainer container, PropertyPath propPath) { Context = context; Container = container; PropPath = propPath; Unity.Assertions.Assert.IsTrue(PropPath.PartsCount != 0); }
public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx) { if (ParserUtils.TryParseIntAt(path, ref cursor, out var index)) { var comps = GO.GetComponents <Component>(); Component comp = comps[index]; //Type PropertyBagContextType = typeof(PropertyBagContext<>); //Type[] typeParams = new Type[] { comp.GetType() }; //Type PropertyBagContextTypeGen = PropertyBagContextType.MakeGenericType(typeParams); // //ctx = (IWatchContext)Activator.CreateInstance(PropertyBagContextTypeGen, this, $"[{index}]", comp, ContextFieldInfo.MakeOperator($"[{index}]")); Type PropertyPathContextType = typeof(PropertyPathContext <,>); Type[] typeParams = new Type[] { comp.GetType(), comp.GetType() }; Type PropertyBagContextTypeGen = PropertyPathContextType.MakeGenericType(typeParams); //public PropertyPathContext(IWatchContext parent, IWatchContext rootPathContext, string relativePath, ref TContainer container, PropertyPath propPath, ContextFieldInfo fieldInfo) ctx = (IWatchContext)Activator.CreateInstance(PropertyBagContextTypeGen, this, this, $"[{index}]", comp, null, ContextFieldInfo.MakeOperator($"[{index}]")); if (ctx != null) { return(ctx != null); } } ctx = default; return(false); }
public GameObjectComponentDictionary(IWatchContext parent, string relativePath, GameObject go, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectContext))) ) { GO = go; }
public GameObjectDictionary(IWatchContext parent, string relativePath, UnityEngine.SceneManagement.Scene scene, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectDictionary))) ) { Scene = scene; }
public EntityDictionary(IWatchContext parent, string relativePath, Entities.World world, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(EntityDictionary))) ) { World = world; }
public EntityContext(IWatchContext parent, string relativePath, Entity entity, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(WorldContext))) ) { this.entity = entity; //Variables.Add("Components", new EntityDictionary(this, ".Entity", World, ContextFieldInfo.Make("Entity"))); }
public GameObjectContext(IWatchContext parent, string relativePath, GameObject go, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectContext))) ) { GO = go; this.Variables.Add("Components", new GameObjectComponentDictionary(this, ".Components", go, ContextFieldInfo.Make("Components"))); }
public WorldContext(IWatchContext parent, string relativePath, Entities.World world, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(WorldContext))) ) { World = world; Variables.Add("Entity", new EntityDictionary(this, ".Entity", World, ContextFieldInfo.Make("Entity"))); }
public SceneContext(IWatchContext parent, string relativePath, UnityEngine.SceneManagement.Scene scene, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(SceneContext))) ) { Scene = scene; Variables.Add("GameObject", new GameObjectDictionary(this, ParserUtils.MakePathRelative("GameObject"), Scene, ContextFieldInfo.Make("GameObject"))); }
// propPath public PropertyPathContext(IWatchContext parent, IWatchContext rootPathContext, string relativePath, TContainer container, PropertyPath propPath, ContextFieldInfo fieldInfo) : base(parent , relativePath , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(TPropertyType))) ) { Container = container; PropPath = propPath; RootPathContext = rootPathContext; }
VisitStatus IPropertyVisitor.VisitCollectionProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker) { var propName = property.GetName(); if (propName != PropertyIdentifier) { return(VisitStatus.Handled); } if (Result != null) { return(VisitStatus.Handled); } Result = new PropertyPathContext <TContainer, TValue2>(Parent, Root, ParserUtils.MakePathRelative(PropertyPart), Container, RootPath.AppendedIndexer(PropertyPart), ContextFieldInfo.MakeOperator(PropertyPart)); return(VisitStatus.Handled); }
public override bool TryParse(string path, ref RangeInt cursor, out IWatchContext ctx) { var c = cursor; if (ParserUtils.TryParseScopeSequenceRange(path, ref c, ParserUtils.DelemiterSquareBracket, out var seqIn, out var seqOut)) { if (TryParseIndex(path, seqIn, out ctx)) { cursor = c; return(true); } } ctx = null; return(false); }
public override bool TryParse(string path, ref RangeInt cursor, out IWatchContext ctx) { var c = cursor; ParserUtils.TryParseAt(path, ref c, "."); foreach (var v in Variables) { if (ParserUtils.TryParseToken(path, ref c, v.Key)) { cursor = c; ctx = v.Value; return(true); } } ctx = null; return(false); }
public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx) { if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var worldNameRangeIn, out var worldNameRangeOut)) { string worldName = path.Substring(worldNameRangeIn); foreach (var w in Entities.World.All) { if (w.Name == worldName) { ctx = new WorldContext(this, $"[\"{worldName}\"]", w, ContextFieldInfo.MakeOperator($"[\"{worldName}\"]")); return(true); } } } ctx = default; return(false); }
public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx) { if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var nameRangeIn, out var nameRangeOut)) { string name = path.Substring(nameRangeIn); for (int i = 0; i != UnityEngine.SceneManagement.SceneManager.sceneCount; ++i) { var s = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (s.name == name) { ctx = new SceneContext(this, $"[\"{name}\"]", s, ContextFieldInfo.MakeOperator($"[\"{name}\"]")); return(true); } } } ctx = default; return(false); }
public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx) { if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var nameRangeIn, out var nameRangeOut)) { string name = path.Substring(nameRangeIn); foreach (var go in Scene.GetRootGameObjects()) { if (go.name == name) { GameObject go2 = go; ctx = new GameObjectContext(this, $"[\"{name}\"]", go, ContextFieldInfo.MakeOperator($"[\"{name}\"]")); //ctx = new PropertyPathContext<GameObject, GameObject>(this, this, $"[\"{name}\"]", ref go2, null, ContextFieldInfo.MakeOperator($"[\"{name}\"]")); //ctx = new PropertyBagContext<GameObject>(this, $"[\"{name}\"]", ref go2, ContextFieldInfo.MakeOperator($"[\"{name}\"]")); return(true); } } } ctx = default; return(false); }
public static bool TryParseDeepest(IWatchContext ctxFirst, string path, ref RangeInt cursor, out IWatchContext ctxResult) { var c = cursor; IWatchContext curCtx = ctxFirst; while (c.length > 0) { var nextCursor = c; if (ParserUtils.TryExtractPathPart(path, ref nextCursor, out var partRange)) { if (curCtx.TryParse(path, ref partRange, out var nextCtx)) { c = nextCursor; curCtx = nextCtx; continue; } } break; } cursor = c; ctxResult = curCtx; return(true); }
public override bool TryParse(string path, ref RangeInt cursor, out IWatchContext ctx) { var c = cursor; if (ParserUtils.TryParseScopeSequenceRange(path, ref c, ParserUtils.DelemiterSquareBracket, out var seqIn, out var seqOut)) { if (ParserUtils.TryParseIntAt(path, ref seqIn, out var index)) { var es = World.EntityManager.GetAllEntities(); for (int i = 0; i != es.Length; ++i) { if (es[i].Index == index) { cursor = c; var ctnr = new EntityContainer(World.EntityManager, es[i]); ctx = new PropertyPathContext <EntityContainer, EntityContainer>(this, this, $"[{es[i].Index}]", ctnr, null, ContextFieldInfo.MakeOperator($"[{es[i].Index}]")); return(true); } } } } ctx = null; return(false); }
public bool TryParseDeepest(string path, ref RangeInt cursor, out IWatchContext ctx) { return(TryParseDeepest(this, path, ref cursor, out ctx)); }
public DictionaryContext(IWatchContext parent, string relativePath, ContextMemberInfo info) : base(parent, relativePath, info) { }
public ContextPathWatch(IWatchContext context, string path) { Context = context; Path = path; }
public ScopeContext(IWatchContext parent, string relativePath, ContextMemberInfo info) : base(parent, relativePath, info) { }
public void AddVariable(string name, IWatchContext ctx) { Variables.Add(name, ctx); }
public PropertyWatch2(IWatchContext context, TContainer container, IProperty <TContainer, TValue> property) { Context = context; Container = container; Property = property; }
public static object Create(Type elementType, Product anchor, string collectionName, IWatchContext context) { var type = typeof(WatchedObservableCollection <>).MakeGenericType(elementType); return(Activator.CreateInstance(type, anchor, collectionName, context)); }
public abstract bool TryParse(string path, ref RangeInt cursor, out IWatchContext ctx);
public WatchContext(IWatchContext parent, string relativePath, ContextMemberInfo info) { Parent = parent; RelativePath = relativePath; memberInfo = info; }
public PropertyPathWatch(IWatchContext context, ref TContainer container, PropertyPath path) { Context = context; PropPath = path; Container = container; }