예제 #1
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as MappingComponent;

                if (dest == null)
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }

                base.CopyTo(dest);
                if (IdentityElement != null)
                {
                    dest.IdentityElement = (Hl7.Fhir.Model.Id)IdentityElement.DeepCopy();
                }
                if (UriElement != null)
                {
                    dest.UriElement = (Hl7.Fhir.Model.FhirUri)UriElement.DeepCopy();
                }
                if (NameElement != null)
                {
                    dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
                }
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                return(dest);
            }
예제 #2
0
        /// <summary>
        /// Gets text from a comment directive, if present.
        /// </summary>
        /// <param name="comment">Comment element containing the directive.</param>
        /// <param name="pattern">Regular expression pattern.</param>
        /// <param name="group">Group key for the text to retrieve.</param>
        /// <returns>Text for the comment directive.</returns>
        protected string GetCommentDirectiveText(CommentElement comment, string pattern, string group)
        {
            string text = null;

            if (comment != null && comment.Type == CommentType.Line && !string.IsNullOrEmpty(pattern))
            {
                Regex regex = null;
                if (!_regexCache.TryGetValue(pattern, out regex))
                {
                    regex = new Regex(pattern, RegexOptions.IgnoreCase);
                    _regexCache.Add(pattern, regex);
                }

                string commentText = comment.Text.Trim();

                Match match = regex.Match(commentText);

                if (match != null && match.Length > 0)
                {
                    Group textGroup = match.Groups[group];
                    if (textGroup != null)
                    {
                        text = textGroup.Value.Trim();
                    }
                }
            }

            return(text);
        }
예제 #3
0
        /// <summary>
        /// Writes a comment line.
        /// </summary>
        /// <param name="comment">Comment code element.</param>
        public override void VisitCommentElement(CommentElement comment)
        {
            StringBuilder builder = new StringBuilder(DefaultBlockLength);

            if (comment.Type == CommentType.Block)
            {
                builder.Append("/*");
                builder.Append(FormatCommentText(comment));
                builder.Append("*/");

                WriteTextBlock(builder.ToString());
            }
            else
            {
                if (comment.Type == CommentType.XmlLine)
                {
                    builder.Append("///");
                }
                else
                {
                    builder.Append("//");
                }

                builder.Append(FormatCommentText(comment));
                WriteIndented(builder.ToString());
            }
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as SubstanceReferenceInformation;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (CommentElement != null)
            {
                dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
            }
            if (Gene != null)
            {
                dest.Gene = new List <Hl7.Fhir.Model.SubstanceReferenceInformation.GeneComponent>(Gene.DeepCopy());
            }
            if (GeneElement != null)
            {
                dest.GeneElement = new List <Hl7.Fhir.Model.SubstanceReferenceInformation.GeneElementComponent>(GeneElement.DeepCopy());
            }
            if (Target != null)
            {
                dest.Target = new List <Hl7.Fhir.Model.SubstanceReferenceInformation.TargetComponent>(Target.DeepCopy());
            }
            return(dest);
        }
예제 #5
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (Collector != null)
                {
                    result.AddRange(Collector.Validate());
                }
                if (CommentElement != null)
                {
                    CommentElement.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (CollectedTimeElement != null)
                {
                    result.AddRange(CollectedTimeElement.Validate());
                }
                if (Quantity != null)
                {
                    result.AddRange(Quantity.Validate());
                }
                if (Method != null)
                {
                    result.AddRange(Method.Validate());
                }
                if (SourceSite != null)
                {
                    result.AddRange(SourceSite.Validate());
                }

                return(result);
            }
예제 #6
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Schedule;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Type != null)
                {
                    dest.Type = new List <Hl7.Fhir.Model.CodeableConcept>(Type.DeepCopy());
                }
                if (Actor != null)
                {
                    dest.Actor = (Hl7.Fhir.Model.ResourceReference)Actor.DeepCopy();
                }
                if (PlanningHorizon != null)
                {
                    dest.PlanningHorizon = (Hl7.Fhir.Model.Period)PlanningHorizon.DeepCopy();
                }
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
예제 #7
0
        public void ToStringTest()
        {
            CommentElement commentLine = new CommentElement("This is some text.");
            string         str         = commentLine.ToString();

            Assert.AreEqual("This is some text.", str, "Unexpected string representation.");
        }
예제 #8
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Appointment;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.Appointment.AppointmentStatus>)StatusElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = (Hl7.Fhir.Model.CodeableConcept)Reason.DeepCopy();
            }
            if (PriorityElement != null)
            {
                dest.PriorityElement = (Hl7.Fhir.Model.UnsignedInt)PriorityElement.DeepCopy();
            }
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (StartElement != null)
            {
                dest.StartElement = (Hl7.Fhir.Model.Instant)StartElement.DeepCopy();
            }
            if (EndElement != null)
            {
                dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
            }
            if (MinutesDurationElement != null)
            {
                dest.MinutesDurationElement = (Hl7.Fhir.Model.PositiveInt)MinutesDurationElement.DeepCopy();
            }
            if (Slot != null)
            {
                dest.Slot = new List <Hl7.Fhir.Model.ResourceReference>(Slot.DeepCopy());
            }
            if (CommentElement != null)
            {
                dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
            }
            if (Participant != null)
            {
                dest.Participant = new List <Hl7.Fhir.Model.Appointment.ParticipantComponent>(Participant.DeepCopy());
            }
            return(dest);
        }
예제 #9
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as UniqueIdComponent;

                if (dest == null)
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }

                base.CopyTo(dest);
                if (TypeElement != null)
                {
                    dest.TypeElement = (Code <Hl7.Fhir.Model.NamingSystem.NamingSystemIdentifierType>)TypeElement.DeepCopy();
                }
                if (ValueElement != null)
                {
                    dest.ValueElement = (Hl7.Fhir.Model.FhirString)ValueElement.DeepCopy();
                }
                if (PreferredElement != null)
                {
                    dest.PreferredElement = (Hl7.Fhir.Model.FhirBoolean)PreferredElement.DeepCopy();
                }
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                if (Period != null)
                {
                    dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
                }
                return(dest);
            }
예제 #10
0
        public override List <Field> GetFieldsForLucene()
        {
            List <Field>   fields         = new List <Field>();
            CommentElement commentElement = (CommentElement)programElement;

            AddBodyField(fields, new Field(SandoField.Body.ToString(), commentElement.Body.ToSandoSearchable(), Field.Store.NO, Field.Index.ANALYZED));
            return(fields);
        }
예제 #11
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Slot;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (ServiceCategory != null)
            {
                dest.ServiceCategory = (Hl7.Fhir.Model.CodeableConcept)ServiceCategory.DeepCopy();
            }
            if (ServiceType != null)
            {
                dest.ServiceType = new List <Hl7.Fhir.Model.CodeableConcept>(ServiceType.DeepCopy());
            }
            if (Specialty != null)
            {
                dest.Specialty = new List <Hl7.Fhir.Model.CodeableConcept>(Specialty.DeepCopy());
            }
            if (AppointmentType != null)
            {
                dest.AppointmentType = (Hl7.Fhir.Model.CodeableConcept)AppointmentType.DeepCopy();
            }
            if (Schedule != null)
            {
                dest.Schedule = (Hl7.Fhir.Model.ResourceReference)Schedule.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.Slot.SlotStatus>)StatusElement.DeepCopy();
            }
            if (StartElement != null)
            {
                dest.StartElement = (Hl7.Fhir.Model.Instant)StartElement.DeepCopy();
            }
            if (EndElement != null)
            {
                dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
            }
            if (OverbookedElement != null)
            {
                dest.OverbookedElement = (Hl7.Fhir.Model.FhirBoolean)OverbookedElement.DeepCopy();
            }
            if (CommentElement != null)
            {
                dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
            }
            return(dest);
        }
예제 #12
0
        public void CreateTextAndXmlTest()
        {
            CommentElement commentLine = new CommentElement("Comment here", CommentType.XmlLine);

            //
            // Verify default property values
            //
            Assert.AreEqual(CommentType.XmlLine, commentLine.Type, "Unexpected value for IsXmlComment.");
            Assert.AreEqual("Comment here", commentLine.Text, "Unexpected value for Text.");
        }
예제 #13
0
        public void CloneTest()
        {
            CommentElement original = DoCreateClonePrototype();
            CommentElement clone    = original.Clone() as CommentElement;

            Assert.IsNotNull(
                clone,
                "Clone did not create an instance of type {0}.",
                typeof(CommentElement).Name);
            Assert.AreNotSame(original, clone, "Clone should be a different instance.");

            DoVerifyClone(original, clone);
        }
예제 #14
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as AllergyIntoleranceEventComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (Substance != null)
                    {
                        dest.Substance = (Hl7.Fhir.Model.CodeableConcept)Substance.DeepCopy();
                    }
                    if (CertaintyElement != null)
                    {
                        dest.CertaintyElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceCertainty>)CertaintyElement.DeepCopy();
                    }
                    if (Manifestation != null)
                    {
                        dest.Manifestation = new List <Hl7.Fhir.Model.CodeableConcept>(Manifestation.DeepCopy());
                    }
                    if (DescriptionElement != null)
                    {
                        dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
                    }
                    if (OnsetElement != null)
                    {
                        dest.OnsetElement = (Hl7.Fhir.Model.FhirDateTime)OnsetElement.DeepCopy();
                    }
                    if (Duration != null)
                    {
                        dest.Duration = (Hl7.Fhir.Model.Duration)Duration.DeepCopy();
                    }
                    if (SeverityElement != null)
                    {
                        dest.SeverityElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceSeverity>)SeverityElement.DeepCopy();
                    }
                    if (ExposureRoute != null)
                    {
                        dest.ExposureRoute = (Hl7.Fhir.Model.CodeableConcept)ExposureRoute.DeepCopy();
                    }
                    if (CommentElement != null)
                    {
                        dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
        public void ProgramElementReader_ReadProgramElementFromDocumentReturnValidCommentElementForValidDocument()
        {
            CommentElement element  = SampleProgramElementFactory.GetSampleCommentElement();
            Document       document = DocumentFactory.Create(element).GetDocument();

            CommentElement returnedElement = ConverterFromHitToProgramElement.Create(document).Convert() as CommentElement;

            Assert.IsNotNull(returnedElement, "returned class element is null!");
            Assert.True("not stored in index" == returnedElement.Body, "AccessLevel is different!");
            Assert.True(element.DefinitionLineNumber == returnedElement.DefinitionLineNumber, "DefinitionLineNumber is different!");
            Assert.True(StandardizeFilePath(element.FullFilePath) == returnedElement.FullFilePath, "FullFilePath is different!");
            Assert.True(element.Name == returnedElement.Name, "Name is different!");
            Assert.True(element.ProgramElementType == returnedElement.ProgramElementType, "ProgramElementType is different!");
            Assert.True(element.RawSource == returnedElement.RawSource, "Snippet is different!");
        }
예제 #16
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as AppointmentResponse;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Appointment != null)
                {
                    dest.Appointment = (Hl7.Fhir.Model.ResourceReference)Appointment.DeepCopy();
                }
                if (StartElement != null)
                {
                    dest.StartElement = (Hl7.Fhir.Model.Instant)StartElement.DeepCopy();
                }
                if (EndElement != null)
                {
                    dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
                }
                if (ParticipantType != null)
                {
                    dest.ParticipantType = new List <Hl7.Fhir.Model.CodeableConcept>(ParticipantType.DeepCopy());
                }
                if (Actor != null)
                {
                    dest.Actor = (Hl7.Fhir.Model.ResourceReference)Actor.DeepCopy();
                }
                if (ParticipantStatus_Element != null)
                {
                    dest.ParticipantStatus_Element = (Code <Hl7.Fhir.Model.AppointmentResponse.ParticipantStatus>)ParticipantStatus_Element.DeepCopy();
                }
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
예제 #17
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Slot;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Schedule != null)
                {
                    dest.Schedule = (Hl7.Fhir.Model.ResourceReference)Schedule.DeepCopy();
                }
                if (FreeBusyTypeElement != null)
                {
                    dest.FreeBusyTypeElement = (Code <Hl7.Fhir.Model.Slot.SlotStatus>)FreeBusyTypeElement.DeepCopy();
                }
                if (StartElement != null)
                {
                    dest.StartElement = (Hl7.Fhir.Model.Instant)StartElement.DeepCopy();
                }
                if (EndElement != null)
                {
                    dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
                }
                if (OverbookedElement != null)
                {
                    dest.OverbookedElement = (Hl7.Fhir.Model.FhirBoolean)OverbookedElement.DeepCopy();
                }
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
예제 #18
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Schedule;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (ActiveElement != null)
            {
                dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy();
            }
            if (ServiceCategory != null)
            {
                dest.ServiceCategory = new List <Hl7.Fhir.Model.CodeableConcept>(ServiceCategory.DeepCopy());
            }
            if (ServiceType != null)
            {
                dest.ServiceType = new List <Hl7.Fhir.Model.CodeableConcept>(ServiceType.DeepCopy());
            }
            if (Specialty != null)
            {
                dest.Specialty = new List <Hl7.Fhir.Model.CodeableConcept>(Specialty.DeepCopy());
            }
            if (Actor != null)
            {
                dest.Actor = new List <Hl7.Fhir.Model.ResourceReference>(Actor.DeepCopy());
            }
            if (PlanningHorizon != null)
            {
                dest.PlanningHorizon = (Hl7.Fhir.Model.Period)PlanningHorizon.DeepCopy();
            }
            if (CommentElement != null)
            {
                dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
            }
            return(dest);
        }
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as MediaComponent;

                if (dest == null)
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }

                base.CopyTo(dest);
                if (CommentElement != null)
                {
                    dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
                }
                if (Link != null)
                {
                    dest.Link = (Hl7.Fhir.Model.ResourceReference)Link.DeepCopy();
                }
                return(dest);
            }
예제 #20
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as CollectionComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (Collector != null)
                    {
                        dest.Collector = (Hl7.Fhir.Model.ResourceReference)Collector.DeepCopy();
                    }
                    if (CommentElement != null)
                    {
                        dest.CommentElement = new List <Hl7.Fhir.Model.FhirString>(CommentElement.DeepCopy());
                    }
                    if (Collected != null)
                    {
                        dest.Collected = (Hl7.Fhir.Model.Element)Collected.DeepCopy();
                    }
                    if (Quantity != null)
                    {
                        dest.Quantity = (Hl7.Fhir.Model.SimpleQuantity)Quantity.DeepCopy();
                    }
                    if (Method != null)
                    {
                        dest.Method = (Hl7.Fhir.Model.CodeableConcept)Method.DeepCopy();
                    }
                    if (BodySite != null)
                    {
                        dest.BodySite = (Hl7.Fhir.Model.CodeableConcept)BodySite.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
예제 #21
0
        /// <summary>
        /// Writes a comment line.
        /// </summary>
        /// <param name="comment">The comment.</param>
        public override void VisitCommentElement(CommentElement comment)
        {
            if (comment.Type == CommentType.Block)
            {
                throw new InvalidOperationException("Block comments are not supported by VB.");
            }
            else
            {
                StringBuilder builder = new StringBuilder(DefaultBlockLength);

                if (comment.Type == CommentType.XmlLine)
                {
                    builder.Append("'''");
                }
                else
                {
                    builder.Append("'");
                }

                builder.Append(FormatCommentText(comment));
                WriteIndented(builder.ToString());
            }
        }
예제 #22
0
        public void GetAttributeTypeTest()
        {
            FieldElement fieldElement = new FieldElement();

            fieldElement.Name   = "TestField";
            fieldElement.Access = CodeAccess.Protected;
            fieldElement.Type   = "int";

            string attribute = ElementUtilities.GetAttribute(ElementAttributeType.Type, fieldElement);

            Assert.AreEqual("int", attribute, "Unexpected attribute.");

            TypeElement typeElement = new TypeElement();

            typeElement.Type = TypeElementType.Interface;

            attribute = ElementUtilities.GetAttribute(ElementAttributeType.Type, typeElement);
            Assert.AreEqual("Interface", attribute, "Unexpected attribute.");

            CommentElement commentElement = new CommentElement(CommentType.Block);

            attribute = ElementUtilities.GetAttribute(ElementAttributeType.Type, commentElement);
            Assert.AreEqual("Block", attribute, "Unexpected attribute.");

            UsingElement usingElement = new UsingElement();

            usingElement.Name     = "MySystem";
            usingElement.Redefine = "System";

            attribute = ElementUtilities.GetAttribute(ElementAttributeType.Type, usingElement);
            Assert.AreEqual("Alias", attribute, "Unexpected attribute.");

            ConditionDirectiveElement conditionElement = new ConditionDirectiveElement();

            attribute = ElementUtilities.GetAttribute(ElementAttributeType.Type, conditionElement);
            Assert.AreEqual(string.Empty, attribute, "Unexpected attribute.");
        }
예제 #23
0
    GameObject readXmlNode(XmlNode xmlNode, GameObject parent, string fileName)
    {
        GameObject go = new GameObject(xmlNode.Name);

        if (parent != null)
        {
            go.transform.parent = parent.transform;
        }

        if (xmlNode.NodeType == XmlNodeType.Comment)
        {
            CommentElement comment = go.AddComponent <CommentElement>();
            go.transform.parent = parent.transform;

            comment.comment = xmlNode.InnerText;
        }
        else if (xmlNode.Name == "vehicle")
        {
            Vehicle tag = go.AddComponent <Vehicle>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.sound        = readString(xmlNode, "sound");
            tag.spring       = readFloat(xmlNode, "spring");
            tag.acceleration = readFloat(xmlNode, "acceleration");
            tag.antiroll     = readFloat(xmlNode, "antiroll");
            tag.damping      = readFloat(xmlNode, "damping");
            tag.friction     = readFloat(xmlNode, "friction");
            tag.difflock     = readFloat(xmlNode, "difflock");
            tag.steerassist  = readFloat(xmlNode, "steerassist");
            tag.topspeed     = readFloat(xmlNode, "topspeed");
            tag.driven       = readBool(xmlNode, "driven", false);
            tag.antispin     = readFloat(xmlNode, "antispin");
            tag.soundVolume  = readFloat(xmlNode, "soundvolume");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "wheel")
        {
            Wheel tag = go.AddComponent <Wheel>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.steer  = readFloat(xmlNode, "steer");
            tag.drive  = readFloat(xmlNode, "drive");
            tag.travel = readVec2(xmlNode, "travel");
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "spawnpoint")
        {
            SpawnPoint tag = go.AddComponent <SpawnPoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "location")
        {
            Location tag = go.AddComponent <Location>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "group")
        {
            Group tag = go.AddComponent <Group>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "rope")
        {
            Rope tag = go.AddComponent <Rope>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.strength = readFloat(xmlNode, "strength");
            tag.slack    = readFloat(xmlNode, "slack");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "screen")
        {
            Screen tag = go.AddComponent <Screen>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.size        = readVec2(xmlNode, "size");
            tag.isEnabled   = readBool(xmlNode, "enabled", false);
            tag.interactive = readBool(xmlNode, "interactive", false);
            tag.emissive    = readFloat(xmlNode, "emissive");
            tag.color       = readColor(xmlNode, "color");
            tag.resolution  = readVec2(xmlNode, "resolution");
            tag.bulge       = readVec2(xmlNode, "bulge");
            tag.script      = readString(xmlNode, "script");
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vox")
        {
            Vox tag = go.AddComponent <Vox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            tag.file      = readString(xmlNode, "file").Replace("LEVEL", getLevelFolder(fileName));;
            tag.voxObject = readString(xmlNode, "object");
            tag.dynamic   = readBool(xmlNode, "prop", false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.Reload();

            if (tag.scale > 0)
            {
                go.transform.localScale *= tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "joint")
        {
            TeardownJoint tag = go.AddComponent <TeardownJoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.type        = (TeardownJoint.Type)Enum.Parse(typeof(TeardownJoint.Type), readString(xmlNode, "type", "ball"), false);
            tag.size        = readFloat(xmlNode, "size");
            tag.rotspring   = readFloat(xmlNode, "rotspring");
            tag.rotstrength = readFloat(xmlNode, "rotstrength");
            tag.limits      = readVec2(xmlNode, "limits");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "voxbox")
        {
            VoxBox tag = go.AddComponent <VoxBox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.color   = readColor(xmlNode, "color");
            tag.dynamic = readBool(xmlNode, "prop", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.parent        = go.transform;
            cube.transform.localPosition = new Vector3(0.5f, 0.5f, -0.5f);
            cube.transform.localRotation = Quaternion.identity;
            cube.GetComponent <MeshRenderer>().sharedMaterial = new Material(Shader.Find("Standard"));
            go.transform.localScale = tag.size / 10;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "body")
        {
            Body tag = go.AddComponent <Body>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.dynamic = readBool(xmlNode, "dynamic", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "water")
        {
            go.name = "<" + xmlNode.Name + ">";
            Water tag = go.AddComponent <Water>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "environment")
        {
            TeardownEnvironment tag = go.AddComponent <TeardownEnvironment>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.skyboxrot     = readFloat(xmlNode, "skyboxrot");
            tag.sunBrightness = readFloat(xmlNode, "sunBrightness");
            tag.sunFogScale   = readFloat(xmlNode, "sunFogScale");
            tag.sunDir        = readVec3(xmlNode, "sunDir");
            tag.sunColorTint  = readColor(xmlNode, "sunColorTint");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "scene")
        {
            Scene tag = go.AddComponent <Scene>();

            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.shadowVolume = readVec3(xmlNode, "shadowVolume");
            tag.version      = readInt(xmlNode, "version");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "boundary")
        {
            Boundary tag = go.AddComponent <Boundary>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;
            go.name             = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "script")
        {
            Script tag = go.AddComponent <Script>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "instance")
        {
            Instance tag = go.AddComponent <Instance>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            if (!fileName.Contains("create") && tag.file.StartsWith("LEVEL"))
            {
                Debug.LogError("Your source file has no create folder in its path but an instance is referencing the level folder. Cannot import!");
            }
            else if (!tag.file.StartsWith("LEVEL"))
            {
                GameObject xmlRoot = readXML(tag.file);
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            else
            {
                GameObject xmlRoot = readXML(tag.file.Replace("LEVEL", getLevelFolder(fileName)));
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "prefab")
        {
            Prefab tag = go.AddComponent <Prefab>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vertex")
        {
            Vertex tag = go.AddComponent <Vertex>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);
            tag.pos = readVec2(xmlNode, "pos");

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";
            go.transform.localPosition = new Vector3(tag.pos.x, 0, tag.pos.y);

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "light")
        {
            Light tag = go.AddComponent <Light>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.penumbra   = readFloat(xmlNode, "penumbra");
            tag.unshadowed = readFloat(xmlNode, "unshadowed");
            tag.angle      = readFloat(xmlNode, "angle");
            tag.glare      = readFloat(xmlNode, "glare");
            tag.color      = readColor(xmlNode, "color");
            tag.type       = (Light.Type)Enum.Parse(typeof(Light.Type), readString(xmlNode, "type", "area"), false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }

        foreach (XmlNode child in xmlNode.ChildNodes)
        {
            GameObject childGameObject = readXmlNode(child, go, fileName);
        }

        return(go);
    }
예제 #24
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the code element.</returns>
        protected override CodeElement DoClone()
        {
            CommentElement clone = new CommentElement(_text, _commentType);

            return clone;
        }
예제 #25
0
 public Section(CommentElement type)
 {
     Type       = type;
     Attributes = new List <string>();
     Lines      = new List <string>();
 }
예제 #26
0
        /// <summary>
        /// Processes a region element.
        /// </summary>
        /// <param name="element">Region code element.</param>
        public void VisitRegionElement(RegionElement element)
        {
            RegionStyle regionStyle = _configuration.Formatting.Regions.Style;

            if (regionStyle == RegionStyle.Default)
            {
                // Use the default region style
                regionStyle = RegionStyle.Directive;
            }

            if (regionStyle == RegionStyle.NoDirective ||
                !element.DirectivesEnabled)
            {
                CodeWriter.WriteVisitElements(element.Children, Writer, this);
            }
            else
            {
                if (regionStyle == RegionStyle.Directive)
                {
                    WriteRegionBeginDirective(element);
                }
                else if (regionStyle == RegionStyle.CommentDirective)
                {
                    CommentElement commentDirective = new CommentElement(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Configuration.Formatting.Regions.CommentDirectiveBeginFormat,
                            element.Name).TrimEnd());
                    VisitCommentElement(commentDirective);
                }

                Writer.WriteLine();

                WriteChildren(element);

                if (element.Children.Count > 0)
                {
                    Writer.WriteLine();
                }

                if (regionStyle == RegionStyle.Directive)
                {
                    WriteRegionEndDirective(element);
                }
                else if (regionStyle == RegionStyle.CommentDirective)
                {
                    string regionName = string.Empty;
                    if (Configuration.Formatting.Regions.EndRegionNameEnabled)
                    {
                        regionName = element.Name;
                    }

                    CommentElement commentDirective = new CommentElement(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Configuration.Formatting.Regions.CommentDirectiveEndFormat,
                            regionName).TrimEnd());
                    VisitCommentElement(commentDirective);
                }
            }
        }
예제 #27
0
 public Section(CommentElement type)
 {
     Type = type;
     Attributes = new List<string>();
     Lines = new List<string>();
 }
예제 #28
0
 public CommentDocument(CommentElement classElement)
     : base(classElement)
 {
 }
예제 #29
0
 /// <summary>
 /// Processes a comment element.
 /// </summary>
 /// <param name="element">Comment code element.</param>
 public abstract void VisitCommentElement(CommentElement element);
예제 #30
0
 private static IEnumerable <String> ExtractCommentWords(CommentElement element)
 {
     return(GetDefaultLetterWords(element.Body));
 }
예제 #31
0
 public override void VisitCommentElement(CommentElement element)
 {
     //throw new NotImplementedException();
 }
예제 #32
0
파일: Visitor.cs 프로젝트: zuzhu/pinac
 public abstract void VisitCommentElement(CommentElement element);
예제 #33
0
 public Section(CommentElement type)
 {
     Type = type;
 }
예제 #34
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the code element.</returns>
        protected override CodeElement DoClone()
        {
            CommentElement clone = new CommentElement(_text, _commentType);

            return(clone);
        }