Exemplo n.º 1
0
        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration, IDictionary <string, object> data)
        {
            // Get the copy command
            XPathNavigator copyNode = configuration.SelectSingleNode("copy");

            if (copyNode == null)
            {
                base.ParentBuildComponent.WriteMessage(MessageLevel.Error, "A copy element is required to " +
                                                       "define the indexes from which to obtain comments and reflection information");
            }

            // Get the comments info
            string sourceName = copyNode.GetAttribute("name", string.Empty);

            if (String.IsNullOrEmpty(sourceName))
            {
                base.ParentBuildComponent.WriteMessage(MessageLevel.Error, "Each copy command must specify " +
                                                       "an index to copy from");
            }

            // Get the reflection info
            string reflectionName = copyNode.GetAttribute("use", String.Empty);

            if (String.IsNullOrEmpty(reflectionName))
            {
                base.ParentBuildComponent.WriteMessage(MessageLevel.Error, "Each copy command must specify " +
                                                       "an index to get reflection information from");
            }

            this.commentsIndex   = (IndexedCache)data[sourceName];
            this.reflectionIndex = (IndexedCache)data[reflectionName];
        }
Exemplo n.º 2
0
 /// <summary>Create a repetition with the specified ancestor, ancestor index, and exposed index.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Index in the parent splitter.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public RepetitionParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _components = new WeakReferenceCache<ComponentParser>(CreateComponent);
 }
Exemplo n.º 3
0
 /// <summary>Create a detached repetition with the specified initial value and encoding configuration.</summary>
 /// <param name="config">Encoding configuration.</param>
 private RepetitionParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _components = new WeakReferenceCache<ComponentParser>(CreateComponent);
 }
Exemplo n.º 4
0
 /// <summary>Create a field with the specified ancestor and indices.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Zero-based index within the parent's raw data.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public FieldParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _repetitions = new WeakReferenceCache <RepetitionParser>(CreateRepetition);
 }
Exemplo n.º 5
0
 /// <summary>Create a detached field with the specified initial value and configuration.</summary>
 /// <param name="config">Encoding configuration.</param>
 public FieldParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _repetitions = new WeakReferenceCache <RepetitionParser>(CreateRepetition);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Combines all tiles to form a graphic plane.
        /// </summary>
        /// <returns>
        /// Newly created graphic plane.
        /// </returns>
        public GraphicPlane Combine(CombineArgs args)
        {
            if(this.Type == MapType.Map2D)
            {
                GraphicPlane plane = new GraphicPlane(this.Width*16, this.Height*16);
                plane.Palette = ImagePalette.GetFullPalette(this.Palette);
                foreach(Tile t in this.TileData)
                {
                    Point loc = new Point(t.X*16, t.Y*16);
                    if(args.ShowUnderlays)
                    {
                        RawImage ul = IconGraphics.GetTileUnderlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ul, loc));
                    }
                    if(!args.ShowHelpers&&IsHelperTile(tilesid, t.Overlay))continue;
                    if(args.ShowOverlays)
                    {
                        RawImage ol = IconGraphics.GetTileOverlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ol, loc));
                    }
                }
                return plane;
            }else if(this.Type == MapType.Map3D)
            {
                MinimapType mt = MinimapType.Classic;
                LabData ld = LabData.GetLabData(this.Labdata);

                GraphicPlane plane = new GraphicPlane(this.Width*8, this.Height*8);
                ImagePalette src = ImagePalette.GetFullPalette(this.Palette);
                ImagePalette dest = plane.Palette = new MinimapPalette(src);

                if(ld != null)
                {
                    if(args.ShowFloors)
                    {
                        //Floors
                        IndexedCache<RawImage> floorcache = new IndexedCache<RawImage>(i=>Minimize(LabGraphics.GetFloor(this.Labdata, i), src, dest));
                        foreach(Block b in this.BlockData)
                        {
                            if(b.Floor != 0)
                            {
                                Point loc = new Point(b.X*8, b.Y*8);
                                plane.Objects.Add(new GraphicObject(floorcache[b.Floor], loc));
                            }
                        }
                    }

                    if(args.ShowWalls)
                    {
                        //Walls
                        foreach(Block b in this.BlockData)
                        {
                            if(b.IsWall && !ld.GetMinimapForm(b).VisibleOnMinimap)
                            {
                                WallForm form = WallForm.Close;
                                if(b.Y > 0 &&        BlockData[b.X  , b.Y-1].IsWall)form |= WallForm.OpenTop;
                                if(b.X < Width-1 &&  BlockData[b.X+1, b.Y  ].IsWall)form |= WallForm.OpenRight;
                                if(b.Y < Height-1 && BlockData[b.X  , b.Y+1].IsWall)form |= WallForm.OpenBottom;
                                if(b.X > 0 &&        BlockData[b.X-1, b.Y  ].IsWall)form |= WallForm.OpenLeft;
                                Point loc = new Point(b.X*8, b.Y*8);
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetWall(form, mt), loc));
                            }
                        }
                    }
                }

                foreach(Block b in this.BlockData)
                {
                    Point loc = new Point(b.X*8, (b.Y-1)*8);
                    if(args.ShowNPCs)
                    {
                        //NPCs
                        foreach(NPC npc in UsedNPCs)
                        {
                            if(npc.Positions[0].X == b.X && npc.Positions[0].Y == b.Y)
                            {
                                byte type = 0;
                                if(npc.Interaction == 2)type = 8;
                                else type = 17;
                                if(type != 0)
                                    plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(type, mt), loc));
                            }
                        }
                    }

                    if(args.ShowObjects)
                    {
                        //Objects
                        if(ld != null)
                        {
                            if(!b.IsEmpty)
                            {
                                byte type = ld.GetMinimapForm(b).MinimapType;
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(type, mt), loc));
                            }
                        }
                    }

                    if(args.ShowGotoPoints)
                    {
                        //Goto-points
                        if(b.GotoPoint!=null)
                        {
                            plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(18, mt), loc));
                        }
                    }
                }
                return plane;
            }
            return null;
        }
Exemplo n.º 7
0
 /// <summary>Create a segment with the specified ancestor and indices.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Index within the ancestor string divider.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public SegmentParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _fields = new WeakReferenceCache<FieldParser>(CreateField);
 }
Exemplo n.º 8
0
 /// <summary>Create a message with a default MSH segment.</summary>
 public MessageParser()
 {
     _segments = new WeakReferenceCache<SegmentParser>(CreateSegment);
     Value = @"MSH|^~\&|";
 }
Exemplo n.º 9
0
 /// <summary>Create a repetition with the specified ancestor, ancestor index, and exposed index.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Index in the parent splitter.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public RepetitionParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _components = new WeakReferenceCache <ComponentParser>(CreateComponent);
 }
Exemplo n.º 10
0
 /// <summary>Create a segment with the specified ancestor and indices.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Index within the ancestor string divider.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public SegmentParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _fields = new WeakReferenceCache <FieldParser>(CreateField);
 }
Exemplo n.º 11
0
 /// <summary>Create a segment root with the specified encoding configuration.</summary>
 /// <param name="config"></param>
 private SegmentParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _fields = new WeakReferenceCache <FieldParser>(CreateField);
 }
Exemplo n.º 12
0
 /// <summary>Create a component.</summary>
 /// <param name="ancestor">Ancestor element to pull encoding information from.</param>
 /// <param name="parentIndex">Zero-based index within the parent divider.</param>
 /// <param name="externalIndex">HL7 index to identify as.</param>
 public ComponentParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _subcomponents = new WeakReferenceCache <SubcomponentParser>(CreateSubcomponent);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Combines all tiles to form a graphic plane.
        /// </summary>
        /// <returns>
        /// Newly created graphic plane.
        /// </returns>
        public GraphicPlane Combine(CombineArgs args)
        {
            if (this.Type == MapType.Map2D)
            {
                GraphicPlane plane = new GraphicPlane(this.Width * 16, this.Height * 16);
                plane.Palette = ImagePalette.GetFullPalette(this.Palette);
                foreach (Tile t in this.TileData)
                {
                    Point loc = new Point(t.X * 16, t.Y * 16);
                    if (args.ShowUnderlays)
                    {
                        RawImage ul = MapIcons.GetTileUnderlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ul, loc));
                    }
                    if (!args.ShowHelpers && IsHelperTile(tilesid, t.Overlay))
                    {
                        continue;
                    }
                    if (args.ShowOverlays)
                    {
                        RawImage ol = MapIcons.GetTileOverlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ol, loc));
                    }
                }
                if (args.ShowNPCs2D)
                {
                    foreach (NPC npc in UsedNPCs)
                    {
                        ImageBase img = NPCGraphics.GetNPCBig(npc.ObjectID)[6];
                        Point     loc = new Point(npc.X * 16, npc.Y * 16 - img.GetHeight() + 16);
                        plane.Objects.Add(new GraphicObject(img, loc));
                    }
                }
                return(plane);
            }
            else if (this.Type == MapType.Map3D)
            {
                MinimapType mt = MinimapType.Classic;
                LabData     ld = LabData.GetLabData(this.Labdata);

                GraphicPlane plane = new GraphicPlane(this.Width * 8, this.Height * 8);
                ImagePalette src   = ImagePalette.GetFullPalette(this.Palette);
                ImagePalette dest  = plane.Palette = new MinimapPalette(src);

                if (ld != null)
                {
                    if (args.ShowFloors)
                    {
                        //Floors
                        IndexedCache <RawImage> floorcache = new IndexedCache <RawImage>(i => Minimize(LabGraphics.GetFloor(this.Labdata, i), src, dest));
                        foreach (Block b in this.BlockData)
                        {
                            if (b.Floor != 0)
                            {
                                Point loc = new Point(b.X * 8, b.Y * 8);
                                plane.Objects.Add(new GraphicObject(floorcache[b.Floor], loc));
                            }
                        }
                    }

                    if (args.ShowWalls)
                    {
                        //Walls
                        foreach (Block b in this.BlockData)
                        {
                            if (b.IsWall && !ld.GetMinimapForm(b).VisibleOnMinimap)
                            {
                                WallForm form = WallForm.Close;
                                if (b.Y > 0 && BlockData[b.X, b.Y - 1].IsWall)
                                {
                                    form |= WallForm.OpenTop;
                                }
                                if (b.X < Width - 1 && BlockData[b.X + 1, b.Y].IsWall)
                                {
                                    form |= WallForm.OpenRight;
                                }
                                if (b.Y < Height - 1 && BlockData[b.X, b.Y + 1].IsWall)
                                {
                                    form |= WallForm.OpenBottom;
                                }
                                if (b.X > 0 && BlockData[b.X - 1, b.Y].IsWall)
                                {
                                    form |= WallForm.OpenLeft;
                                }
                                Point loc = new Point(b.X * 8, b.Y * 8);
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetWall(form, mt), loc));
                            }
                        }
                    }
                }

                foreach (Block b in this.BlockData)
                {
                    Point loc = new Point(b.X * 8, (b.Y - 1) * 8);
                    if (args.ShowNPCs3D)
                    {
                        //NPCs
                        foreach (NPC npc in UsedNPCs)
                        {
                            if (npc.Positions[0].X == b.X && npc.Positions[0].Y == b.Y)
                            {
                                byte type = 0;
                                if (npc.Interaction == 2)
                                {
                                    type = 8;
                                }
                                else
                                {
                                    type = 17;
                                }
                                if (type != 0)
                                {
                                    plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(type, mt), loc));
                                }
                            }
                        }
                    }

                    if (args.ShowObjects)
                    {
                        //Objects
                        if (ld != null)
                        {
                            if (!b.IsEmpty)
                            {
                                byte type = ld.GetMinimapForm(b).MinimapType;
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(type, mt), loc));
                            }
                        }
                    }

                    if (args.ShowGotoPoints)
                    {
                        //Goto-points
                        if (b.GotoPoint != null)
                        {
                            plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(18, mt), loc));
                        }
                    }
                }
                return(plane);
            }
            return(null);
        }
Exemplo n.º 14
0
 /// <summary>Create a segment root with the specified encoding configuration.</summary>
 /// <param name="config"></param>
 private SegmentParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _fields = new WeakReferenceCache<FieldParser>(CreateField);
 }
Exemplo n.º 15
0
 /// <summary>Create a field with the specified ancestor and indices.</summary>
 /// <param name="ancestor">Ancestor element.</param>
 /// <param name="parentIndex">Zero-based index within the parent's raw data.</param>
 /// <param name="externalIndex">Exposed index.</param>
 public FieldParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _repetitions = new WeakReferenceCache<RepetitionParser>(CreateRepetition);
 }
Exemplo n.º 16
0
 /// <summary>Create a detached repetition with the specified initial value and encoding configuration.</summary>
 /// <param name="config">Encoding configuration.</param>
 private RepetitionParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _components = new WeakReferenceCache <ComponentParser>(CreateComponent);
 }
Exemplo n.º 17
0
 /// <summary>Create a detached field with the specified initial value and configuration.</summary>
 /// <param name="config">Encoding configuration.</param>
 public FieldParser(ReadOnlyEncodingConfiguration config)
     : base(config)
 {
     _repetitions = new WeakReferenceCache<RepetitionParser>(CreateRepetition);
 }
Exemplo n.º 18
0
 /// <summary>Create a message with a default MSH segment.</summary>
 public MessageParser()
 {
     _segments = new WeakReferenceCache <SegmentParser>(CreateSegment);
     Value     = @"MSH|^~\&|";
 }
Exemplo n.º 19
0
        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            MessageLevel level;
            bool         isAttribute, ignoreCase;

            // Set up the context
            XPathNodeIterator contextNodes = configuration.Select("context");

            foreach (XPathNavigator contextNode in contextNodes)
            {
                contextNamespaces[contextNode.GetAttribute("prefix", String.Empty)] =
                    contextNode.GetAttribute("name", String.Empty);
            }

            // This is only used by the indices and won't change
            this.Context = new CustomContext(contextNamespaces);

            // Set up the indices
            XPathNodeIterator indexNodes = configuration.Select("index");

            foreach (XPathNavigator indexNode in indexNodes)
            {
                // Create the index
                IndexedCache index = this.CreateIndex(indexNode);
#if DEBUG
                this.WriteMessage(MessageLevel.Diagnostic, "Loading {0} index", index.Name);

                DateTime startLoad = DateTime.Now;
#endif
                // Search the data directories for entries
                XPathNodeIterator dataNodes = indexNode.Select("data");

                foreach (XPathNavigator dataNode in dataNodes)
                {
                    index.AddDocuments(dataNode);
                }

                // Getting the count from a database cache can be expensive so only report it if it will be seen
                if (this.BuildAssembler.VerbosityLevel == MessageLevel.Info)
                {
                    this.WriteMessage(MessageLevel.Info, "Indexed {0} elements", index.Count);
                }
#if DEBUG
                TimeSpan loadTime = (DateTime.Now - startLoad);
                this.WriteMessage(MessageLevel.Diagnostic, "Load time: {0} seconds", loadTime.TotalSeconds);
#endif
                BuildComponentCore.Data.Add(index.Name, index);
            }

            // Get the copy commands
            XPathNodeIterator copyNodes = configuration.Select("copy");

            foreach (XPathNavigator copyNode in copyNodes)
            {
                string sourceName = copyNode.GetAttribute("name", String.Empty);

                if (String.IsNullOrWhiteSpace(sourceName))
                {
                    this.WriteMessage(MessageLevel.Error, "Each copy command must specify an index to copy from");
                }

                string keyXPath = copyNode.GetAttribute("key", String.Empty);

                if (String.IsNullOrWhiteSpace(keyXPath))
                {
                    keyXPath = "string($key)";
                }

                string sourceXPath = copyNode.GetAttribute("source", String.Empty);

                if (String.IsNullOrWhiteSpace(sourceXPath))
                {
                    this.WriteMessage(MessageLevel.Error, "When instantiating a CopyFromIndex component, you " +
                                      "must specify a source XPath format using the source attribute");
                }

                string targetXPath = copyNode.GetAttribute("target", String.Empty);

                if (String.IsNullOrWhiteSpace(targetXPath))
                {
                    this.WriteMessage(MessageLevel.Error, "When instantiating a CopyFromIndex component, you " +
                                      "must specify a target XPath format using the target attribute");
                }

                isAttribute = ignoreCase = false;

                string boolValue = copyNode.GetAttribute("attribute", String.Empty);

                if (!String.IsNullOrWhiteSpace(boolValue) && !Boolean.TryParse(boolValue, out isAttribute))
                {
                    this.WriteMessage(MessageLevel.Error, "The 'attribute' attribute value is not a valid Boolean");
                }

                boolValue = copyNode.GetAttribute("ignoreCase", String.Empty);

                if (!String.IsNullOrWhiteSpace(boolValue) && !Boolean.TryParse(boolValue, out ignoreCase))
                {
                    this.WriteMessage(MessageLevel.Error, "The ignoreCase attribute value is not a valid Boolean");
                }

                IndexedCache index = (IndexedCache)BuildComponentCore.Data[sourceName];

                CopyFromIndexCommand copyCommand = new CopyFromIndexCommand(this, index, keyXPath, sourceXPath,
                                                                            targetXPath, isAttribute, ignoreCase);

                string messageLevel = copyNode.GetAttribute("missing-entry", String.Empty);

                if (!String.IsNullOrWhiteSpace(messageLevel))
                {
                    if (Enum.TryParse <MessageLevel>(messageLevel, true, out level))
                    {
                        copyCommand.MissingEntry = level;
                    }
                    else
                    {
                        this.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel);
                    }
                }

                messageLevel = copyNode.GetAttribute("missing-source", String.Empty);

                if (!String.IsNullOrWhiteSpace(messageLevel))
                {
                    if (Enum.TryParse <MessageLevel>(messageLevel, true, out level))
                    {
                        copyCommand.MissingSource = level;
                    }
                    else
                    {
                        this.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel);
                    }
                }

                messageLevel = copyNode.GetAttribute("missing-target", String.Empty);

                if (!String.IsNullOrWhiteSpace(messageLevel))
                {
                    if (Enum.TryParse <MessageLevel>(messageLevel, true, out level))
                    {
                        copyCommand.MissingTarget = level;
                    }
                    else
                    {
                        this.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel);
                    }
                }

                copyCommands.Add(copyCommand);
            }

            XPathNodeIterator componentNodes = configuration.Select("components/component");

            foreach (XPathNavigator componentNode in componentNodes)
            {
                // Get the ID of the copy component
                string id = componentNode.GetAttribute("id", String.Empty);

                if (String.IsNullOrWhiteSpace(id))
                {
                    this.WriteMessage(MessageLevel.Error, "Each copy component element must have an id attribute");
                }

                var copyComponentFactory = copyComponentFactories.FirstOrDefault(g => g.Metadata.Id == id);

                if (copyComponentFactory == null)
                {
                    this.WriteMessage(MessageLevel.Error, "A copy component with the ID '{0}' could not be found", id);
                }

                try
                {
                    var copyComponent = copyComponentFactory.Value.Create(this);

                    copyComponent.Initialize(componentNode.Clone(), BuildComponentCore.Data);
                    components.Add(copyComponent);
                }
                catch (Exception ex)
                {
                    this.WriteMessage(MessageLevel.Error, "An error occurred while attempting to instantiate " +
                                      "the '{0}' copy component. The error message is: {1}{2}", id, ex.Message,
                                      ex.InnerException != null ? "\r\n" + ex.InnerException.Message : String.Empty);
                }
            }

            if (components.Count != 0)
            {
                this.WriteMessage(MessageLevel.Info, "Loaded {0} copy components", components.Count);
            }
        }
Exemplo n.º 20
0
 /// <summary>Create a component.</summary>
 /// <param name="ancestor">Ancestor element to pull encoding information from.</param>
 /// <param name="parentIndex">Zero-based index within the parent divider.</param>
 /// <param name="externalIndex">HL7 index to identify as.</param>
 public ComponentParser(Parser ancestor, int parentIndex, int externalIndex)
     : base(ancestor, parentIndex, externalIndex)
 {
     _subcomponents = new WeakReferenceCache<SubcomponentParser>(CreateSubcomponent);
 }