示例#1
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (IdentifierElement != null)
                {
                    IdentifierElement.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (ReportType != null)
                {
                    result.AddRange(ReportType.Validate());
                }
                if (ReportDateElement != null)
                {
                    result.AddRange(ReportDateElement.Validate());
                }
                if (TextElement != null)
                {
                    result.AddRange(TextElement.Validate());
                }
                if (Reaction != null)
                {
                    Reaction.ForEach(elem => result.AddRange(elem.Validate()));
                }

                return(result);
            }
示例#2
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as MessageHeaderResponseComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (IdentifierElement != null)
                    {
                        dest.IdentifierElement = (Hl7.Fhir.Model.Id)IdentifierElement.DeepCopy();
                    }
                    if (CodeElement != null)
                    {
                        dest.CodeElement = (Code <Hl7.Fhir.Model.MessageHeader.ResponseType>)CodeElement.DeepCopy();
                    }
                    if (Details != null)
                    {
                        dest.Details = (Hl7.Fhir.Model.ResourceReference)Details.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
示例#3
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Query;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (IdentifierElement != null)
                {
                    dest.IdentifierElement = (Hl7.Fhir.Model.FhirUri)IdentifierElement.DeepCopy();
                }
                if (Parameter != null)
                {
                    dest.Parameter = new List <Hl7.Fhir.Model.Extension>(Parameter.DeepCopy());
                }
                if (Response != null)
                {
                    dest.Response = (Hl7.Fhir.Model.Query.QueryResponseComponent)Response.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
示例#4
0
        public override Node ExitFieldPropertyExpression(Production node)
        {
            //string name = ((Token)node.GetChildAt(0))?.Image;
            var name = node.GetChildAt(0).GetValue(0).ToString();
            var elem = new IdentifierElement(name);

            node.AddValue(elem);
            return(node);
        }
示例#5
0
        private MetaData GenerateMetaData()
        {
            CreatorElement creator = new CreatorElement();

            creator.Text = "Charles Petzold";

            IdentifierElement identifier = new IdentifierElement();

            identifier.Identifier = "urn:isbn:9780735656680";

            TitleElement title = new TitleElement();

            //title.Text = "Microsoft XNA Framework Edition: Programming Windows Phone 7";
            title.Text = doc.Name;

            RightsElement rights = new RightsElement();

            rights.Text = "Copyright © 2010";

            PublisherElement publisher = new PublisherElement();

            publisher.Text = "Microsoft Press";

            SubjectElement subject = new SubjectElement();

            subject.Text = "COMPUTERS / Programming / Microsoft Programming";

            DateElement date = new DateElement();

            date.Text = "2010-12-15";

            DescriptionElement description = new DescriptionElement();

            description.Text = "&lt;p&gt;Focusing on XNA and the C# language, you&amp;#8217;ll learn how to extend your existing skills to the Windows Phone 7 platform&amp;#8212;mastering the core tools and techniques for creating your own games for the phone.&lt;/p&gt;";

            LanguageElement language = new LanguageElement();

            language.Text = "en";

            MetaData meta = new MetaData()
            {
                Identifier  = identifier,
                Title       = title,
                Rights      = rights,
                Publisher   = publisher,
                Subject     = subject,
                Date        = date,
                Description = description,
                Creator     = creator,
                Language    = language
            };

            return(meta);
        }
示例#6
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as QueryResponseComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (IdentifierElement != null)
                    {
                        dest.IdentifierElement = (Hl7.Fhir.Model.FhirUri)IdentifierElement.DeepCopy();
                    }
                    if (OutcomeElement != null)
                    {
                        dest.OutcomeElement = (Code <Hl7.Fhir.Model.Query.QueryOutcome>)OutcomeElement.DeepCopy();
                    }
                    if (TotalElement != null)
                    {
                        dest.TotalElement = (Hl7.Fhir.Model.Integer)TotalElement.DeepCopy();
                    }
                    if (Parameter != null)
                    {
                        dest.Parameter = new List <Hl7.Fhir.Model.Extension>(Parameter.DeepCopy());
                    }
                    if (First != null)
                    {
                        dest.First = new List <Hl7.Fhir.Model.Extension>(First.DeepCopy());
                    }
                    if (Previous != null)
                    {
                        dest.Previous = new List <Hl7.Fhir.Model.Extension>(Previous.DeepCopy());
                    }
                    if (Next != null)
                    {
                        dest.Next = new List <Hl7.Fhir.Model.Extension>(Next.DeepCopy());
                    }
                    if (Last != null)
                    {
                        dest.Last = new List <Hl7.Fhir.Model.Extension>(Last.DeepCopy());
                    }
                    if (Reference != null)
                    {
                        dest.Reference = new List <Hl7.Fhir.Model.ResourceReference>(Reference.DeepCopy());
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
示例#7
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (IdentifierElement != null)
                {
                    result.AddRange(IdentifierElement.Validate());
                }
                if (OutcomeElement != null)
                {
                    result.AddRange(OutcomeElement.Validate());
                }
                if (TotalElement != null)
                {
                    result.AddRange(TotalElement.Validate());
                }
                if (Parameter != null)
                {
                    Parameter.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (First != null)
                {
                    First.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Previous != null)
                {
                    Previous.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Next != null)
                {
                    Next.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Last != null)
                {
                    Last.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Reference != null)
                {
                    Reference.ForEach(elem => result.AddRange(elem.Validate()));
                }

                return(result);
            }
示例#8
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (IdentifierElement != null)
            {
                result.AddRange(IdentifierElement.Validate());
            }
            if (Parameter != null)
            {
                Parameter.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Response != null)
            {
                result.AddRange(Response.Validate());
            }

            return(result);
        }
示例#9
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (IdentifierElement != null)
                {
                    result.AddRange(IdentifierElement.Validate());
                }
                if (CodeElement != null)
                {
                    result.AddRange(CodeElement.Validate());
                }
                if (Details != null)
                {
                    result.AddRange(Details.Validate());
                }

                return(result);
            }
示例#10
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MessageHeader;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (IdentifierElement != null)
                {
                    dest.IdentifierElement = (Hl7.Fhir.Model.Id)IdentifierElement.DeepCopy();
                }
                if (TimestampElement != null)
                {
                    dest.TimestampElement = (Hl7.Fhir.Model.Instant)TimestampElement.DeepCopy();
                }
                if (Event != null)
                {
                    dest.Event = (Hl7.Fhir.Model.Coding)Event.DeepCopy();
                }
                if (Response != null)
                {
                    dest.Response = (Hl7.Fhir.Model.MessageHeader.MessageHeaderResponseComponent)Response.DeepCopy();
                }
                if (Source != null)
                {
                    dest.Source = (Hl7.Fhir.Model.MessageHeader.MessageSourceComponent)Source.DeepCopy();
                }
                if (Destination != null)
                {
                    dest.Destination = new List <Hl7.Fhir.Model.MessageHeader.MessageDestinationComponent>(Destination.DeepCopy());
                }
                if (Enterer != null)
                {
                    dest.Enterer = (Hl7.Fhir.Model.ResourceReference)Enterer.DeepCopy();
                }
                if (Author != null)
                {
                    dest.Author = (Hl7.Fhir.Model.ResourceReference)Author.DeepCopy();
                }
                if (Receiver != null)
                {
                    dest.Receiver = (Hl7.Fhir.Model.ResourceReference)Receiver.DeepCopy();
                }
                if (Responsible != null)
                {
                    dest.Responsible = (Hl7.Fhir.Model.ResourceReference)Responsible.DeepCopy();
                }
                if (Reason != null)
                {
                    dest.Reason = (Hl7.Fhir.Model.CodeableConcept)Reason.DeepCopy();
                }
                if (Data != null)
                {
                    dest.Data = new List <Hl7.Fhir.Model.ResourceReference>(Data.DeepCopy());
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
示例#11
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (IdentifierElement != null)
            {
                result.AddRange(IdentifierElement.Validate());
            }
            if (VersionElement != null)
            {
                result.AddRange(VersionElement.Validate());
            }
            if (NameElement != null)
            {
                result.AddRange(NameElement.Validate());
            }
            if (PublisherElement != null)
            {
                result.AddRange(PublisherElement.Validate());
            }
            if (Telecom != null)
            {
                Telecom.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (DescriptionElement != null)
            {
                result.AddRange(DescriptionElement.Validate());
            }
            if (CopyrightElement != null)
            {
                result.AddRange(CopyrightElement.Validate());
            }
            if (StatusElement != null)
            {
                result.AddRange(StatusElement.Validate());
            }
            if (ExperimentalElement != null)
            {
                result.AddRange(ExperimentalElement.Validate());
            }
            if (DateElement != null)
            {
                result.AddRange(DateElement.Validate());
            }
            if (Define != null)
            {
                result.AddRange(Define.Validate());
            }
            if (Compose != null)
            {
                result.AddRange(Compose.Validate());
            }
            if (Expansion != null)
            {
                result.AddRange(Expansion.Validate());
            }

            return(result);
        }
示例#12
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ConceptMap;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (IdentifierElement != null)
                {
                    dest.IdentifierElement = (Hl7.Fhir.Model.FhirString)IdentifierElement.DeepCopy();
                }
                if (VersionElement != null)
                {
                    dest.VersionElement = (Hl7.Fhir.Model.FhirString)VersionElement.DeepCopy();
                }
                if (NameElement != null)
                {
                    dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
                }
                if (PublisherElement != null)
                {
                    dest.PublisherElement = (Hl7.Fhir.Model.FhirString)PublisherElement.DeepCopy();
                }
                if (Telecom != null)
                {
                    dest.Telecom = new List <Hl7.Fhir.Model.Contact>(Telecom.DeepCopy());
                }
                if (DescriptionElement != null)
                {
                    dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
                }
                if (CopyrightElement != null)
                {
                    dest.CopyrightElement = (Hl7.Fhir.Model.FhirString)CopyrightElement.DeepCopy();
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Hl7.Fhir.Model.Code)StatusElement.DeepCopy();
                }
                if (ExperimentalElement != null)
                {
                    dest.ExperimentalElement = (Hl7.Fhir.Model.FhirBoolean)ExperimentalElement.DeepCopy();
                }
                if (DateElement != null)
                {
                    dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
                }
                if (Source != null)
                {
                    dest.Source = (Hl7.Fhir.Model.ResourceReference)Source.DeepCopy();
                }
                if (Target != null)
                {
                    dest.Target = (Hl7.Fhir.Model.ResourceReference)Target.DeepCopy();
                }
                if (Concept != null)
                {
                    dest.Concept = new List <Hl7.Fhir.Model.ConceptMap.ConceptMapConceptComponent>(Concept.DeepCopy());
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
示例#13
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (IdentifierElement != null)
            {
                result.AddRange(IdentifierElement.Validate());
            }
            if (TimestampElement != null)
            {
                result.AddRange(TimestampElement.Validate());
            }
            if (EventElement != null)
            {
                result.AddRange(EventElement.Validate());
            }
            if (Response != null)
            {
                result.AddRange(Response.Validate());
            }
            if (Source != null)
            {
                result.AddRange(Source.Validate());
            }
            if (Destination != null)
            {
                result.AddRange(Destination.Validate());
            }
            if (Enterer != null)
            {
                result.AddRange(Enterer.Validate());
            }
            if (Author != null)
            {
                result.AddRange(Author.Validate());
            }
            if (Receiver != null)
            {
                result.AddRange(Receiver.Validate());
            }
            if (Responsible != null)
            {
                result.AddRange(Responsible.Validate());
            }
            if (Effective != null)
            {
                result.AddRange(Effective.Validate());
            }
            if (Reason != null)
            {
                result.AddRange(Reason.Validate());
            }
            if (Data != null)
            {
                Data.ForEach(elem => result.AddRange(elem.Validate()));
            }

            return(result);
        }
示例#14
0
        public LexicalElement NextToken()
        {
            LexicalElement result     = null;
            Span <char>    buffer     = stackalloc char[129];
            int            bufferFill = 0;
            bool           run        = true;
            // if (input.EndOfStream) return null;
            int startIndex = currentCursor - 1;

            while (result == null && run)
            {
                switch (_state)
                {
                case State.TransitionNeeded:
                    bufferFill = 0;
                    startIndex = currentCursor - 1;
                    if (lastChar == '\r')
                    {
                        _state = State.CR;
                    }
                    else if (lastChar == '\n')
                    {
                        _state = State.LF;
                    }
                    else if (Mappings.CanBeNonword(lastChar))
                    {
                        _state = State.Nonword;
                    }
                    else if (Mappings.CanBeIdentifier(lastChar, true))
                    {
                        _state = State.IdentifierOrKeyword;
                    }
                    else if (lastChar == '\"')
                    {
                        sb.Clear();
                        _state = State.String;
                    }
                    else if (char.IsDigit(lastChar))
                    {
                        _state = State.Number;
                    }
                    else if (char.IsWhiteSpace(lastChar))
                    {
                        _state = State.WhiteCharacters;
                    }
                    else if (lastChar == '{')
                    {
                        _state = State.Comment;
                    }
                    else if (lastChar == '\0')
                    {
                        return(null);
                    }
                    else
                    {
                        throw new LexicalException(currentLine, currentCursor - 1, currentCursor, $"Unknown character \'{lastChar}\'");
                    }
                    continue;

                case State.CR:
                    AdvanceChar();
                    if (lastChar == '\n')
                    {
                        _state = State.TransitionNeeded;
                        result = new LineFeedElement()
                        {
                            LineNumber = currentLine, StartIndex = currentCursor - 2, EndIndex = currentCursor, StringValue = "\r\n"
                        };
                        currentCursor = 0;
                        currentLine++;
                        AdvanceChar();
                        return(result);
                    }
                    else
                    {
                        _state = State.TransitionNeeded;
                        result = new LineFeedElement()
                        {
                            LineNumber = currentLine, StartIndex = currentCursor - 2, EndIndex = currentCursor - 1, StringValue = "\r"
                        };
                        currentLine++;
                        currentCursor = 0;
                        AdvanceChar();
                        return(result);
                    }

                case State.LF:
                    _state = State.TransitionNeeded;
                    result = new LineFeedElement()
                    {
                        LineNumber = currentLine, StartIndex = currentCursor - 2, EndIndex = currentCursor - 1, StringValue = "\r"
                    };
                    currentLine++;
                    currentCursor = 0;
                    AdvanceChar();
                    return(result);

                case State.WhiteCharacters:
                    if (!char.IsWhiteSpace(AdvanceChar()))
                    {
                        _state = State.TransitionNeeded;
                    }
                    continue;

                case State.Nonword:
                    buffer[bufferFill++] = lastChar;
                    if (!Mappings.CanBePairedNonword(lastChar))
                    {
                        AdvanceChar();
                        _state = State.TransitionNeeded;
                        string      s = buffer.Slice(0, bufferFill).ToString();
                        NonwordType ot;
                        if (Mappings.StringToNonwordMap.TryGetValue(s, out ot))
                        {
                            result = new NonwordElement()
                            {
                                LineNumber = currentLine, StartIndex = currentCursor - 1 - bufferFill, EndIndex = currentCursor - 1, Type = ot, StringValue = s
                            };
                            return(result);
                        }
                        else
                        {
                            throw new LexicalException(currentLine, currentCursor - 1 - bufferFill, currentCursor - 1, $"Unknown nonword: \"{s}\"");
                        }
                    }
                    if (!Mappings.CanBeNonword(AdvanceChar()))
                    {
                        _state = State.TransitionNeeded;
                        string      s = buffer.Slice(0, bufferFill).ToString();
                        NonwordType ot;
                        if (Mappings.StringToNonwordMap.TryGetValue(s, out ot))
                        {
                            result = new NonwordElement()
                            {
                                LineNumber = currentLine, StartIndex = currentCursor - 1 - bufferFill, EndIndex = currentCursor - 1, Type = ot, StringValue = s
                            };
                            return(result);
                        }
                        else
                        {
                            throw new LexicalException(currentLine, currentCursor - 1 - bufferFill, currentCursor - 1, $"Unknown nonword: \"{s}\"");
                        }
                    }
                    break;

                case State.IdentifierOrKeyword:
                    buffer[bufferFill++] = lastChar;
                    if (!Mappings.CanBeIdentifier(AdvanceChar()))
                    {
                        _state = State.TransitionNeeded;
                        string      s = buffer.Slice(0, bufferFill).ToString();
                        KeywordType kt;
                        if (Mappings.StringToKeywordMap.TryGetValue(s, out kt))
                        {
                            result = new KeywordElement()
                            {
                                LineNumber = currentLine, StartIndex = currentCursor - 1 - bufferFill, EndIndex = currentCursor - 1, Type = kt, StringValue = s
                            };
                            return(result);
                        }
                        result = new IdentifierElement(s)
                        {
                            LineNumber = currentLine, StartIndex = currentCursor - 1 - bufferFill, EndIndex = currentCursor - 1, StringValue = s
                        };
                    }
                    break;

                case State.String:
                    if (char.IsControl(lastChar))
                    {
                        throw new LexicalException(currentLine, startIndex, currentCursor - 1, $"Malformed string (control character found) \"{buffer.Slice(0, bufferFill-1).ToString()}\"");
                    }
                    if (AdvanceChar() != '\"')
                    {
                        buffer[bufferFill++] = lastChar;
                        if (lastChar == '\\')
                        {
                            buffer[bufferFill++] = AdvanceChar();
                            try {
                                string es = Regex.Unescape(buffer.Slice(bufferFill - 2, 2).ToString());
                                sb.Append(es);
                            } catch {
                                throw new LexicalException(currentLine, currentCursor - 2, currentCursor, $"Unknown string escape sequence \"{buffer.Slice(bufferFill-2, 2).ToString()}\"");
                            }
                        }
                        else
                        {
                            sb.Append(lastChar);
                        }
                    }
                    else
                    {
                        _state = State.TransitionNeeded;
                        result = new StringLiteral()
                        {
                            LineNumber = currentLine, StartIndex = startIndex, EndIndex = currentCursor, StringValue = buffer.Slice(0, bufferFill).ToString(), Value = sb.ToString()
                        };
                        AdvanceChar();
                        return(result);
                    }

                    break;

                case State.Number:
                    buffer[bufferFill++] = lastChar;
                    AdvanceChar();
                    if (!char.IsLetterOrDigit(lastChar) && lastChar != '.')
                    {
                        _state = State.TransitionNeeded;
                        string s = buffer.Slice(0, bufferFill).ToString();
                        if (s.Contains('.'))
                        {
                            try {
                                double value = double.Parse(s);
                                result = new RealLiteral()
                                {
                                    LineNumber = currentLine, StartIndex = startIndex, EndIndex = currentCursor - 1,
                                    Value      = value, StringValue = s
                                };
                                return(result);
                            } catch {
                                throw new LexicalException(currentLine, startIndex, currentCursor - 1,
                                                           $"Malformed real literal: \"{s}\"");
                            }
                        }
                        else
                        {
                            int value;
                            try {
                                if (s.StartsWith("00"))
                                {
                                    // Autodetect
                                    string substr     = s.Substring(2);
                                    int    baseNumber = 10;
                                    if (RegexBinary.IsMatch(substr))
                                    {
                                        // Binary
                                        baseNumber = 2;
                                    }
                                    else if (RegexOctal.IsMatch(substr))
                                    {
                                        // Octal
                                        baseNumber = 8;
                                    }
                                    else if (RegexDecimal.IsMatch(substr))
                                    {
                                        baseNumber = 10;
                                    }
                                    else if (RegexHexadecimal.IsMatch(substr))
                                    {
                                        baseNumber = 16;
                                    }
                                    else
                                    {
                                        throw new LexicalException(currentLine, startIndex, currentCursor - 1,
                                                                   $"Malformed integer literal \"{s}\"");
                                    }

                                    value = Convert.ToInt32(substr, baseNumber);
                                }
                                else if (s.StartsWith("0x"))
                                {
                                    // Hexadecimal
                                    value = Convert.ToInt32(s.Substring(2), 16);
                                }
                                else if (s.StartsWith("0"))
                                {
                                    // Octal
                                    value = Convert.ToInt32(s.Substring(0), 8);
                                }
                                else
                                {
                                    // Decimal
                                    value = Convert.ToInt32(s);
                                }
                            } catch (OverflowException) {
                                throw new LexicalException(currentLine, startIndex, currentCursor - 1, $"Integer overflow \"{s}\"");
                            } catch (Exception e) {
                                if (e is LexicalException)
                                {
                                    throw;
                                }
                                throw new LexicalException(currentLine, startIndex, currentCursor - 1, $"Malformed integer interal \"{s}\"");
                            }


                            result = new IntegerLiteral()
                            {
                                LineNumber = currentLine, StartIndex = startIndex, EndIndex = currentCursor - 1,
                                Value      = value, StringValue = s
                            };
                            return(result);
                        }
                    }
                    else
                    {
                    }

                    break;

                default:
                    throw new LexicalException(currentLine, startIndex, currentCursor, $"Illegal state");

                case State.Comment:
                    AdvanceChar();
                    if (lastChar == '\r')
                    {
                        try {
                            if (Convert.ToInt32(input.Peek()) == '\n')
                            {
                                AdvanceChar();
                            }
                        } catch {
                            throw new LexicalException(currentLine, currentCursor - 2, currentCursor - 1, $"Incomplete comment, read EOF");
                        }
                        currentLine++;
                        currentCursor = 0;
                    }
                    else if (lastChar == '\n')
                    {
                        currentLine++;
                        currentCursor = 0;
                    }
                    else if (lastChar == '}')
                    {
                        // End of comment
                        _state = State.TransitionNeeded;
                        AdvanceChar();
                    }
                    else if (lastChar == '\0')
                    {
                        throw new LexicalException(currentLine, currentCursor - 2, currentCursor - 1, $"Incomplete comment, read EOF");
                    }
                    break;
                }
            }
            return(result);
        }