public void EmptyKeyValues() { MapContext<string, int> context = new MapContext<string, int>(); Assert.IsNotNull(context.KeyValues); Assert.AreEqual(0, context.KeyValues.Keys.Count); }
/** * @param po * @throws PipelineException */ private void Write(IWorkerContext context, ProcessObject po) { MapContext mp = (MapContext)GetLocalContext(context); if (po.ContainsWritable()) { Document doc = (Document) mp[DOCUMENT]; bool continuousWrite = (bool) mp[CONTINUOUS]; IWritable writable = null; while (null != (writable = po.Poll())) { if (writable is WritableElement) { foreach (IElement e in ((WritableElement) writable).Elements()) { try { if (!doc.Add(e) && LOG.IsLogging(Level.TRACE)) { LOG.Trace(String.Format( LocaleMessages.GetInstance().GetMessage(LocaleMessages.ELEMENT_NOT_ADDED), e.ToString())); } } catch (DocumentException e1) { if (!continuousWrite) { throw new PipelineException(e1); } else { LOG.Error( LocaleMessages.GetInstance().GetMessage(LocaleMessages.ELEMENT_NOT_ADDED_EXC), e1); } } } } } } }
public LOSMap(MapContext<RolePlayActor> map, bool throughEntities = false) { _losMap = null; _mapRP = map; _pivotCell = null; _throughEntities = throughEntities; }
#pragma warning restore 649 /// <inheritdoc /> public void SaveBlueprint(GridId gridId, string yamlPath) { var grid = _mapManager.GetGrid(gridId); var context = new MapContext(_mapManager, _tileDefinitionManager, _serverEntityManager, _pauseManager, _componentFactory, _componentManager); context.RegisterGrid(grid); var root = context.Serialize(); var document = new YamlDocument(root); var resPath = new ResourcePath(yamlPath).ToRootedPath(); _resMan.UserData.CreateDir(resPath.Directory); using (var file = _resMan.UserData.Open(resPath, FileMode.Create)) { using (var writer = new StreamWriter(file)) { var stream = new YamlStream(); stream.Add(document); stream.Save(new YamlMappingFix(new Emitter(writer)), false); } } }
public override IList <IElement> Start(IWorkerContext ctx, Tag tag) { List <IElement> l = new List <IElement>(1); try { IDictionary <String, String> css = tag.CSS; if (css.ContainsKey(CSS.Property.BACKGROUND_COLOR)) { Type type = typeof(PdfWriterPipeline); MapContext pipeline = (MapContext)ctx.Get(type.FullName); if (pipeline != null) { Document document = (Document)pipeline[PdfWriterPipeline.DOCUMENT]; if (document != null) { Rectangle rectangle = new Rectangle(document.Left, document.Bottom, document.Right, document.Top, document.PageSize.Rotation); rectangle.BackgroundColor = HtmlUtilities.DecodeColor(css[CSS.Property.BACKGROUND_COLOR]); PdfBody body = new PdfBody(rectangle); l.Add(body); } } } } catch (NoCustomContextException e) {} return(l); }
/// <inheritdoc /> public void SaveMap(MapId mapId, string yamlPath) { Logger.InfoS("map", $"Saving map {mapId} to {yamlPath}"); var context = new MapContext(_mapManager, _tileDefinitionManager, _serverEntityManager, _pauseManager, _componentManager, _prototypeManager); foreach (var grid in _mapManager.GetAllMapGrids(mapId)) { context.RegisterGrid(grid); } var document = new YamlDocument(context.Serialize()); var resPath = new ResourcePath(yamlPath).ToRootedPath(); _resMan.UserData.CreateDir(resPath.Directory); using (var file = _resMan.UserData.Create(resPath)) { using (var writer = new StreamWriter(file)) { var stream = new YamlStream(); stream.Add(document); stream.Save(new YamlMappingFix(new Emitter(writer)), false); } } Logger.InfoS("map", "Save completed!"); }
public LOSMap(MapContext<Fighter> map, bool throughEntities = false) { _losMap = null; _mapF = map; _pivotCell = null; _throughEntities = throughEntities; }
/// <inheritdoc /> public void SaveMap(IMap map, string yamlPath) { var context = new MapContext(); foreach (var grid in map.GetAllGrids()) { context.RegisterGrid(grid); } var document = new YamlDocument(context.Serialize()); var resPath = new ResourcePath(yamlPath).ToRootedPath(); _resMan.UserData.CreateDir(resPath.Directory); using (var file = _resMan.UserData.Open(resPath, FileMode.Create)) { using (var writer = new StreamWriter(file)) { var stream = new YamlStream(); stream.Add(document); stream.Save(writer, false); } } }
public override void ConfigureMapItem(MapItem item) { base.ConfigureMapItem(item); var mapItem = item as MapBubble ?? throw new Exception("Map item must be MapBubble."); if (Location == null || Location.Length != 2) { throw new Exception("Location must be double array with 2 elements."); } mapItem.Location = MapContext.CreateCoordPoint(Location[0], Location[1]); mapItem.Argument = Argument; if (Value.HasValue) { mapItem.Value = Value.Value; } if (Size.HasValue) { mapItem.Size = Size.Value; } if (Group.HasValue) { mapItem.Group = Group.Value; } if (MarkerType.HasValue) { mapItem.MarkerType = MarkerType.Value; } }
/// <inheritdoc /> public void SaveMap(MapId mapId, string yamlPath) { var context = new MapContext(_mapManager, _tileDefinitionManager, _serverEntityManager, _pauseManager); foreach (var grid in _mapManager.GetAllMapGrids(mapId)) { context.RegisterGrid(grid); } var document = new YamlDocument(context.Serialize()); var resPath = new ResourcePath(yamlPath).ToRootedPath(); _resMan.UserData.CreateDir(resPath.Directory); using (var file = _resMan.UserData.Open(resPath, FileMode.Create)) { using (var writer = new StreamWriter(file)) { var stream = new YamlStream(); stream.Add(document); stream.Save(new YamlMappingFix(new Emitter(writer)), false); } } }
/// <inheritdoc cref="IMapFactory{TDrawingContext}.FetchFeatures(MapContext{TDrawingContext})"/> public IEnumerable <GeoJsonFeature> FetchFeatures(MapContext <SkiaSharpDrawingContext> context) { foreach (var feature in context.MapFile.Features ?? new GeoJsonFeature[0]) { yield return(feature); } }
public void EmitSaveKeyValues() { MapContext<string, int> context = new MapContext<string, int>(); context.Emit("a", 1); context.Emit("word", 1); context.Emit("is", 1); context.Emit("a", 1); context.Emit("word", 1); Assert.IsNotNull(context.KeyValues); Assert.AreEqual(3, context.KeyValues.Keys.Count); Assert.IsTrue(context.KeyValues.ContainsKey("word")); Assert.IsNotNull(context.KeyValues["word"]); Assert.AreEqual(2, context.KeyValues["word"].Count); Assert.AreEqual(1, context.KeyValues["word"][0]); Assert.AreEqual(1, context.KeyValues["word"][1]); Assert.IsTrue(context.KeyValues.ContainsKey("a")); Assert.IsNotNull(context.KeyValues["a"]); Assert.AreEqual(2, context.KeyValues["a"].Count); Assert.AreEqual(1, context.KeyValues["a"][0]); Assert.AreEqual(1, context.KeyValues["a"][1]); Assert.IsTrue(context.KeyValues.ContainsKey("is")); Assert.IsNotNull(context.KeyValues["is"]); Assert.AreEqual(1, context.KeyValues["is"].Count); Assert.AreEqual(1, context.KeyValues["is"][0]); }
static void Main(string[] args) { MapContext ctx = new MapContext(); Console.WriteLine("Hello thinkers"); Console.ReadKey(); }
public void Map(ref object local, DiffPart diff, MapContext context) { if (context.Path.Count == 0) { switch (diff.DiffType) { case DiffPartType.Create: local = diff.Value; break; case DiffPartType.Remove: local = null; break; case DiffPartType.Resize: ResizeArray(ref local, (int)diff.Value); break; } } else { switch (diff.DiffType) { case DiffPartType.Include: var index = int.Parse(context.Path.Pop()); Type elementType = context.Type.GetElementType(); var array = (Array)local; object arrValue = array.GetValue(index); context.Resolvers.FindResolver(elementType).Map(ref arrValue, diff, new MapContext(context, elementType)); array.SetValue(arrValue, index); break; } } }
/// <inheritdoc cref="IMapFactory{TDrawingContext}.FetchMapElements(MapContext{TDrawingContext})"/> public IEnumerable <IMapElement> FetchMapElements(MapContext <SkiaSharpDrawingContext> context) { foreach (var shape in context.View.Shapes) { yield return(shape); } }
/// <inheritdoc /> public void SaveBlueprint(GridId gridId, string yamlPath) { var grid = _mapManager.GetGrid(gridId); var context = new MapContext(); context.RegisterGrid(grid); var root = context.Serialize(); var document = new YamlDocument(root); var resPath = new ResourcePath(yamlPath).ToRootedPath(); _resMan.UserData.CreateDir(resPath.Directory); using (var file = _resMan.UserData.Open(resPath, FileMode.Create)) { using (var writer = new StreamWriter(file)) { var stream = new YamlStream(); stream.Add(document); stream.Save(writer, false); } } }
static void Main(string[] args) { /* User u = new User() * { * LastName = "jebari", * FirstName = "mayssa", * Login="******", * Password="******", * Address = "benarouss", * DateOfBirth = new DateTime(0080, 10, 10), * TelephoneNumber = "12584", * ImageUrl = "url" * * * * * };*/ MapContext ctx = new MapContext(); //ctx.UserS.Add(u); ctx.SaveChanges(); Console.WriteLine("Base Created with succes "); Console.ReadKey(); }
public Context(WrappedMapper <Keyin, Valuein, Keyout, Valueout> _enclosing, MapContext <KEYIN, VALUEIN, KEYOUT, VALUEOUT> mapContext) : base(_enclosing) { this._enclosing = _enclosing; this.mapContext = mapContext; }
public void Map(ref object local, DiffPart diff, MapContext context) { if (context.Path.Count == 0) { local = diff.DiffType == DiffPartType.Exclude ? TypeHelpers.CreateDefaultState(context.Type) : diff.Value; } else { var member = TypeMemberInfo.GetPublicMember(local.GetType(), context.Path.Pop() as string); var fi = member as FieldInfo; if (fi != null) { object fieldLocal = fi.GetValue(local); Type type = (fieldLocal == null) ? fi.FieldType : fieldLocal.GetType(); if (diff.DiffType == DiffPartType.Exclude) { if (context.Path.Count == 0) { fi.SetValue(local, TypeHelpers.CreateDefaultState(type)); } else { context.Resolvers.FindResolver(type).Map(ref fieldLocal, diff, new MapContext(context, type)); // fi.SetValue(local, fieldLocal); } } else { context.Resolvers.FindResolver(type).Map(ref fieldLocal, diff, new MapContext(context, type)); fi.SetValue(local, fieldLocal); } } var pi = member as PropertyInfo; if (pi != null) { object propertyLocal = pi.GetValue(local); Type type = (propertyLocal == null) ? pi.PropertyType : propertyLocal.GetType(); if (diff.DiffType == DiffPartType.Exclude) { if (context.Path.Count == 0) { pi.SetValue(local, TypeHelpers.CreateDefaultState(pi.PropertyType)); } else { context.Resolvers.FindResolver(type).Map(ref propertyLocal, diff, new MapContext(context, type)); // pi.SetValue(local, propertyLocal); } } else { context.Resolvers.FindResolver(type).Map(ref propertyLocal, diff, new MapContext(context, type)); pi.SetValue(local, propertyLocal); } } } }
private void OnPhotosAdded(MapContext sender, IReadOnlyCollection <Photo> photos) { foreach (var photo in photos) { MapObjects.Add(new GeoObject(photo.Location, photo)); } MapObjects.TriggerCurrentViewRerendering(); }
void Awake() { curState = null; Menu = new MenuContext( this ); Character = new CharacterContext( this ); Map = new MapContext( this ); EnterName = new EnterNameContext( this ); MatchScore = new MatchScore( this ); Header = new HeaderContext( this ); }
/// <inheritdoc /> public IMapGrid?LoadBlueprint(MapId mapId, string path) { TextReader reader; var resPath = new ResourcePath(path).ToRootedPath(); // try user if (!_resMan.UserData.Exists(resPath)) { Logger.InfoS("map", $"No user blueprint path: {resPath}"); // fallback to content if (_resMan.TryContentFileRead(resPath, out var contentReader)) { reader = new StreamReader(contentReader); } else { Logger.ErrorS("map", $"No blueprint found: {resPath}"); return(null); } } else { var file = _resMan.UserData.Open(resPath, FileMode.Open); reader = new StreamReader(file); } IMapGrid grid; using (reader) { Logger.InfoS("map", $"Loading Grid: {resPath}"); var data = new MapData(reader); LoadedMapData?.Invoke(data.Stream, resPath.ToString()); if (data.GridCount != 1) { throw new InvalidDataException("Cannot instance map with multiple grids as blueprint."); } var context = new MapContext(_mapManager, _tileDefinitionManager, _serverEntityManager, _pauseManager, _componentManager, _prototypeManager, (YamlMappingNode)data.RootNode, mapId); context.Deserialize(); grid = context.Grids[0]; if (!context.MapIsPostInit && _pauseManager.IsMapInitialized(mapId)) { foreach (var entity in context.Entities) { entity.RunMapInit(); } } } return(grid); }
static void Main(string[] args) { MapContext ctx = new MapContext(); Console.WriteLine("DATABASECREATED"); Console.ReadKey(); // var req = from A in AspNetUsers // select A. }
public GameViewSystems(GameContext gameContext, MapContext mapContext, GraphicsDevice graphicsDevice, ContentManager contentManager) { this.gameContext = gameContext; this.mapContext = mapContext; InitView(graphicsDevice, contentManager); InitSystems(); }
private static void WriteHorizontalBorder(MapContext map, bool bottom) { Console.Write(bottom ? "└" : "┌"); for (int i = 0; i < map.Width; i++) { Console.Write("─"); } Console.Write(bottom ? "┘" : "┐"); Console.WriteLine(); }
public ObjectDroppedActionSteps( MainHooks mainHooks, MapContext mapContext, ActionDriver actionDriver, ScenarioContext scenarioContext) { _mapContext = mapContext; _actionDriver = actionDriver; _mainHooks = mainHooks; _scenarioContext = scenarioContext; }
public void Initialize(SkyContext skyContext, ICollection <BaseRenderer> renderers) { mapContext = new MapContext(this, skyContext); Projection = new ArcProjection(mapContext); Projection.IsInverted = settings.Get("IsInverted"); Projection.IsMirrored = settings.Get("IsMirrored"); this.renderers.AddRange(renderers); this.renderers.ForEach(r => r.Initialize()); Schema = settings.Get <ColorSchema>("Schema"); // get saved rendering orders RenderingOrder renderingOrder = settings.Get <RenderingOrder>("RenderingOrder"); // sort renderers according saved orders this.renderers.Sort(renderingOrder.Select(r => r.RendererTypeName)); // build rendering order based on existing renderers renderingOrder = new RenderingOrder(this.renderers.Select(r => new RenderingOrderItem(r))); // save actual rendering order settings.Set("RenderingOrder", renderingOrder); settings.SettingValueChanged += (name, value) => { // redraw if rendering order changed if (name == "RenderingOrder") { this.renderers.Sort(settings.Get <RenderingOrder>("RenderingOrder").Select(r => r.RendererTypeName)); Invalidate(); } if (name == "Schema") { Schema = settings.Get <ColorSchema>("Schema"); Invalidate(); } if (name == "IsMirrored") { Projection.IsMirrored = settings.Get("IsMirrored"); Invalidate(); } if (name == "IsInverted") { Projection.IsInverted = settings.Get("IsInverted"); Invalidate(); } }; }
/// <summary> /// Приведение объекта к новому состоянию путем применения цепочки изменений /// </summary> /// <param name="local">Текущее состояние объекта</param> /// <param name="differents">Цепочка изменений</param> /// <returns>Объект в новом состоянии</returns> public static object DiffMap(object local, DiffChain differents) { if (local == null) { throw new ArgumentNullException("local"); } foreach (var diff in differents) { var context = new MapContext(new ResolverMap(), diff, local.GetType()); context.Resolvers.FindResolver(local.GetType()).Map(ref local, diff, context); } return(local); }
public static void Initialize(MapContext context) { context.Database.EnsureCreated(); var gridCells = GetGridCells(); var clusters = GetAllClusters(); var servers = GetAllServers(gridCells); context.AddRange(gridCells); context.AddRange(clusters); context.AddRange(servers); context.SaveChanges(); }
public virtual InputSplit GetInputSplit() { if (@base is MapContext) { MapContext <KEYIN, VALUEIN, KEYOUT, VALUEOUT> mc = (MapContext <KEYIN, VALUEIN, KEYOUT , VALUEOUT>)@base; return(mc.GetInputSplit()); } else { return(null); } }
public override IPipeline Init(IWorkerContext context) { MapContext mc = new MapContext(); continiously = true; mc[CONTINUOUS] = continiously; if (null != doc) { mc[DOCUMENT] = doc; } if (null != writer) { mc[WRITER] = writer; } context.Put(GetContextKey(), mc); return base.Init(context); }
/// <summary> /// Copy a custom WrappedMapper.Context, optionally replacing /// the input and output. /// </summary> /// <?/> /// <?/> /// <?/> /// <?/> /// <param name="context">the context to clone</param> /// <param name="conf">a new configuration</param> /// <param name="reader">Reader to read from. Null means to clone from context.</param> /// <param name="writer">Writer to write to. Null means to clone from context.</param> /// <returns>a new context. it will not be the same class as the original.</returns> /// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> public static Mapper.Context CloneMapContext <K1, V1, K2, V2>(MapContext <K1, V1, K2 , V2> context, Configuration conf, RecordReader <K1, V1> reader, RecordWriter <K2, V2> writer) { try { // get the outer object pointer object outer = OuterMapField.GetValue(context); // if it is a wrapped 21 context, unwrap it if ("org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context".Equals(context.GetType ().FullName)) { context = (MapContext <K1, V1, K2, V2>)WrappedContextField.GetValue(context); } // if the reader or writer aren't given, use the same ones if (reader == null) { reader = (RecordReader <K1, V1>)ReaderField.GetValue(context); } if (writer == null) { writer = (RecordWriter <K2, V2>)WriterField.GetValue(context); } if (useV21) { object basis = MapContextImplConstructor.NewInstance(conf, context.GetTaskAttemptID (), reader, writer, context.GetOutputCommitter(), ReporterField.GetValue(context ), context.GetInputSplit()); return((Mapper.Context)MapContextConstructor.NewInstance(outer, basis)); } else { return((Mapper.Context)MapContextConstructor.NewInstance(outer, conf, context.GetTaskAttemptID (), reader, writer, context.GetOutputCommitter(), ReporterField.GetValue(context ), context.GetInputSplit())); } } catch (MemberAccessException e) { throw new ArgumentException("Can't access field", e); } catch (InstantiationException e) { throw new ArgumentException("Can't create object", e); } catch (TargetInvocationException e) { throw new ArgumentException("Can't invoke constructor", e); } }
public void GoesAroundObstacles() { var map = new MapContext(5, 3); map.StartingPoint = new Point(0, 1); map.TargetPoint = new Point(4, 1); map.Obstacles.Add(new Point(2, 2)); map.Obstacles.Add(new Point(2, 1)); var subject = new AStarPathFinder(); var path = subject.FindPath(map); Check.That(path.Steps).Not.Contains(new Point(2, 1)); }
public void NoPathReturnsNull() { var map = new MapContext(5, 3); map.StartingPoint = new Point(0, 0); map.TargetPoint = new Point(4, 1); map.AddObstacle(0, 1); map.AddObstacle(1, 0); map.AddObstacle(1, 1); var subject = new AStarPathFinder(); var path = subject.FindPath(map); Check.That(path).IsNull(); }
public override void ConfigureMapItem(MapItem item) { base.ConfigureMapItem(item); var mapItem = item as MapEllipse ?? throw new Exception("Map item must be MapEllipse."); if (Location == null || Location.Length != 2) { throw new Exception("Location must be double array with 2 elements."); } mapItem.Location = MapContext.CreateCoordPoint(Location[0], Location[1]); mapItem.Height = Height; mapItem.Width = Width; }
public virtual Reducer CreateCombiner(MapContext context) { return null; }
public void Map(MapContext context) { foreach (string word in encoding.GetString(context.InputValue).Split(splitChars, StringSplitOptions.RemoveEmptyEntries)) context.Emit(encoding.GetBytes(word), encoding.GetBytes("1")); }
public override Mapper CreateMapper(MapContext context) { return new WordCountMapper(); }
public virtual Partitioner CreatePartitioner(MapContext context) { return null; }
void IDisposable.Dispose() { if (_pivotCell != null) _pivotCell = null; if (_mapRP != null) _mapRP = null; if (_mapF != null) _mapF = null; if (_losMap != null) _losMap = null; }
public virtual RecordReader CreateRecordReader(MapContext context) { return null; }
public void Draw(MapContext context) { }
public void Draw(MapContext context) { h = EditorGUILayout.Slider(h, context.min_h, context.max_h); greater_than = EditorGUILayout.Toggle("Greater than", greater_than); }
private static void Map(int key, string value, MapContext<string, int> context) { context.Emit(value, 1); }
public abstract Mapper CreateMapper(MapContext context);