Esempio n. 1
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (RoleElement != null)
                {
                    result.AddRange(RoleElement.Validate());
                }
                if (Type != null)
                {
                    result.AddRange(Type.Validate());
                }
                if (ReferenceElement != null)
                {
                    result.AddRange(ReferenceElement.Validate());
                }
                if (DisplayElement != null)
                {
                    result.AddRange(DisplayElement.Validate());
                }
                if (Agent != null)
                {
                    result.AddRange(Agent.Validate());
                }

                return(result);
            }
Esempio n. 2
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DetectedIssue;

            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.ObservationStatus>)StatusElement.DeepCopy();
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (SeverityElement != null)
            {
                dest.SeverityElement = (Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>)SeverityElement.DeepCopy();
            }
            if (Patient != null)
            {
                dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
            }
            if (Identified != null)
            {
                dest.Identified = (Hl7.Fhir.Model.DataType)Identified.DeepCopy();
            }
            if (Author != null)
            {
                dest.Author = (Hl7.Fhir.Model.ResourceReference)Author.DeepCopy();
            }
            if (Implicated != null)
            {
                dest.Implicated = new List <Hl7.Fhir.Model.ResourceReference>(Implicated.DeepCopy());
            }
            if (Evidence != null)
            {
                dest.Evidence = new List <Hl7.Fhir.Model.DetectedIssue.EvidenceComponent>(Evidence.DeepCopy());
            }
            if (DetailElement != null)
            {
                dest.DetailElement = (Hl7.Fhir.Model.FhirString)DetailElement.DeepCopy();
            }
            if (ReferenceElement != null)
            {
                dest.ReferenceElement = (Hl7.Fhir.Model.FhirUri)ReferenceElement.DeepCopy();
            }
            if (Mitigation != null)
            {
                dest.Mitigation = new List <Hl7.Fhir.Model.DetectedIssue.MitigationComponent>(Mitigation.DeepCopy());
            }
            return(dest);
        }
Esempio n. 3
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ResourceReference;

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

            base.CopyTo(dest);
            if (ReferenceElement != null)
            {
                dest.ReferenceElement = (Hl7.Fhir.Model.FhirString)ReferenceElement.DeepCopy();
            }
            if (TypeElement != null)
            {
                dest.TypeElement = (Hl7.Fhir.Model.FhirUri)TypeElement.DeepCopy();
            }
            if (Identifier != null)
            {
                dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (DisplayElement != null)
            {
                dest.DisplayElement = (Hl7.Fhir.Model.FhirString)DisplayElement.DeepCopy();
            }
            return(dest);
        }
Esempio n. 4
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as EntityComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (RoleElement != null)
                    {
                        dest.RoleElement = (Code <Hl7.Fhir.Model.Provenance.ProvenanceEntityRole>)RoleElement.DeepCopy();
                    }
                    if (Type != null)
                    {
                        dest.Type = (Hl7.Fhir.Model.Coding)Type.DeepCopy();
                    }
                    if (ReferenceElement != null)
                    {
                        dest.ReferenceElement = (Hl7.Fhir.Model.FhirUri)ReferenceElement.DeepCopy();
                    }
                    if (DisplayElement != null)
                    {
                        dest.DisplayElement = (Hl7.Fhir.Model.FhirString)DisplayElement.DeepCopy();
                    }
                    if (Agent != null)
                    {
                        dest.Agent = (Hl7.Fhir.Model.Provenance.AgentComponent)Agent.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
Esempio n. 5
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Expression;

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

            base.CopyTo(dest);
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.Id)NameElement.DeepCopy();
            }
            if (LanguageElement != null)
            {
                dest.LanguageElement = (Hl7.Fhir.Model.Code)LanguageElement.DeepCopy();
            }
            if (ExpressionElement != null)
            {
                dest.ExpressionElement = (Hl7.Fhir.Model.FhirString)ExpressionElement.DeepCopy();
            }
            if (ReferenceElement != null)
            {
                dest.ReferenceElement = (Hl7.Fhir.Model.FhirUri)ReferenceElement.DeepCopy();
            }
            return(dest);
        }
Esempio n. 6
0
        private static ReferenceElement[] CreateReferenceElements(Collection <AssemblyReference> references)
        {
            if (references.Count > 0)
            {
                var elements = new ReferenceElement[references.Count];

                for (int i = 0; i < references.Count; i++)
                {
                    var element = new ReferenceElement()
                    {
                        Assembly = references[i].AssemblyName
                    };

                    if (references[i].Url != null)
                    {
                        element.Url = references[i].Url.ToString();
                    }

                    elements[i] = element;
                }

                return(elements);
            }

            return(null);
        }
        public static void Run()
        {
            // ExStart:CreateStructureElements
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // Create Pdf Document
            Document document = new Document();

            // Get Content for work with TaggedPdf
            ITaggedContent taggedContent = document.TaggedContent;

            // Set Title and Language for Documnet
            taggedContent.SetTitle("Tagged Pdf Document");
            taggedContent.SetLanguage("en-US");

            // Create Grouping Elements
            PartElement       partElement       = taggedContent.CreatePartElement();
            ArtElement        artElement        = taggedContent.CreateArtElement();
            SectElement       sectElement       = taggedContent.CreateSectElement();
            DivElement        divElement        = taggedContent.CreateDivElement();
            BlockQuoteElement blockQuoteElement = taggedContent.CreateBlockQuoteElement();
            CaptionElement    captionElement    = taggedContent.CreateCaptionElement();
            TOCElement        tocElement        = taggedContent.CreateTOCElement();
            TOCIElement       tociElement       = taggedContent.CreateTOCIElement();
            IndexElement      indexElement      = taggedContent.CreateIndexElement();
            NonStructElement  nonStructElement  = taggedContent.CreateNonStructElement();
            PrivateElement    privateElement    = taggedContent.CreatePrivateElement();

            // Create Text Block-Level Structure Elements
            ParagraphElement paragraphElement = taggedContent.CreateParagraphElement();
            HeaderElement    headerElement    = taggedContent.CreateHeaderElement();
            HeaderElement    h1Element        = taggedContent.CreateHeaderElement(1);

            // Create Text Inline-Level Structure Elements
            SpanElement  spanElement  = taggedContent.CreateSpanElement();
            QuoteElement quoteElement = taggedContent.CreateQuoteElement();
            NoteElement  noteElement  = taggedContent.CreateNoteElement();

            // Create Illustration Structure Elements
            FigureElement  figureElement  = taggedContent.CreateFigureElement();
            FormulaElement formulaElement = taggedContent.CreateFormulaElement();

            // Methods are under development
            ListElement      listElement      = taggedContent.CreateListElement();
            TableElement     tableElement     = taggedContent.CreateTableElement();
            ReferenceElement referenceElement = taggedContent.CreateReferenceElement();
            BibEntryElement  bibEntryElement  = taggedContent.CreateBibEntryElement();
            CodeElement      codeElement      = taggedContent.CreateCodeElement();
            LinkElement      linkElement      = taggedContent.CreateLinkElement();
            AnnotElement     annotElement     = taggedContent.CreateAnnotElement();
            RubyElement      rubyElement      = taggedContent.CreateRubyElement();
            WarichuElement   warichuElement   = taggedContent.CreateWarichuElement();
            FormElement      formElement      = taggedContent.CreateFormElement();

            // Save Tagged Pdf Document
            document.Save(dataDir + "StructureElements.pdf");
            // ExEnd:CreateStructureElements
        }
Esempio n. 8
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Contraindication;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Patient != null)
                {
                    dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
                }
                if (Category != null)
                {
                    dest.Category = (Hl7.Fhir.Model.CodeableConcept)Category.DeepCopy();
                }
                if (SeverityElement != null)
                {
                    dest.SeverityElement = (Hl7.Fhir.Model.Code)SeverityElement.DeepCopy();
                }
                if (Implicated != null)
                {
                    dest.Implicated = new List <Hl7.Fhir.Model.ResourceReference>(Implicated.DeepCopy());
                }
                if (DetailElement != null)
                {
                    dest.DetailElement = (Hl7.Fhir.Model.FhirString)DetailElement.DeepCopy();
                }
                if (DateElement != null)
                {
                    dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
                }
                if (Author != null)
                {
                    dest.Author = (Hl7.Fhir.Model.ResourceReference)Author.DeepCopy();
                }
                if (Identifier != null)
                {
                    dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
                }
                if (ReferenceElement != null)
                {
                    dest.ReferenceElement = (Hl7.Fhir.Model.FhirUri)ReferenceElement.DeepCopy();
                }
                if (Mitigation != null)
                {
                    dest.Mitigation = new List <Hl7.Fhir.Model.Contraindication.ContraindicationMitigationComponent>(Mitigation.DeepCopy());
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Esempio n. 9
0
        private static ReferenceElement GetSettings(string areaName, string name)
        {
            var section = ConfigurationManager.GetSection(areaName);
            ReferenceElement settings = section.References[name];

            if (settings == null)
            {
                throw new WebResourceException(string.Format("Web resource name {0} not found", name));
            }
            return(settings);
        }
Esempio n. 10
0
        private void ProcessReferenceTag(XmlElement placeholderElement, string value)
        {
            var xml    = this.TemplateDocument.XmlDocument;
            var refEle = new ReferenceElement(xml, value);
            var rEle   = xml.CreateElement("w:r", WordMLNamespaceManager.WNamespace);
            var tEle   = xml.CreateElement("w:t", WordMLNamespaceManager.WNamespace);

            rEle.AppendChild(tEle);
            tEle.AppendChild(refEle);
            placeholderElement.ParentNode.ReplaceChild(rEle, placeholderElement);
        }
Esempio n. 11
0
        public static IHtmlString ExternalResources(this HtmlHelper htmlHelper, string areaName, string name, RouteValueDictionary htmlAttributes, string baseUri)
        {
            ReferenceElement settings = GetSettings(areaName, name);

            // get distinct show if / hide if conditions and group into files
            IDictionary <Condition, IList <FileInfoElement> > conditions = new Dictionary <Condition, IList <FileInfoElement> >(new ConditionComparer());

            foreach (FileInfoElement fileInfo in settings.Files)
            {
                Condition condition = new Condition {
                    If = fileInfo.If
                };
                if (conditions.ContainsKey(condition))
                {
                    conditions[condition].Add(fileInfo);
                }
                else
                {
                    conditions.Add(condition, new List <FileInfoElement> {
                        fileInfo
                    });
                }
            }

            string attributes = CreateAttributeList(htmlAttributes);

            switch (settings.MimeType)
            {
            case "text/x-javascript":
            case "text/javascript":
            case "text/ecmascript":
            {
                ReferenceFomatter formatter = (filename, mimeType, attribs) => string.Format("<script src=\"{0}\" type=\"{1}\"{2}></script>", filename, settings.MimeType, attribs);
                return(OutputReferences(htmlHelper.ViewContext, conditions, settings, attributes, formatter, areaName, baseUri));
            }

            case "text/css":
            {
                ReferenceFomatter formatter = (filename, mimeType, attribs) => string.Format("<link rel=\"Stylesheet\" href=\"{0}\" type=\"{1}\"{2} />", filename, settings.MimeType, attribs);
                return(OutputReferences(htmlHelper.ViewContext, conditions, settings, attributes, formatter, areaName, baseUri));
            }

            // TODO: Decide any other reference types that we want to handle e.g. images
            default:
            {
                return(new HtmlString(string.Empty));
            }
            }
        }
        /// <summary>
        /// Measure adorner.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            Debug.Assert(child != null, "_child should not be null");

            if (ReferenceElement != null && AdornedElement != null &&
                AdornedElement.IsMeasureValid &&
                !AreClose(ReferenceElement.DesiredSize, AdornedElement.DesiredSize))
            {
                ReferenceElement.InvalidateMeasure();
            }

            child.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));

            return(child.DesiredSize);
        }
Esempio n. 13
0
        private static void ProcessPlaceHolderElement(XmlNode placeholder, ReferenceElement ie)
        {
            var placeholderType = placeholder.Attributes[OdfDocument.TextPlaceholderTypeAttribute]
                                  .InnerText.Trim().ToLowerInvariant();

            ;
            switch (placeholderType)
            {
            case "text":
                placeholder.ParentNode.ReplaceChild(ie, placeholder);
                break;

            default:
                throw new SyntaxErrorException("Unsupported placeholder type: " + placeholderType);
            }
        }
Esempio n. 14
0
        private static void ProcessIdentifierTag(OdfContentXmlDocument xml, XmlNode placeholder, string value)
        {
            Debug.Assert(xml != null);
            Debug.Assert(placeholder != null);
            Debug.Assert(!string.IsNullOrEmpty(value));

            var ie = new ReferenceElement(xml, value);

            if (placeholder.Name == OdfDocument.TextPlaceholderElement)
            {
                ProcessPlaceHolderElement(placeholder, ie);
            }
            else
            {
                placeholder.ParentNode.ReplaceChild(ie, placeholder);
            }
        }
        private static ReferenceElement setReferenceElement(UANode node)
        {
            //ReferenceElement
            //  -> Value

            ReferenceElement refEle = new ReferenceElement();

            foreach (Reference _ref in node.References)
            {
                if (_ref.ReferenceType != "HasTypeDefinition")
                {
                    UAVariable var = (UAVariable)findNode(_ref.Value);
                    string     val = var.Value.InnerText;
                    //convert String into Reference
                    refEle.value = createReference(val);
                }
            }

            return(refEle);
        }
Esempio n. 16
0
        ReferenceElement IReferenceParser.Parse(string raw)
        {
            if (!raw.StartsWith(GuidToken, StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException();
            }

            ReferenceElement reference = new ReferenceElement();

            //   *\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\system32\stdole2.tlb#OLE Automation

            raw = raw.Substring(3);

            string[] parts = raw.Split(PartSplitChar);
            if (parts.Length == 5)
            {
                reference.Guid     = Guid.Parse(parts[0]);
                reference.Version  = parts[1];
                reference.Reserved = parts[2];
                reference.FileName = parts[3];

                // The file name sometimes features a backslash, which we remove and store in a separate property.
                if (char.IsNumber(reference.FileName.Last()))
                {
                    int iSlash = reference.FileName.LastIndexOf('\\');

                    reference.FileNameTrailer = reference.FileName;
                    reference.FileName        = reference.FileName.Substring(0, iSlash);
                    reference.FileNameTrailer = reference.FileNameTrailer.Remove(0, iSlash);
                }

                reference.Name = parts[4];
            }

            return(reference);
        }
Esempio n. 17
0
        private static void ProcessIdentifierTag(XmlDocument xml, XmlNode placeholder, string value)
        {
            Debug.Assert(xml != null);
            Debug.Assert(placeholder != null);
            Debug.Assert(!string.IsNullOrEmpty(value));

            var ie = new ReferenceElement(xml, value);

            if (placeholder.Name == TextPlaceholderElement)
            {
                ProcessPlaceHolderElement(placeholder, ie);
            }
            else
            {
                placeholder.ParentNode.ReplaceChild(ie, placeholder);
            }
        }
        public static ISubmodelElement ToSubmodelElement(this SubmodelElementType_V2_0 envSubmodelElement, List <IConceptDescription> conceptDescriptions)
        {
            if (envSubmodelElement == null)
            {
                return(null);
            }

            ModelType modelType = envSubmodelElement.ModelType;

            if (modelType == null)
            {
                return(null);
            }

            SubmodelElement submodelElement = null;

            if (modelType == ModelType.Property && envSubmodelElement is Property_V2_0 castedProperty)
            {
                DataObjectType dataObjectType;
                if (string.IsNullOrEmpty(castedProperty.ValueType))
                {
                    dataObjectType = DataObjectType.None;
                }
                else if (!DataObjectType.TryParse(castedProperty.ValueType, out dataObjectType))
                {
                    return(null);
                }

                Property property = new Property(new DataType(dataObjectType))
                {
                    Value   = castedProperty.Value,
                    ValueId = castedProperty.ValueId?.ToReference_V2_0()
                };

                submodelElement = property;
            }
            else if (modelType == ModelType.MultiLanguageProperty && envSubmodelElement is MultiLanguageProperty_V2_0 castedMultiLanguageProperty)
            {
                MultiLanguageProperty multiLanguageProperty = new MultiLanguageProperty
                {
                    Value   = castedMultiLanguageProperty.Value,
                    ValueId = castedMultiLanguageProperty.ValueId?.ToReference_V2_0()
                };

                submodelElement = multiLanguageProperty;
            }
            else if (modelType == ModelType.Range && envSubmodelElement is Range_V2_0 castedRange)
            {
                if (!DataObjectType.TryParse(castedRange.ValueType, out DataObjectType dataObjectType))
                {
                    return(null);
                }

                Range range = new Range()
                {
                    Min       = new ElementValue(castedRange.Min, new DataType(dataObjectType)),
                    Max       = new ElementValue(castedRange.Max, new DataType(dataObjectType)),
                    ValueType = new DataType(dataObjectType)
                };

                submodelElement = range;
            }
            else if (modelType == ModelType.File && envSubmodelElement is File_V2_0 castedFile)
            {
                File file = new File
                {
                    MimeType = castedFile.MimeType,
                    Value    = castedFile.Value
                };

                submodelElement = file;
            }
            else if (modelType == ModelType.Blob && envSubmodelElement is Blob_V2_0 castedBlob)
            {
                Blob blob = new Blob
                {
                    MimeType = castedBlob.MimeType,
                    Value    = Convert.FromBase64String(castedBlob.Value)
                };

                submodelElement = blob;
            }
            else if (modelType == ModelType.RelationshipElement && envSubmodelElement is RelationshipElement_V2_0 castedRelationshipElement)
            {
                RelationshipElement relationshipElement = new RelationshipElement
                {
                    First  = castedRelationshipElement.First?.ToReference_V2_0 <IReferable>(),
                    Second = castedRelationshipElement.Second?.ToReference_V2_0 <IReferable>()
                };

                submodelElement = relationshipElement;
            }
            else if (modelType == ModelType.AnnotatedRelationshipElement && envSubmodelElement is AnnotatedRelationshipElement_V2_0 castedAnnotatedRelationshipElement)
            {
                AnnotatedRelationshipElement annotatedRelationshipElement = new AnnotatedRelationshipElement()
                {
                    First      = castedAnnotatedRelationshipElement.First?.ToReference_V2_0 <IReferable>(),
                    Second     = castedAnnotatedRelationshipElement.Second?.ToReference_V2_0 <IReferable>(),
                    Annotation = castedAnnotatedRelationshipElement.Annotation?.ToReference_V2_0 <ISubmodelElement>()
                };

                submodelElement = annotatedRelationshipElement;
            }
            else if (modelType == ModelType.ReferenceElement && envSubmodelElement is ReferenceElement_V2_0 castedReferenceElement)
            {
                ReferenceElement referenceElement = new ReferenceElement
                {
                    Value = castedReferenceElement.Value?.ToReference_V2_0()
                };

                submodelElement = referenceElement;
            }
            else if (modelType == ModelType.Event && envSubmodelElement is Event_V2_0 castedEvent)
            {
                Event eventable = new Event();

                submodelElement = eventable;
            }
            else if (modelType == ModelType.BasicEvent && envSubmodelElement is BasicEvent_V2_0 castedBasicEvent)
            {
                BasicEvent basicEvent = new BasicEvent()
                {
                    Observed = castedBasicEvent.Observed.ToReference_V2_0 <IReferable>()
                };

                submodelElement = basicEvent;
            }
            else if (modelType == ModelType.Entity && envSubmodelElement is Entity_V2_0 castedEntity)
            {
                Entity entity = new Entity()
                {
                    EntityType = (EntityType)Enum.Parse(typeof(EntityType), castedEntity.EntityType.ToString()),
                    Asset      = castedEntity.AssetReference.ToReference_V2_0 <IAsset>()
                };

                var statements = castedEntity.Statements?.ConvertAll(c => c.submodelElement.ToSubmodelElement(conceptDescriptions));
                if (statements?.Count > 0)
                {
                    foreach (var element in statements)
                    {
                        entity.Statements.Add(element);
                    }
                }

                submodelElement = entity;
            }
            else if (modelType == ModelType.Operation && envSubmodelElement is Operation_V2_0 castedOperation)
            {
                Operation operation = new Operation
                {
                    InputVariables    = new OperationVariableSet(),
                    OutputVariables   = new OperationVariableSet(),
                    InOutputVariables = new OperationVariableSet()
                };

                var operationInElements = castedOperation.InputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions));
                if (operationInElements?.Count > 0)
                {
                    foreach (var element in operationInElements)
                    {
                        operation.InputVariables.Add(element);
                    }
                }

                var operationOutElements = castedOperation.OutputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions));
                if (operationOutElements?.Count > 0)
                {
                    foreach (var element in operationOutElements)
                    {
                        operation.OutputVariables.Add(element);
                    }
                }

                var operationInOutElements = castedOperation.InOutputVariables?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions));
                if (operationInOutElements?.Count > 0)
                {
                    foreach (var element in operationInOutElements)
                    {
                        operation.InOutputVariables.Add(element);
                    }
                }

                submodelElement = operation;
            }
            else if (modelType == ModelType.SubmodelElementCollection && envSubmodelElement is SubmodelElementCollection_V2_0 castedSubmodelElementCollection)
            {
                SubmodelElementCollection submodelElementCollection = new SubmodelElementCollection();

                if (castedSubmodelElementCollection.Value?.Count > 0)
                {
                    submodelElementCollection.Value = new ElementContainer <ISubmodelElement>();
                    List <ISubmodelElement> smElements = castedSubmodelElementCollection.Value?.ConvertAll(c => c.submodelElement?.ToSubmodelElement(conceptDescriptions));
                    foreach (var smElement in smElements)
                    {
                        submodelElementCollection.Value.Add(smElement);
                    }
                }

                submodelElement = submodelElementCollection;
            }


            if (submodelElement == null)
            {
                return(null);
            }

            submodelElement.Category    = envSubmodelElement.Category;
            submodelElement.Description = envSubmodelElement.Description;
            submodelElement.IdShort     = envSubmodelElement.IdShort;
            submodelElement.Kind        = envSubmodelElement.Kind;
            submodelElement.SemanticId  = envSubmodelElement.SemanticId?.ToReference_V2_0();
            submodelElement.Parent      = string.IsNullOrEmpty(envSubmodelElement.Parent) ? null :
                                          new Reference(
                new Key(KeyElements.AssetAdministrationShell, KeyType.IRI, envSubmodelElement.Parent, true));
            submodelElement.Constraints = null;

            string semanticId = envSubmodelElement.SemanticId?.Keys?.FirstOrDefault()?.Value;

            if (!string.IsNullOrEmpty(semanticId))
            {
                submodelElement.ConceptDescription =
                    conceptDescriptions.Find(f => f.Identification.Id == semanticId);
                submodelElement.EmbeddedDataSpecifications = submodelElement.ConceptDescription?.EmbeddedDataSpecifications;
            }

            return(submodelElement);
        }
Esempio n. 19
0
        private static IHtmlString OutputReferences(ViewContext viewContext, IDictionary <Condition, IList <FileInfoElement> > conditions, ReferenceElement settings, string attributes, ReferenceFomatter formatter, string areaName, string baseUrl)
        {
            var           section = ConfigurationManager.GetSection(areaName);
            StringBuilder sb      = new StringBuilder();

            foreach (KeyValuePair <Condition, IList <FileInfoElement> > keyValuePair in conditions)
            {
                Condition condition           = keyValuePair.Key;
                IList <FileInfoElement> files = keyValuePair.Value;

                // we need to wrap these files in conditional comments if the condition is anything but Action = Show with empty if (i.e. show to everything)
                bool conditionalCommentRequired = !string.IsNullOrEmpty(condition.If);

                if (conditionalCommentRequired)
                {
                    sb.AppendFormat("<!--[if {0}]>", condition.If);
                    sb.AppendLine();
                }

                switch (section.Mode)
                {
                case Mode.Release:
                    UrlHelper urlHelper = new UrlHelper(viewContext.RequestContext);

                    //VirtualPathData virtualPathData = RouteTable.Routes.GetVirtualPath(viewContext.RequestContext,
                    //    new RouteValueDictionary(new
                    //    {
                    //        area = viewContext.RouteData.Values["area"],
                    //        controller = "WebResource",
                    //        action = "Index",
                    //        name = settings.Name,
                    //        version = section.Version,
                    //        condition = condition.If
                    //    }));
                    string url = urlHelper.Action("Index", new
                    {
                        area       = areaName,
                        controller = "WebResource",
                        action     = "Index",
                        name       = settings.Name,
                        version    = section.Version,
                        condition  = condition.If
                    });
                    if (!string.IsNullOrEmpty(baseUrl))
                    {
                        url = Kooboo.Web.Url.UrlUtility.ToHttpAbsolute(baseUrl, url);
                    }
                    sb.AppendLine(formatter.Invoke(url, settings.MimeType, attributes));
                    break;

                case Mode.Debug:
                    foreach (FileInfoElement fileInfo in files)
                    {
                        string fileUrl = VirtualPathUtility.ToAbsolute(fileInfo.Filename);
                        if (!string.IsNullOrEmpty(baseUrl))
                        {
                            fileUrl = Kooboo.Web.Url.UrlUtility.ToHttpAbsolute(baseUrl, fileUrl);
                        }
                        sb.AppendLine(formatter.Invoke(fileUrl, settings.MimeType, attributes));
                    }
                    break;
                }

                if (conditionalCommentRequired)
                {
                    sb.AppendFormat("<![endif]-->");
                    sb.AppendLine();
                }
            }

            return(new HtmlString(sb.ToString()));
        }
Esempio n. 20
0
 string IReferenceParser.Parse(ReferenceElement reference)
 {
     return(reference.ToString());
 }
        public static ISubmodelElement ToSubmodelElement(this SubmodelElementType_V1_0 envSubmodelElement, List <IConceptDescription> conceptDescriptions)
        {
            if (envSubmodelElement == null)
            {
                logger.Warn("EnvironmentSubmodelElement is null");
                return(null);
            }

            ModelType modelType = envSubmodelElement.ModelType;

            if (modelType == null)
            {
                logger.Warn("ModelType of Element " + envSubmodelElement.IdShort + " is null");
                return(null);
            }
            SubmodelElement submodelElement = null;

            if (modelType == ModelType.Property && envSubmodelElement is Property_V1_0 castedProperty)
            {
                Property property;
                if (DataObjectType.TryParse(castedProperty.ValueType, out DataObjectType dataObjectType))
                {
                    property = new Property(new DataType(dataObjectType));
                }
                else
                {
                    logger.Warn("Unable to parse ValueType of Property " + castedProperty.IdShort + " - ValueType: " + castedProperty.ValueType);
                    property = new Property();
                }

                property.Value   = castedProperty.Value;
                property.ValueId = castedProperty.ValueId?.ToReference_V1_0();

                submodelElement = property;
            }
            else if (modelType == ModelType.File && envSubmodelElement is File_V1_0 castedFile)
            {
                File file = new File
                {
                    MimeType = castedFile.MimeType,
                    Value    = castedFile.Value
                };

                submodelElement = file;
            }
            else if (modelType == ModelType.Blob && envSubmodelElement is Blob_V1_0 castedBlob)
            {
                Blob blob = new Blob
                {
                    MimeType = castedBlob.MimeType,
                    Value    = Convert.FromBase64String(castedBlob.Value)
                };

                submodelElement = blob;
            }
            else if (modelType == ModelType.RelationshipElement && envSubmodelElement is RelationshipElement_V1_0 castedRelationshipElement)
            {
                RelationshipElement relationshipElement = new RelationshipElement
                {
                    First  = castedRelationshipElement.First?.ToReference_V1_0 <IReferable>(),
                    Second = castedRelationshipElement.Second?.ToReference_V1_0 <IReferable>()
                };

                submodelElement = relationshipElement;
            }
            else if (modelType == ModelType.ReferenceElement && envSubmodelElement is ReferenceElement_V1_0 castedReferenceElement)
            {
                ReferenceElement referenceElement = new ReferenceElement
                {
                    Value = castedReferenceElement.Value?.ToReference_V1_0()
                };

                submodelElement = referenceElement;
            }
            else if (modelType == ModelType.Event && envSubmodelElement is Event_V1_0 castedEvent)
            {
                Event eventable = new Event();

                submodelElement = eventable;
            }
            else if (modelType == ModelType.Operation && envSubmodelElement is Operation_V1_0 castedOperation)
            {
                Operation operation = new Operation
                {
                    InputVariables  = new OperationVariableSet(),
                    OutputVariables = new OperationVariableSet()
                };

                var operationInElements = castedOperation.In?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions));
                if (operationInElements?.Count > 0)
                {
                    foreach (var element in operationInElements)
                    {
                        operation.InputVariables.Add(element);
                    }
                }

                var operationOutElements = castedOperation.Out?.ConvertAll(c => c.Value?.submodelElement?.ToSubmodelElement(conceptDescriptions));
                if (operationOutElements?.Count > 0)
                {
                    foreach (var element in operationOutElements)
                    {
                        operation.OutputVariables.Add(element);
                    }
                }

                submodelElement = operation;
            }
            else if (modelType == ModelType.SubmodelElementCollection && envSubmodelElement is SubmodelElementCollection_V1_0 castedSubmodelElementCollection)
            {
                SubmodelElementCollection submodelElementCollection = new SubmodelElementCollection();

                if (castedSubmodelElementCollection.Value?.Count > 0)
                {
                    submodelElementCollection.Value = new ElementContainer <ISubmodelElement>();
                    List <ISubmodelElement> smElements = castedSubmodelElementCollection.Value?.ConvertAll(c => c.submodelElement?.ToSubmodelElement(conceptDescriptions));
                    foreach (var smElement in smElements)
                    {
                        submodelElementCollection.Value.Add(smElement);
                    }
                }

                submodelElement = submodelElementCollection;
            }


            if (submodelElement == null)
            {
                logger.Warn("SubmodelElement " + envSubmodelElement.IdShort + " is still null");
                return(null);
            }

            submodelElement.Category    = envSubmodelElement.Category;
            submodelElement.Description = envSubmodelElement.Description;
            submodelElement.IdShort     = envSubmodelElement.IdShort;
            submodelElement.Kind        = envSubmodelElement.Kind;
            submodelElement.SemanticId  = envSubmodelElement.SemanticId?.ToReference_V1_0();
            submodelElement.Constraints = null;

            string semanticId = envSubmodelElement.SemanticId?.Keys?.FirstOrDefault()?.Value;

            if (!string.IsNullOrEmpty(semanticId))
            {
                submodelElement.ConceptDescription =
                    conceptDescriptions.Find(f => f.Identification.Id == semanticId);
                submodelElement.EmbeddedDataSpecifications = submodelElement.ConceptDescription?.EmbeddedDataSpecifications;
            }

            return(submodelElement);
        }
        public void Index(string name, string version, string condition)
        {
            HttpResponseBase response = Response;

            WebResourcesSection section = ConfigurationManager.GetSection(Kooboo.Common.Web.AreaHelpers.GetAreaName(this.RouteData));

            if (section == null)
            {
                throw new HttpException(500, "Unable to find the web resource configuration.");
            }

            ReferenceElement settings = section.References[name];

            if (settings == null)
            {
                throw new HttpException(500, string.Format("Unable to find any matching web resource settings for {0}.", name));
            }

            Condition conditionInfo = new Condition
            {
                If = condition ?? string.Empty
            };

            // filter the files based on the condition (Action / If) passed in
            IList <FileInfoElement> files = new List <FileInfoElement>();

            foreach (FileInfoElement fileInfo in settings.Files)
            {
                if (fileInfo.If.Equals(conditionInfo.If))
                {
                    files.Add(fileInfo);
                }
            }

            // Ooutput Type
            response.ContentType = settings.MimeType;
            Stream output = response.OutputStream;

            // Compress
            if (section.Compress)
            {
                string acceptEncoding = Request.Headers["Accept-Encoding"];

                if (!string.IsNullOrEmpty(acceptEncoding))
                {
                    acceptEncoding = acceptEncoding.ToLowerInvariant();

                    if (acceptEncoding.Contains("gzip"))
                    {
                        response.AddHeader("Content-encoding", "gzip");
                        output = new GZipStream(output, CompressionMode.Compress);
                    }
                    else if (acceptEncoding.Contains("deflate"))
                    {
                        response.AddHeader("Content-encoding", "deflate");
                        output = new DeflateStream(output, CompressionMode.Compress);
                    }
                }
            }

            // Combine
            using (StreamWriter sw = new StreamWriter(output))
            {
                foreach (FileInfoElement fileInfo in files)
                {
                    string content;
                    var    dynamicResource = DynamicClientResourceFactory.Default.ResolveProvider(fileInfo.Filename);

                    if (dynamicResource != null)
                    {
                        content = dynamicResource.Parse(fileInfo.Filename);
                    }
                    else
                    {
                        content = System.IO.File.ReadAllText(Server.MapPath(fileInfo.Filename));
                    }
                    switch (settings.MimeType)
                    {
                    case "text/css":
                        content = CSSMinify.Minify(Url, fileInfo.Filename, Request.Url.AbsolutePath, content);
                        break;

                    case "text/x-javascript":
                    case "text/javascript":
                    case "text/ecmascript":
                        if (section.Compact && fileInfo.Compact)
                        {
                            content = JSMinify.Minify(content);
                        }
                        break;
                    }
                    sw.WriteLine(content.Trim());
                }
            }

            // Cache

            if (section.CacheDuration > 0)
            {
                DateTime            timestamp = HttpContext.Timestamp;
                HttpCachePolicyBase cache     = response.Cache;
                int duration = section.CacheDuration;

                cache.SetCacheability(HttpCacheability.Public);
                cache.SetExpires(timestamp.AddSeconds(duration));
                cache.SetMaxAge(new TimeSpan(0, 0, duration));
                cache.SetValidUntilExpires(true);
                cache.SetLastModified(timestamp);
                cache.VaryByHeaders["Accept-Encoding"] = true;
                cache.VaryByParams["name"]             = true;
                cache.VaryByParams["version"]          = true;
                cache.VaryByParams["display"]          = true;
                cache.VaryByParams["condition"]        = true;
                cache.SetOmitVaryStar(true);
            }
        }
        public bool CheckPasteEligibilityFromClipboard(AnimationSequencer destinationSequence)
        {
            bool canPaste = false;

            switch (this.CurrentClipboardAction)
            {
            case ClipboardAction.Clone:
                if (this.currentClipboardObject != null)
                {
                    if (this.currentClipboardObject is AnimationSequencer)
                    {
                        AnimationSequencer      seqElement  = this.currentClipboardObject as AnimationSequencer;
                        List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements);
                        if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference?.Ability == destinationSequence); })))
                        {
                            canPaste = true;
                        }
                    }
                    else if (this.currentClipboardObject is ReferenceElement)
                    {
                        ReferenceElement refAbility = this.currentClipboardObject as ReferenceElement;
                        if (refAbility.Reference?.Ability == destinationSequence)
                        {
                            canPaste = false;
                        }
                        else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0)
                        {
                            bool refexists = false;
                            if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement))
                            {
                                refexists = true;
                            }
                            List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements);
                            if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); }))
                            {
                                refexists = true;
                            }
                            if (!refexists)
                            {
                                canPaste = true;
                            }
                        }
                        else
                        {
                            canPaste = true;
                        }
                    }
                    else
                    {
                        canPaste = true;
                    }
                }
                break;

            case ClipboardAction.Cut:
                if (this.currentClipboardObject != null)
                {
                    object[]           clipObj = this.currentClipboardObject as object[];
                    AnimationElement   clipboardAnimationElement   = clipObj[0] as AnimationElement;
                    AnimationSequencer clipboardAnimationSequencer = clipObj[1] as AnimationSequencer;
                    if (clipboardAnimationElement is SequenceElement)
                    {
                        SequenceElement         seqElement  = clipboardAnimationElement as SequenceElement;
                        List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements);
                        if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); })))
                        {
                            canPaste = true;
                        }
                    }
                    else if (clipboardAnimationElement is ReferenceElement)
                    {
                        ReferenceElement refAbility = clipboardAnimationElement as ReferenceElement;
                        if (refAbility.Reference?.Ability == destinationSequence)
                        {
                            canPaste = false;
                        }
                        else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0)
                        {
                            bool refexists = false;
                            if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement))
                            {
                                refexists = true;
                            }
                            List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements);
                            if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); }))
                            {
                                refexists = true;
                            }
                            if (!refexists)
                            {
                                canPaste = true;
                            }
                        }
                        else
                        {
                            canPaste = true;
                        }
                    }
                    else
                    {
                        canPaste = true;
                    }
                }
                break;
            }
            return(canPaste);
        }
Esempio n. 24
0
        private static void ProcessPlaceHolderElement(XmlNode placeholder, ReferenceElement ie)
        {
            var placeholderType = placeholder.Attributes[TextPlaceholderTypeAttribute]
                .InnerText.Trim().ToLowerInvariant();
            ;
            //处理图像占位符

            switch (placeholderType)
            {
                case "image":
                    ProcessImageTag(placeholder, ie);
                    break;

                case "text":
                    placeholder.ParentNode.ReplaceChild(ie, placeholder);
                    break;

                default:
                    throw new SyntaxErrorException("Unsupported placeholder type: " + placeholderType);
            }
        }
Esempio n. 25
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ProcessRequest;

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

            base.CopyTo(dest);
            if (ActionElement != null)
            {
                dest.ActionElement = (Code <Hl7.Fhir.Model.ProcessRequest.ActionList>)ActionElement.DeepCopy();
            }
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (Ruleset != null)
            {
                dest.Ruleset = (Hl7.Fhir.Model.Coding)Ruleset.DeepCopy();
            }
            if (OriginalRuleset != null)
            {
                dest.OriginalRuleset = (Hl7.Fhir.Model.Coding)OriginalRuleset.DeepCopy();
            }
            if (CreatedElement != null)
            {
                dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy();
            }
            if (Target != null)
            {
                dest.Target = (Hl7.Fhir.Model.ResourceReference)Target.DeepCopy();
            }
            if (Provider != null)
            {
                dest.Provider = (Hl7.Fhir.Model.ResourceReference)Provider.DeepCopy();
            }
            if (Organization != null)
            {
                dest.Organization = (Hl7.Fhir.Model.ResourceReference)Organization.DeepCopy();
            }
            if (Request != null)
            {
                dest.Request = (Hl7.Fhir.Model.ResourceReference)Request.DeepCopy();
            }
            if (Response != null)
            {
                dest.Response = (Hl7.Fhir.Model.ResourceReference)Response.DeepCopy();
            }
            if (NullifyElement != null)
            {
                dest.NullifyElement = (Hl7.Fhir.Model.FhirBoolean)NullifyElement.DeepCopy();
            }
            if (ReferenceElement != null)
            {
                dest.ReferenceElement = (Hl7.Fhir.Model.FhirString)ReferenceElement.DeepCopy();
            }
            if (Item != null)
            {
                dest.Item = new List <Hl7.Fhir.Model.ProcessRequest.ItemsComponent>(Item.DeepCopy());
            }
            if (IncludeElement != null)
            {
                dest.IncludeElement = new List <Hl7.Fhir.Model.FhirString>(IncludeElement.DeepCopy());
            }
            if (ExcludeElement != null)
            {
                dest.ExcludeElement = new List <Hl7.Fhir.Model.FhirString>(ExcludeElement.DeepCopy());
            }
            if (Period != null)
            {
                dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
            }
            return(dest);
        }
Esempio n. 26
0
        private static void ProcessImageTag(XmlNode placeholder, ReferenceElement ie)
        {
            Debug.Assert(placeholder != null);
            Debug.Assert(ie != null);

            //向上查找 drawbox
            var drawboxNode = placeholder.LookupAncestor(DrawTextBoxElement);
            if (drawboxNode.Name != DrawTextBoxElement)
            {
                throw new TemplateException("The placeholder of image must be in a 'frame'");
            }

            drawboxNode.ParentNode.ReplaceChild(ie, drawboxNode);
        }