コード例 #1
0
 private void PlayArea_MouseMove(object sender, MouseEventArgs e)
 {
     cursorPosition = e.GetPosition(game.PlayArea);
     if (currentStructure != null)
     {
         if (currentStructure.GetType() == typeof(Wall))
         {
             MoveWall(currentStructure as Wall);
         }
         else if (currentStructure != null && currentStructure is Turret)
         {
             MoveTurret(currentStructure as Turret);
         }
     }
 }
コード例 #2
0
ファイル: MessageNavigator.cs プロジェクト: erichwu/nHapi
        /// <summary> Navigates to a specific location in the message</summary>
        private void drillHere(IStructure destination)
        {
            IStructure pathElem   = destination;
            ArrayList  pathStack  = new ArrayList();
            ArrayList  indexStack = new ArrayList();

            do
            {
                MessageIterator.Index index = MessageIterator.getIndex(pathElem.ParentStructure, pathElem);
                indexStack.Add(index);
                pathElem = pathElem.ParentStructure;
                pathStack.Add(pathElem);
            } while (!root.Equals(pathElem) && !typeof(IMessage).IsAssignableFrom(pathElem.GetType()));

            if (!root.Equals(pathElem))
            {
                throw new HL7Exception("The destination provided is not under the root of this navigator");
            }

            reset();
            while (!(pathStack.Count == 0))
            {
                IGroup parent = (IGroup)SupportClass.StackSupport.Pop(pathStack);
                MessageIterator.Index index = (MessageIterator.Index)SupportClass.StackSupport.Pop(indexStack);
                int child = search(parent.Names, index.name);
                if (!(pathStack.Count == 0))
                {
                    drillDown(child, 0);
                }
                else
                {
                    toChild(child);
                }
            }
        }
コード例 #3
0
        /// <summary> As findSegment(), but will only return a group.</summary>
        public virtual IGroup findGroup(String namePattern, int rep)
        {
            IStructure s = null;

            do
            {
                s = findStructure(namePattern, rep);
            } while (!typeof(IGroup).IsAssignableFrom(s.GetType()));
            return((IGroup)s);
        }
コード例 #4
0
        /// <summary> As getSegment() but will only return a group.</summary>
        public virtual IGroup getGroup(String namePattern, int rep)
        {
            IStructure s = GetStructure(namePattern, rep);

            if (!typeof(IGroup).IsAssignableFrom(s.GetType()))
            {
                throw new HL7Exception(s.GetStructureName() + " is not a group", HL7Exception.APPLICATION_INTERNAL_ERROR);
            }
            return((IGroup)s);
        }
コード例 #5
0
        /// <summary> Returns the first segment with a name that matches the given pattern, in a depth-first search.
        /// Repeated searches are initiated from the location just AFTER where the last segment was found.
        /// Call reset() is this is not desired.  Note: this means that the current location will not be found.
        /// </summary>
        /// <param name="segmentName">the name of the segment to find.  The wildcad * means any number
        /// of arbitrary characters; the wildard ? one arbitrary character
        /// (eg "P*" or "*ID" or "???" or "P??" would match on PID).
        /// </param>
        /// <param name="rep">the repetition of the segment to return
        /// </param>
        public virtual ISegment findSegment(System.String namePattern, int rep)
        {
            IStructure s = null;

            do
            {
                s = findStructure(namePattern, rep);
            }while (!typeof(ISegment).IsAssignableFrom(s.GetType()));
            return((ISegment)s);
        }
コード例 #6
0
        /// <summary> Returns the first segment with a name matching the given pattern that is a sibling of
        /// the structure at the current location.  Other parts of the message are
        /// not searched (in contrast to findSegment).
        /// As a special case, if the pointer is at the root, the children of the root
        /// are searched.
        /// </summary>
        /// <param name="segmentName">the name of the segment to get.  The wildcad * means any number
        /// of arbitrary characters; the wildard ? one arbitrary character
        /// (eg "P*" or "*ID" or "???" or "P??" would match on PID).
        /// </param>
        /// <param name="rep">the repetition of the segment to return
        /// </param>
        public virtual ISegment getSegment(System.String namePattern, int rep)
        {
            IStructure s = GetStructure(namePattern, rep);

            if (!typeof(ISegment).IsAssignableFrom(s.GetType()))
            {
                throw new HL7Exception(s.GetStructureName() + " is not a segment", HL7Exception.APPLICATION_INTERNAL_ERROR);
            }
            return((ISegment)s);
        }
コード例 #7
0
ファイル: ProcessHelper.cs プロジェクト: cargima/HL7Parser
 /// <summary>
 /// Processes the structure.
 /// A base structure can be either a segment, or segment group. This function
 /// determines which it is before passing it on.
 /// </summary>
 /// <param name="structure">The structure.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 private static void ProcessStructure(IStructure structure, FieldGroup parentNode)
 {
     if (structure.GetType().IsSubclassOf(typeof(AbstractSegment)))
     {
         AbstractSegment seg = (AbstractSegment)structure;
         ProcessSegment(seg, parentNode);
     }
     else if (structure.GetType().IsSubclassOf(typeof(AbstractGroup)))
     {
         AbstractGroup structureGroup = (AbstractGroup)structure;
         ProcessStructureGroup(structureGroup, parentNode);
     }
     else
     {
         parentNode.FieldList.Add(new FieldGroup()
         {
             Name = "Something Else!!!"
         });
     }
 }
コード例 #8
0
        public void Test_ShouldReturnBuilding_WhenGivenDef(Type defType, Type expectedType)
        {
            //    Arrange
            BuildingFactory buildingFactory = new BuildingFactory(faction, game);
            IStructureDef   def             = (IStructureDef)Activator.CreateInstance(defType);


            //    Act
            IStructure <IStructureDef> building = buildingFactory.CreateNewBuilding(def);

            //    Assert
            Assert.AreEqual(expectedType, building.GetType());
        }
コード例 #9
0
ファイル: MessageIterator.cs プロジェクト: erdemsarigh/nhapi
        /* for configurability (maybe to add later, replacing hard-coded options
         * in nextFromEndOfGroup) ...
         * public void setSearchLevel(String level) {
         * if (WHOLE_GROUP.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = false;
         * } else if (FIRST_DESCENDENTS_ONLY.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = true;
         * } else if (UP_TO_FIRST_REQUIRED.equals(level)) {
         * this.findUpToFirstRequired = true;
         * this.findFirstDescendentsOnly = false;
         * } else {
         * throw IllegalArgumentException(level + " is not a valid search level.  Should be WHOLE_GROUP, etc.");
         * }
         * }
         *
         * public String getSearchLevel() {
         * String level = WHOLE_GROUP;
         * if (this.findFirstDescendentsOnly) {
         * level = FIRST_DESCENDENTS_ONLY;
         * } else if (this.findUpTpFirstRequired) {
         * level = UP_TO_FIRST_REQUIRED;
         * }
         * return level;
         * }*/

        #region Public Methods and Operators

        /// <summary>
        /// Determines whether the given structure matches the given name, or contains a child that does.
        /// </summary>
        ///
        /// <exception cref="ApplicationException"> Thrown when an Application error condition occurs. </exception>
        ///
        /// <param name="s">                    the structure to check. </param>
        /// <param name="name">                 the name to look for. </param>
        /// <param name="firstDescendentsOnly"> only checks first descendents (i.e. first child, first
        ///                                     child of first child, etc.)  In theory the first child of
        ///                                     a group should always be present, and we don't use this
        ///                                     method with subsequent children because finding the next
        ///                                     position within a group is straightforward.  </param>
        /// <param name="upToFirstRequired">    only checks first descendents and of their siblings up to
        ///                                     the first required one.  This may be needed because in
        ///                                     practice some first children of groups are not required.  </param>
        ///
        /// <returns>   true if the object is in this collection, false if not. </returns>

        public static bool contains(IStructure s, System.String name, bool firstDescendentsOnly, bool upToFirstRequired)
        {
            bool contains = false;

            if (typeof(ISegment).IsAssignableFrom(s.GetType()))
            {
                if (s.GetStructureName().Equals(name))
                {
                    contains = true;
                }
            }
            else
            {
                IGroup          g     = (IGroup)s;
                System.String[] names = g.Names;
                for (int i = 0; i < names.Length && !contains; i++)
                {
                    try
                    {
                        contains = MessageIterator.contains(
                            g.GetStructure(names[i], 0),
                            name,
                            firstDescendentsOnly,
                            upToFirstRequired);
                        if (firstDescendentsOnly)
                        {
                            break;
                        }
                        if (upToFirstRequired && g.IsRequired(names[i]))
                        {
                            break;
                        }
                    }
                    catch (HL7Exception e)
                    {
                        throw new System.ApplicationException("HL7Exception due to bad index: " + e.Message);
                    }
                }
            }
            return(contains);
        }
コード例 #10
0
        /* for configurability (maybe to add later, replacing hard-coded options
         * in nextFromEndOfGroup) ...
         * public void setSearchLevel(String level) {
         * if (WHOLE_GROUP.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = false;
         * } else if (FIRST_DESCENDENTS_ONLY.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = true;
         * } else if (UP_TO_FIRST_REQUIRED.equals(level)) {
         * this.findUpToFirstRequired = true;
         * this.findFirstDescendentsOnly = false;
         * } else {
         * throw IllegalArgumentException(level + " is not a valid search level.  Should be WHOLE_GROUP, etc.");
         * }
         * }
         *
         * public String getSearchLevel() {
         * String level = WHOLE_GROUP;
         * if (this.findFirstDescendentsOnly) {
         * level = FIRST_DESCENDENTS_ONLY;
         * } else if (this.findUpTpFirstRequired) {
         * level = UP_TO_FIRST_REQUIRED;
         * }
         * return level;
         * }*/


        /// <summary> Returns true if another object exists in the iteration sequence.  </summary>
        public virtual bool MoveNext()
        {
            bool has = true;

            if (next_Renamed_Field == null)
            {
                if (typeof(IGroup).IsAssignableFrom(currentStructure.GetType()))
                {
                    groupNext((IGroup)currentStructure);
                }
                else
                {
                    IGroup   parent          = currentStructure.ParentStructure;
                    Index    i               = getIndex(parent, currentStructure);
                    Position currentPosition = new Position(parent, i);

                    try
                    {
                        if (parent.IsRepeating(i.name) && currentStructure.GetStructureName().Equals(direction))
                        {
                            nextRep(currentPosition);
                        }
                        else
                        {
                            has = nextPosition(currentPosition, this.direction, this.handleUnexpectedSegments);
                        }
                    }
                    catch (HL7Exception e)
                    {
                        throw new System.ApplicationException("HL7Exception arising from bad index: " + e.Message);
                    }
                }
            }
            log.Debug("MessageIterator.hasNext() in direction " + this.direction + "? " + has);
            return(has);
        }
コード例 #11
0
ファイル: MessageIterator.cs プロジェクト: snosrap/nhapi
 /// <summary> Determines whether the given structure matches the given name, or contains 
 /// a child that does.  
 /// </summary>
 /// <param name="s">the structure to check 
 /// </param>
 /// <param name="name">the name to look for 
 /// </param>
 /// <param name="firstDescendentsOnly">only checks first descendents (i.e. first 
 /// child, first child of first child, etc.)  In theory the first child 
 /// of a group should always be present, and we don't use this method with 
 /// subsequent children because finding the next position within a group is 
 /// straightforward.  
 /// </param>
 /// <param name="upToFirstRequired">only checks first descendents and of their siblings 
 /// up to the first required one.  This may be needed because in practice 
 /// some first children of groups are not required.  
 /// </param>
 public static bool contains(IStructure s, System.String name, bool firstDescendentsOnly, bool upToFirstRequired)
 {
     bool contains = false;
     if (typeof(ISegment).IsAssignableFrom(s.GetType()))
     {
         if (s.GetStructureName().Equals(name))
             contains = true;
     }
     else
     {
         IGroup g = (IGroup)s;
         System.String[] names = g.Names;
         for (int i = 0; i < names.Length && !contains; i++)
         {
             try
             {
                 contains = MessageIterator.contains(g.GetStructure(names[i], 0), name, firstDescendentsOnly, upToFirstRequired);
                 if (firstDescendentsOnly)
                     break;
                 if (upToFirstRequired && g.IsRequired(names[i]))
                     break;
             }
             catch (HL7Exception e)
             {
                 throw new System.ApplicationException("HL7Exception due to bad index: " + e.Message);
             }
         }
     }
     return contains;
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: dgrinberg/HL7-Snoop
 /// <summary>
 /// Processes the structure.
 /// A base structure can be either a segment, or segment group. This function
 /// determines which it is before passing it on.
 /// </summary>
 /// <param name="structure">The structure.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 private void ProcessStructure(IStructure structure, FieldGroup parentNode)
 {
     if (structure.GetType().IsSubclassOf(typeof(AbstractSegment)))
     {
         AbstractSegment seg = (AbstractSegment)structure;
         this.ProcessSegment(seg, parentNode);
     }
     else if (structure.GetType().IsSubclassOf(typeof(AbstractGroup)))
     {
         AbstractGroup structureGroup = (AbstractGroup)structure;
         this.ProcessStructureGroup(structureGroup, parentNode);
     }
     else
     {
         parentNode.FieldList.Add(new Field() { Name = "Something Else!!!" });
     }
 }