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

                result.AddRange(base.Validate());

                if (CodeElement != null)
                {
                    result.AddRange(CodeElement.Validate());
                }
                if (AbstractElement != null)
                {
                    result.AddRange(AbstractElement.Validate());
                }
                if (DisplayElement != null)
                {
                    result.AddRange(DisplayElement.Validate());
                }
                if (DefinitionElement != null)
                {
                    result.AddRange(DefinitionElement.Validate());
                }
                if (Concept != null)
                {
                    Concept.ForEach(elem => result.AddRange(elem.Validate()));
                }

                return(result);
            }
Example #2
0
        private void AddOrUpdateDefinition(List <ItemDefinition> definitions, DefinitionElement element)
        {
            ItemDefinition definition = definitions.Find(d => d.Discriminator == element.Name);

            if (definition == null)
            {
                Type itemType = EnsureType <ContentItem>(element.Type);
                definition.Discriminator = element.Name;
                definition = new ItemDefinition(itemType);
                definition.Initialize(definition.ItemType);

                definitions.Add(definition);
            }
            else
            {
                Type changedType = Type.GetType(element.Type);
                if (changedType != null && changedType != definition.ItemType)
                {
                    definition.ItemType = changedType;
                    definition.Initialize(definition.ItemType);
                }
            }

            UpdateDefinitionFromConfiguration(element, definition);
        }
Example #3
0
        public void Configuration_CanRemove_Editable_FromDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Remove(new ContainableElement {
                Name = "Text"
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableFreeTextAreaAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(0));
        }
Example #4
0
        private LogEvent CreateEvent(DefinitionElement definition, Timestamp timestamp, LogElement element)
        {
            var logEvent = new LogEvent(definition.Category, element);

            foreach (string key in definition.GetMetadataKeys())
            {
                string regex;
                if (definition.Metadata.TryGetValue(key, out regex))
                {
                    List <string> matches;
                    if (StringHelper.TryGetMatch(element.LogMessage, regex, out matches))
                    {
                        logEvent.AddMetadata(key, matches);
                    }
                }
                if (!String.IsNullOrEmpty(timestamp.Pattern) && !String.IsNullOrEmpty(timestamp.Format))
                {
                    List <string> rawTimestamp;
                    if (StringHelper.TryGetMatch(element.LogMessage, timestamp.Pattern, out rawTimestamp))
                    {
                        var timestampObject = DateTime.ParseExact(rawTimestamp.ElementAt(0), timestamp.Format, CultureInfo.InvariantCulture);
                        logEvent.Timestamp = timestampObject;
                    }
                }
            }
            return(logEvent);
        }
Example #5
0
        public void Configuration_CanAdd_Editable_ToDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Add(new ContainableElement {
                Name = "X", Type = typeof(EditableCheckBoxAttribute).AssemblyQualifiedName
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableCheckBoxAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(1));
        }
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as ItemComponent;

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

                base.CopyTo(dest);
                if (LinkIdElement != null)
                {
                    dest.LinkIdElement = (Hl7.Fhir.Model.FhirString)LinkIdElement.DeepCopy();
                }
                if (DefinitionElement != null)
                {
                    dest.DefinitionElement = (Hl7.Fhir.Model.FhirUri)DefinitionElement.DeepCopy();
                }
                if (TextElement != null)
                {
                    dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy();
                }
                if (Answer != null)
                {
                    dest.Answer = new List <Hl7.Fhir.Model.QuestionnaireResponse.AnswerComponent>(Answer.DeepCopy());
                }
                if (Item != null)
                {
                    dest.Item = new List <Hl7.Fhir.Model.QuestionnaireResponse.ItemComponent>(Item.DeepCopy());
                }
                return(dest);
            }
Example #7
0
        private void UpdateDefinitionFromConfiguration(DefinitionElement element, ItemDefinition definition)
        {
            definition.DefaultContainerName = element.DefaultContainerName ?? config.Definitions.DefaultContainerName;
            definition.SortOrder            = element.SortOrder ?? definition.SortOrder;
            definition.Title     = element.Title ?? definition.Title;
            definition.ToolTip   = element.ToolTip ?? definition.ToolTip;
            definition.IsDefined = true;

            foreach (ContainableElement editable in element.Editables.AllElements)
            {
                AddContainable(definition, editable);
            }
            foreach (ContainableElement editable in element.Editables.RemovedElements)
            {
                RemoveContainable(definition, editable);
            }
            foreach (ContainableElement container in element.Containers.AllElements)
            {
                AddContainable(definition, container);
            }
            foreach (ContainableElement container in element.Containers.RemovedElements)
            {
                RemoveContainable(definition, container);
            }
        }
Example #8
0
 public bool Equals(DefinitionElement other)
 {
     if (ReferenceEquals(null, other))
         return false;
     if (ReferenceEquals(this, other))
         return true;
     return Equals(other.Key, Key) && Equals(other.Value, Value);
 }
Example #9
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MessageHeader;

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

            base.CopyTo(dest);
            if (Event != null)
            {
                dest.Event = (Hl7.Fhir.Model.Element)Event.DeepCopy();
            }
            if (Destination != null)
            {
                dest.Destination = new List <Hl7.Fhir.Model.MessageHeader.MessageDestinationComponent>(Destination.DeepCopy());
            }
            if (Sender != null)
            {
                dest.Sender = (Hl7.Fhir.Model.ResourceReference)Sender.DeepCopy();
            }
            if (Enterer != null)
            {
                dest.Enterer = (Hl7.Fhir.Model.ResourceReference)Enterer.DeepCopy();
            }
            if (Author != null)
            {
                dest.Author = (Hl7.Fhir.Model.ResourceReference)Author.DeepCopy();
            }
            if (Source != null)
            {
                dest.Source = (Hl7.Fhir.Model.MessageHeader.MessageSourceComponent)Source.DeepCopy();
            }
            if (Responsible != null)
            {
                dest.Responsible = (Hl7.Fhir.Model.ResourceReference)Responsible.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = (Hl7.Fhir.Model.CodeableConcept)Reason.DeepCopy();
            }
            if (Response != null)
            {
                dest.Response = (Hl7.Fhir.Model.MessageHeader.ResponseComponent)Response.DeepCopy();
            }
            if (Focus != null)
            {
                dest.Focus = new List <Hl7.Fhir.Model.ResourceReference>(Focus.DeepCopy());
            }
            if (DefinitionElement != null)
            {
                dest.DefinitionElement = (Hl7.Fhir.Model.Canonical)DefinitionElement.DeepCopy();
            }
            return(dest);
        }
Example #10
0
        public override void DrawContent()
        {
            DefinitionElement definitionList = new DefinitionElement(1);

            definitionList.Draw("AssemblyQualifiedName", this.type.AssemblyQualifiedName);
            definitionList.Draw("FullName", this.type.FullName);
            definitionList.Draw("Namespace", this.type.Namespace);
            definitionList.Draw("Attributes", this.type.Attributes.ToString());
            var typeBaseType = this.type.BaseType;

            if (typeBaseType != null)
            {
                definitionList.Draw("BaseType", typeBaseType.Name);
            }
            definitionList.Draw("GUID", this.type.GUID.ToString());
            definitionList.Draw("HasElementType", this.type.HasElementType.ToString());
            definitionList.Draw("IsAbstract", this.type.IsAbstract.ToString());
            definitionList.Draw("IsAnsiClass", this.type.IsAnsiClass.ToString());
            definitionList.Draw("IsArray", this.type.IsArray.ToString());
            definitionList.Draw("IsAutoClass", this.type.IsAutoClass.ToString());
            definitionList.Draw("IsAutoLayout", this.type.IsAutoLayout.ToString());
            definitionList.Draw("IsByRef", this.type.IsByRef.ToString());
            definitionList.Draw("IsClass", this.type.IsClass.ToString());
            definitionList.Draw("IsCOMObject", this.type.IsCOMObject.ToString());
            definitionList.Draw("IsContextful", this.type.IsContextful.ToString());
            definitionList.Draw("IsEnum", this.type.IsEnum.ToString());
            definitionList.Draw("IsExplicitLayout", this.type.IsExplicitLayout.ToString());
            definitionList.Draw("IsGenericParameter", this.type.IsGenericParameter.ToString());
            definitionList.Draw("IsGenericTypeDefinition", this.type.IsGenericTypeDefinition.ToString());
            definitionList.Draw("IsImport", this.type.IsImport.ToString());
            definitionList.Draw("IsInterface", this.type.IsInterface.ToString());
            definitionList.Draw("IsLayoutSequential", this.type.IsLayoutSequential.ToString());
            definitionList.Draw("IsMarshalByRef", this.type.IsMarshalByRef.ToString());
            definitionList.Draw("IsNested", this.type.IsNested.ToString());
            definitionList.Draw("IsNestedAssembly", this.type.IsNestedAssembly.ToString());
            definitionList.Draw("IsNestedPrivate", this.type.IsNestedPrivate.ToString());
            definitionList.Draw("IsNestedPublic", this.type.IsNestedPublic.ToString());
            definitionList.Draw("IsNestedPublic", this.type.IsNestedPublic.ToString());
            definitionList.Draw("IsPointer", this.type.IsPointer.ToString());
            definitionList.Draw("IsPrimitive", this.type.IsPrimitive.ToString());
            definitionList.Draw("IsPublic", this.type.IsPublic.ToString());
            definitionList.Draw("IsSealed", this.type.IsSealed.ToString());
            definitionList.Draw("IsSerializable", this.type.IsSerializable.ToString());
            definitionList.Draw("IsUnicodeClass", this.type.IsUnicodeClass.ToString());
            definitionList.Draw("IsVisible", this.type.IsVisible.ToString());
            definitionList.Draw("MemberType", this.type.MemberType.ToString());
            definitionList.Draw("Module", this.type.Module.Name);
            definitionList.Draw("Namespace", this.type.Namespace);
            var typeReflectedType = this.type.ReflectedType;

            if (typeReflectedType != null)
            {
                definitionList.Draw("ReflectedType", typeReflectedType.Name);
            }
        }
Example #11
0
 public bool Equals(DefinitionElement other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Key, Key) && Equals(other.Value, Value));
 }
Example #12
0
        public override void DrawContent()
        {
            DefinitionElement definitionList = new DefinitionElement(1);

            definitionList.Draw("Name", this.module.Name);
            definitionList.Draw("FullyQualifiedName", this.module.FullyQualifiedName);
            definitionList.Draw("ScopeName", this.module.ScopeName);
            definitionList.Draw("ModuleVersionId", this.module.ModuleVersionId.ToString());
            definitionList.Draw("MetadataToken", this.module.MetadataToken.ToString());
            definitionList.Draw("MDStreamVersion", this.module.MDStreamVersion.ToString());
            definitionList.Draw("HashCode", this.module.GetHashCode().ToString());
            definitionList.Draw("IsResource", this.module.IsResource().ToString());
        }
Example #13
0
        public override void DrawContent()
        {
            DefinitionElement definitionList = new DefinitionElement(1);
            var assemblyName = assembly.GetName();

            definitionList.Draw("FullName", assembly.FullName);

            if (assemblyName.Name != null)
            {
                definitionList.Draw("Name", assemblyName.Name);
            }

            if (assemblyName.CodeBase != null)
            {
                definitionList.Draw("CodeBase", assemblyName.CodeBase);
            }

            if (assemblyName.CultureInfo != null)
            {
                definitionList.Draw("CultureInfo", assemblyName.CultureInfo.DisplayName);
            }

            definitionList.Draw("Flags", assemblyName.Flags.ToString());
            definitionList.Draw("HashAlgorithm", assemblyName.HashAlgorithm.ToString());
            definitionList.Draw("ProcessorArchitecture", assemblyName.ProcessorArchitecture.ToString());
            definitionList.Draw("Version", assemblyName.Version.ToString());
            definitionList.Draw("VersionCompatibility", assemblyName.VersionCompatibility.ToString());
            definitionList.Draw("Location", assembly.Location);
            definitionList.Draw("CodeBase", assembly.CodeBase);
            definitionList.Draw("ImageRuntimeVersion", assembly.ImageRuntimeVersion);

            if (assembly.EntryPoint != null)
            {
                definitionList.Draw("EntryPoint Name", assembly.EntryPoint.Name);
            }

            definitionList.Draw("Is GAC?", assembly.GlobalAssemblyCache.ToString());
        }
Example #14
0
        private void UpdateMatchingDefinitions(IEnumerable <ItemDefinition> definitions, DefinitionElement element)
        {
            if (string.IsNullOrEmpty(element.Type))
            {
                return;
            }
            Type itemType = EnsureType <ContentItem>(element.Type);

            foreach (var definition in definitions)
            {
                if (!itemType.IsAssignableFrom(definition.ItemType))
                {
                    continue;
                }

                UpdateDefinitionFromConfiguration(element, definition);
            }
        }
 private LogEvent CreateEvent(DefinitionElement definition, Timestamp timestamp, LogElement element)
 {
     var logEvent = new LogEvent(definition.Category, element);
     foreach (string key in definition.GetMetadataKeys())
     {
         string regex;
         if (definition.Metadata.TryGetValue(key, out regex))
         {
             List<string> matches;
             if (StringHelper.TryGetMatch(element.LogMessage, regex, out matches)){
                 logEvent.AddMetadata(key, matches);
             }
         }
         if (!String.IsNullOrEmpty(timestamp.Pattern) && !String.IsNullOrEmpty(timestamp.Format))
         {
             List<string> rawTimestamp;
             if (StringHelper.TryGetMatch(element.LogMessage, timestamp.Pattern, out rawTimestamp))
             {
                 var timestampObject = DateTime.ParseExact(rawTimestamp.ElementAt(0), timestamp.Format, CultureInfo.InvariantCulture);
                 logEvent.Timestamp = timestampObject;
             }
         }
     }
     return logEvent;
 }
        public async Task <ActionResult <DefinitionElement> > UpdateDefinitionElementAsync(int id, [FromBody] DefinitionElement element)
        {
            var current = await _context.Definitions.GetAsync(id);

            if (current == null)
            {
                return(NotFound());
            }

            if (current.DashboardFolderId == element.DashboardFolderId)
            {
                // not reparenting, adjust positions
                var newPeers = await _context.Definitions.GetAsync(d => d.DashboardFolderId == element.DashboardFolderId);

                PositionAdjuster.AdjustForUpdate(element, newPeers.ToList <ISortable>(), current);
            }
            else
            {
                // we are reparenting, adjust old peer positions
                var oldPeers = await _context.Definitions.GetAsync(d => d.DashboardFolderId == current.DashboardFolderId);

                PositionAdjuster.AdjustForDelete(current, oldPeers.ToList <ISortable>());

                // and new peer positions
                var newPeers = await _context.Definitions.GetAsync(d => d.DashboardFolderId == element.DashboardFolderId);

                PositionAdjuster.AdjustForCreate(element, newPeers.ToList <ISortable>());
            }

            current.UpdateFrom(element);

            _context.Definitions.Update(current);
            await _context.SaveChangesAsync();

            return(current.ToElement());
        }
Example #17
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ChargeItem;

            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 = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (DefinitionElement != null)
            {
                dest.DefinitionElement = new List <Hl7.Fhir.Model.FhirUri>(DefinitionElement.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>)StatusElement.DeepCopy();
            }
            if (PartOf != null)
            {
                dest.PartOf = new List <Hl7.Fhir.Model.ResourceReference>(PartOf.DeepCopy());
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.DataType)Occurrence.DeepCopy();
            }
            if (Participant != null)
            {
                dest.Participant = new List <Hl7.Fhir.Model.ChargeItem.ParticipantComponent>(Participant.DeepCopy());
            }
            if (PerformingOrganization != null)
            {
                dest.PerformingOrganization = (Hl7.Fhir.Model.ResourceReference)PerformingOrganization.DeepCopy();
            }
            if (RequestingOrganization != null)
            {
                dest.RequestingOrganization = (Hl7.Fhir.Model.ResourceReference)RequestingOrganization.DeepCopy();
            }
            if (Quantity != null)
            {
                dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
            }
            if (Bodysite != null)
            {
                dest.Bodysite = new List <Hl7.Fhir.Model.CodeableConcept>(Bodysite.DeepCopy());
            }
            if (FactorOverrideElement != null)
            {
                dest.FactorOverrideElement = (Hl7.Fhir.Model.FhirDecimal)FactorOverrideElement.DeepCopy();
            }
            if (PriceOverride != null)
            {
                dest.PriceOverride = (Hl7.Fhir.Model.Money)PriceOverride.DeepCopy();
            }
            if (OverrideReasonElement != null)
            {
                dest.OverrideReasonElement = (Hl7.Fhir.Model.FhirString)OverrideReasonElement.DeepCopy();
            }
            if (Enterer != null)
            {
                dest.Enterer = (Hl7.Fhir.Model.ResourceReference)Enterer.DeepCopy();
            }
            if (EnteredDateElement != null)
            {
                dest.EnteredDateElement = (Hl7.Fhir.Model.FhirDateTime)EnteredDateElement.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = new List <Hl7.Fhir.Model.CodeableConcept>(Reason.DeepCopy());
            }
            if (Service != null)
            {
                dest.Service = new List <Hl7.Fhir.Model.ResourceReference>(Service.DeepCopy());
            }
            if (Account != null)
            {
                dest.Account = new List <Hl7.Fhir.Model.ResourceReference>(Account.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (SupportingInformation != null)
            {
                dest.SupportingInformation = new List <Hl7.Fhir.Model.ResourceReference>(SupportingInformation.DeepCopy());
            }
            return(dest);
        }