示例#1
0
        public Task MoveCatalogItem(string name, string description, ReferenceType sourceRef)
        {
            CopyOrMoveCatalogItemParamsType catalogItemParamsType = new CopyOrMoveCatalogItemParamsType();

            catalogItemParamsType.name        = name;
            catalogItemParamsType.Description = description;
            catalogItemParamsType.Source      = sourceRef;
            return(new Task(this.VcloudClient, SdkUtil.Post <TaskType>(this.VcloudClient, this.Resource.href + "/action/move", SerializationUtil.SerializeObject <CopyOrMoveCatalogItemParamsType>(catalogItemParamsType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.vcloud.copyOrMoveCatalogItemParams+xml", 202)));
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomData"/> class.
 /// </summary>
 /// <param name="info">The serialization info.</param>
 /// <param name="context">The streaming context.</param>
 protected CustomData(SerializationInfo info, StreamingContext context)
 {
     Any = SerializationUtil.GetXmlElementList(info);
 }
        public void ValidateInvariantAllExamplesWithOtherConstraints()
        {
            string profiles = TestDataHelper.GetFullPathForExample("profiles-others.xml");

            FhirXmlParser            parser               = new FhirXmlParser();
            int                      errorCount           = 0;
            int                      testFileCount        = 0;
            Dictionary <string, int> failedInvariantCodes = new Dictionary <string, int>();
            List <String>            checkedCode          = new List <string>();


            Bundle otherSDs;
            Dictionary <string, List <ElementDefinition.ConstraintComponent> > invariantCache = new Dictionary <string, List <ElementDefinition.ConstraintComponent> >();

            using (Stream streamOther = File.OpenRead(profiles))
            {
                otherSDs = new Fhir.Serialization.FhirXmlParser().Parse <Bundle>(SerializationUtil.XmlReaderFromStream(streamOther));
                foreach (StructureDefinition resource in otherSDs.Entry.Select(e => e.Resource).Where(r => r != null && r is StructureDefinition))
                {
                    List <ElementDefinition.ConstraintComponent> cacheForResource;
                    if (invariantCache.ContainsKey(resource.ConstrainedType.ToString()))
                    {
                        cacheForResource = invariantCache[resource.ConstrainedType.ToString()];
                    }
                    else
                    {
                        cacheForResource = new List <ElementDefinition.ConstraintComponent>();
                        invariantCache.Add(resource.ConstrainedType.ToString(), cacheForResource);
                    }

                    // read the invariants for elements in the differential
                    foreach (var ed in resource.Differential.Element)
                    {
                        foreach (var constraint in ed.Constraint)
                        {
                            var ext = constraint.GetExtensionValue <FhirString>("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression");
                            if (ext == null)
                            {
                                continue;
                            }
                            string expression = ext.Value;
                            string parentPath = ed.Path;
                            if (parentPath.Contains("."))
                            {
                                // This expression applied to a backbone element, so need to give it scope
                                expression = parentPath.Replace(resource.ConstrainedType.ToString() + ".", "") + ".all(" + expression + ")";
                                ext.Value  = expression;
                            }
                            string key = constraint.Key;
                            if (!string.IsNullOrEmpty(expression))
                            {
                                cacheForResource.Add(constraint);
                            }
                        }
                    }
                }
            }

            var zip = TestDataHelper.ReadTestZip("examples.zip");

            using (zip)
            {
                foreach (var entry in zip.Entries)
                {
                    Stream file = entry.Open();
                    using (file)
                    {
                        // Verified examples that fail validations
                        // dom-3
                        if (entry.Name.EndsWith("list-example-familyhistory-genetics-profile-annie(prognosis).xml"))
                        {
                            continue;
                        }
                        if (entry.Name.EndsWith("questionnaire-sdc-profile-example-loinc(questionnaire-sdc-profile-example-loinc).xml"))
                        {
                            continue;
                        }
                        if (entry.Name.EndsWith("questionnaireresponse-example(3141).xml"))
                        {
                            continue;
                        }
                        if (entry.Name.EndsWith("dataelement-example(gender).xml"))
                        {
                            continue;
                        }


                        // vsd-3, vsd-8
                        //if (file.EndsWith("valueset-ucum-common(ucum-common).xml"))
                        //    continue;

                        var reader   = SerializationUtil.WrapXmlReader(XmlReader.Create(file));
                        var resource = parser.Parse <Resource>(reader);

                        testFileCount++;
                        // Debug.WriteLine(String.Format("Validating {0}", entry.Name));
                        resource.AddDefaultConstraints();
                        if (invariantCache.ContainsKey(resource.ResourceType.ToString()))
                        {
                            resource.InvariantConstraints.AddRange(invariantCache[resource.ResourceType.ToString()]);
                        }
                        var outcome = new OperationOutcome();
                        resource.ValidateInvariants(outcome);
                        // Debug.WriteLine("Key: " + String.Join(", ", resource.InvariantConstraints.Select(s => s.Key)));
                        foreach (var item in resource.InvariantConstraints)
                        {
                            if (checkedCode.Contains(item.Key))
                            {
                                continue;
                            }
                            checkedCode.Add(item.Key);
                            string expression = item.GetExtensionValue <FhirString>("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression").Value;
                            if (expression.Contains("[x]"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an [x] in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("\"%\""))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an \"%\" in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("$parent"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had a '$parent' in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("descendents"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an 'descendents' in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("Decimal"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an 'Decimal' in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("String"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an 'String' in it '{1}'", item.Key, expression));
                            }
                            if (expression.Contains("Integer"))
                            {
                                Debug.WriteLine(String.Format("Expression {0} had an 'Integer' in it '{1}'", item.Key, expression));
                            }
                        }
                        // we can skip the US zipcode validations
                        if (outcome.Issue.Where(i => (i.Diagnostics != "address.postalCode.all(matches('[0-9]{5}(-[0-9]{4}){0,1}'))")).Count() > 0)
                        {
                            Debug.WriteLine(String.Format("Validating {0} failed:", entry.Name));
                            foreach (var item in outcome.Issue)
                            {
                                if (!failedInvariantCodes.ContainsKey(item.Details.Coding[0].Code))
                                {
                                    failedInvariantCodes.Add(item.Details.Coding[0].Code, 1);
                                }
                                else
                                {
                                    failedInvariantCodes[item.Details.Coding[0].Code]++;
                                }

                                Trace.WriteLine("\t" + item.Details.Coding[0].Code + ": " + item.Details.Text);
                                Trace.WriteLine("\t" + item.Diagnostics);
                            }
                            //  Trace.WriteLine("-------------------------");
                            //  Trace.WriteLine(FhirSerializer.SerializeResourceToXml(resource));
                            //  Trace.WriteLine("-------------------------");
                            // count the issue
                            errorCount++;
                        }
                    }
                }
            }

            Debug.WriteLine(String.Format("\r\n------------------\r\nValidation failed in {0} of {1} examples", errorCount, testFileCount));
            if (failedInvariantCodes.Count > 0)
            {
                Debug.Write("Issues with Invariant: ");
                bool b = false;
                foreach (var item in failedInvariantCodes)
                {
                    if (b)
                    {
                        Debug.Write(", ");
                    }
                    Debug.Write(String.Format("{0} ({1})", item.Key, item.Value));
                    b = true;
                }
            }
            Assert.AreEqual(22, errorCount, String.Format("Failed Validating {0} of {1} examples", errorCount, testFileCount));

            /*
             * Validating dataelement-labtestmaster-example(prothrombin).xml failed:
             *  inv-2: One and only one DataElement.code must have is-data-element-concept set to "true"
             *  code.extension(%"ext-11179-de-is-data-element-concept").count() = 1
             * Validating dataelement-sdc-profile-example(dataelement-sdc-profile-example).xml failed:
             *  inv-2: One and only one DataElement.code must have is-data-element-concept set to "true"
             *  code.extension(%"ext-11179-de-is-data-element-concept").count() = 1
             * Validating dataelement-sdc-profile-example-de(dataelement-sdc-profile-example-de).xml failed:
             *  inv-2: One and only one DataElement.code must have is-data-element-concept set to "true"
             *  code.extension(%"ext-11179-de-is-data-element-concept").count() = 1
             * Validating organization-example-f001-burgers(f001).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating organization-example-f201-aumc(f201).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating organization-example-f203-bumc(f203).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating patient-example(example).xml failed:
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all(matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating patient-example-f001-pieter(f001).xml failed:
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all(matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating patient-example-f201-roel(f201).xml failed:
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all(matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating patient-example-us-extensions(us01).xml failed:
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             *  inv-1: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all(matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f001-evdb(f001).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f002-pv(f002).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f003-mv(f003).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f004-rb(f004).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f005-al(f005).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f006-rvdb(f006).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f007-sh(f007).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f201-ab(f201).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f202-lm(f202).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f203-jvg(f203).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating practitioner-example-f204-ce(f204).xml failed:
             *  inv-2: (Zip or Postal Code) SHALL be formatted as 99999[-9999] for US Zip or ZIP +4 codes or as A9A9A9 for Canadian postal codes.
             *  address.postalCode.all($this.matches('[0-9]{5}(-[0-9]{4}){0,1}'))
             * Validating valueset-example-expansion(example-expansion).xml failed:
             *      vsd-9: Must have a code if not abstract
             *      expansion.contains.all(code.exists() or (abstract = 'true'))
             *
             * ------------------
             * Validation failed in 22 of 725 examples
             * Issues with Invariant: inv-2 (23), inv-1 (12), vsd-9 (1)
             *
             */
        }
 protected virtual void OnBeginEdit()
 {
     // Create clone
     _editClone = SerializationUtil.BinaryCloneObject(this) as DataItemBase;
 }
示例#5
0
 public static bool IsValidValue(string value) => !SerializationUtil.RunFhirXhtmlSchemaValidation(value).Any();
 public byte[] Serialize() => SerializationUtil.Serialize(this);
        public bool WriteThru(CacheBase cacheImpl, string key, CacheEntry cacheEntry, OpCode operationCode, OperationContext operationContext)
        {
            if ((_context.DatasourceMgr == null) || ((_context != null) && !_context.DatasourceMgr.IsWriteThruEnabled))
            {
                throw new OperationFailedException("Backing source not available. Verify backing source settings");
            }
            Exception inner = null;
            int       num   = 0;

            try
            {
                object serializedObject = null;
                if (((cacheEntry != null) && (operationCode != OpCode.Remove)) && (operationCode != OpCode.Clear))
                {
                    if (cacheEntry.Value is CallbackEntry)
                    {
                        serializedObject = ((CallbackEntry)cacheEntry.Value).Value;
                    }
                    else
                    {
                        serializedObject = cacheEntry.Value;
                    }
                    if (serializedObject != null)
                    {
                        serializedObject = CompressionUtil.Decompress(((UserBinaryObject)serializedObject).GetFullObject() as byte[], cacheEntry.Flag);
                        serializedObject = SerializationUtil.SafeDeserialize(serializedObject, _context.SerializationContext, cacheEntry.Flag);
                    }
                }
                num = this.WriteThru(key, serializedObject, operationCode);
            }
            catch (Exception exception2)
            {
                inner = exception2;
            }
            finally
            {
                if (num == 0)
                {
                    try
                    {
                        switch (operationCode)
                        {
                        case OpCode.Add:
                        case OpCode.Update:
                            cacheImpl.Remove(key, ItemRemoveReason.Removed, false, null, 0, LockAccessType.IGNORE_LOCK, operationContext);
                            break;
                        }
                    }
                    catch (Exception exception3)
                    {
                        throw new OperationFailedException("error while trying to synchronize the cache with data source. Error: " + exception3.Message, exception3);
                    }
                    if (inner != null)
                    {
                        throw new OperationFailedException("IWriteThruProvider failed. Error: " + inner.Message, inner);
                    }
                }
            }
            if (num != 1)
            {
                return(false);
            }
            return(true);
        }
示例#8
0
 public Group ImportGroup(GroupType groupType)
 {
     try
     {
         return(new Group(this.VcloudClient, SdkUtil.Post <GroupType>(this.VcloudClient, this.Reference.href + "/groups", SerializationUtil.SerializeObject <GroupType>(groupType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.group+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#9
0
 public AdminVdc CreateAdminVdc(AdminVdcType adminVdcType)
 {
     try
     {
         return(new AdminVdc(this.VcloudClient, SdkUtil.Post <AdminVdcType>(this.VcloudClient, this.Reference.href + "/vdcs", SerializationUtil.SerializeObject <AdminVdcType>(adminVdcType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.vdc+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#10
0
        public static void SmokeTest1()
        {
            string script =
                "Alice: Hello? Are you there?\n" +
                "Eve: Yes, yes, just... one moment.\n" +
                "add(4)\n" +
                ": The line briefly emits a sharp static. Then, silence.\n" +

                "choice [hangup]\n" +
                "  > Hang up.\n" +
                "  : Alice hangs up.\n" +

                "choice [wait]\n" +
                "  > Wait.\n" +
                "  waited = { true }\n" +
                "  : Alice waits\n" +

                "choose\n" +

                "if { waited }\n" +
                "  Eve: There we go. Sorry about that.\n" +
                "  Alice: No problem.\n" +
                "  add(4)\n";

            var nodes = new RumorCompiler()
                        .SetTabSize(2)
                        .LinkAction("add", ValueType.Number)
                        .Compile(script);

            double number = 0;
            var    rumor  = new Engine.Rumor(nodes);

            rumor.Bindings.Bind <double>("add", (x) => number += x);
            rumor.Start();

            Assert.AreEqual(
                new Dictionary <string, string>
            {
                { "Alice", "Hello? Are you there?" },
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();

            Assert.AreEqual(
                new Dictionary <string, string>
            {
                { "Eve", "Yes, yes, just... one moment." },
            },
                rumor.State.GetDialog()
                );

            // Simulate saving and loading the game
            rumor = SerializationUtil.Reserialize(rumor);
            rumor.Bindings.Bind <double>("add", (x) => number += x);

            rumor.Advance();

            Assert.AreEqual(4, number);
            Assert.AreEqual(
                new Dictionary <string, string>
            {
                { "_narrator", "The line briefly emits a sharp static. Then, silence." },
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();
            rumor.Choose("hangup");

            Assert.AreEqual(
                new Dictionary <string, string>
            {
                { "_narrator", "Alice hangs up." },
            },
                rumor.State.GetDialog()
                );

            rumor.Advance();
            Assert.IsFalse(rumor.Executing);
        }
示例#11
0
 public User CreateUser(UserType userType)
 {
     try
     {
         return(new User(this.VcloudClient, SdkUtil.Post <UserType>(this.VcloudClient, this.Reference.href + "/users", SerializationUtil.SerializeObject <UserType>(userType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.user+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#12
0
        public IICalendarCollection icalendar(ISerializationContext ctx) //throws RecognitionException, TokenStreamException
        {
            IICalendarCollection iCalendars = new CalendarCollection();


            SerializationUtil.OnDeserializing(iCalendars);

            ICalendar cal      = null;
            Type      foo      = typeof(ISerializationSettings);
            var       settings = ctx.GetService <ISerializationSettings>();

            { // ( ... )*
                for (;;)
                {
                    if ((LA(1) == CRLF || LA(1) == BEGIN))
                    {
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop4_breakloop;
                                }
                            }
_loop4_breakloop:
                            ;
                        } // ( ... )*
                        match(BEGIN);
                        match(COLON);
                        match(VCALENDAR);
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop6_breakloop;
                                }
                            }
_loop6_breakloop:
                            ;
                        } // ( ... )*

                        var processor = ctx.GetService(typeof(ISerializationProcessor <ICalendar>)) as ISerializationProcessor <ICalendar>;

                        // Do some pre-processing on the calendar:
                        processor?.PreDeserialization(cal);

                        cal = new Calendar();
                        SerializationUtil.OnDeserializing(cal);

                        // Push the iCalendar onto the serialization context stack
                        ctx.Push(cal);

                        icalbody(ctx, cal);
                        match(END);
                        match(COLON);
                        match(VCALENDAR);
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF) && (LA(2) == EOF || LA(2) == CRLF || LA(2) == BEGIN) && (tokenSet_0_.member(LA(3))))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop8_breakloop;
                                }
                            }
_loop8_breakloop:
                            ;
                        } // ( ... )*

                        // Do some final processing on the calendar:
                        processor?.PostDeserialization(cal);

                        // Notify that the iCalendar has been loaded
                        cal.OnLoaded();
                        iCalendars.Add(cal);

                        SerializationUtil.OnDeserialized(cal);

                        // Pop the iCalendar off the serialization context stack
                        ctx.Pop();
                    }
                    else
                    {
                        goto _loop9_breakloop;
                    }
                }
_loop9_breakloop:
                ;
            } // ( ... )*

            SerializationUtil.OnDeserialized(iCalendars);

            return(iCalendars);
        }
示例#13
0
        public ICalendarComponent component(ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o)
        //throws RecognitionException, TokenStreamException
        {
            ICalendarComponent c;
            IToken             n = null;

            match(BEGIN);
            match(COLON);
            {
                switch (LA(1))
                {
                case IANA_TOKEN:
                {
                    n = LT(1);
                    match(IANA_TOKEN);
                    c = cf.Build(n.getText());
                    break;
                }

                case X_NAME:
                {
                    var m = LT(1);
                    match(X_NAME);
                    c = cf.Build(m.getText());
                    break;
                }

                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                }
            }

            var processor = ctx.GetService(typeof(ISerializationProcessor <ICalendarComponent>)) as ISerializationProcessor <ICalendarComponent>;

            // Do some pre-processing on the component
            processor?.PreDeserialization(c);

            SerializationUtil.OnDeserializing(c);

            // Push the component onto the serialization context stack
            ctx.Push(c);

            // Add the component as a child immediately, in case
            // embedded components need to access this component,
            // or the iCalendar itself.
            o?.AddChild(c);

            c.Line   = n.getLine();
            c.Column = n.getColumn();

            { // ( ... )*
                for (;;)
                {
                    if ((LA(1) == CRLF))
                    {
                        match(CRLF);
                    }
                    else
                    {
                        goto _loop16_breakloop;
                    }
                }
_loop16_breakloop:
                ;
            } // ( ... )*
            { // ( ... )*
                for (;;)
                {
                    switch (LA(1))
                    {
                    case IANA_TOKEN:
                    case X_NAME:
                    {
                        property(ctx, c);
                        break;
                    }

                    case BEGIN:
                    {
                        component(ctx, sf, cf, c);
                        break;
                    }

                    default:
                    {
                        goto _loop18_breakloop;
                    }
                    }
                }
_loop18_breakloop:
                ;
            } // ( ... )*
            match(END);
            match(COLON);
            match(IANA_TOKEN);
            { // ( ... )*
                for (;;)
                {
                    if ((LA(1) == CRLF))
                    {
                        match(CRLF);
                    }
                    else
                    {
                        goto _loop20_breakloop;
                    }
                }
_loop20_breakloop:
                ;
            } // ( ... )*

            // Do some final processing on the component
            processor?.PostDeserialization(c);

            // Notify that the component has been loaded
            c.OnLoaded();

            SerializationUtil.OnDeserialized(c);

            // Pop the component off the serialization context stack
            ctx.Pop();

            return(c);
        }
示例#14
0
 public CatalogItem AddCatalogItem(CatalogItemType catalogItemType)
 {
     try
     {
         return(new CatalogItem(this.VcloudClient, SdkUtil.Post <CatalogItemType>(this.VcloudClient, this.Reference.href + "/catalogItems", SerializationUtil.SerializeObject <CatalogItemType>(catalogItemType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.vcloud.catalogItem+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#15
0
 public AdminCatalog CreateCatalog(AdminCatalogType adminCatalogType)
 {
     try
     {
         return(new AdminCatalog(this.VcloudClient, SdkUtil.Post <AdminCatalogType>(this.VcloudClient, this.Resource.href + "/catalogs", SerializationUtil.SerializeObject <AdminCatalogType>(adminCatalogType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.catalog+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#16
0
 public AdminVdc CreateAdminVdc(CreateVdcParamsType vdcParams)
 {
     return(new AdminVdc(this.VcloudClient, SdkUtil.Post <AdminVdcType>(this.VcloudClient, this.Reference.href + "/vdcsparams", SerializationUtil.SerializeObject <CreateVdcParamsType>(vdcParams, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.createVdcParams+xml", 201)));
 }
示例#17
0
        static List <Expression> MakePropertySerializers([NotNull] CodeEmitter codeEmitter, [NotNull] Type type)
        {
            var expressions = new List <Expression>();

            foreach (PropertyInfo property in GetSerializableProperties(type))
            {
                Type propType = property.PropertyType;

                // read tag name
                Attribute nameAttribute = property.GetCustomAttribute(typeof(TagNameAttribute));
                string    tagName;
                if (nameAttribute != null)
                {
                    tagName = ((TagNameAttribute)nameAttribute).Name;
                }
                else
                {
                    tagName = property.Name;
                }

                // read NullPolicy attribute
                var nullPolicyAttr =
                    (NullPolicyAttribute)property.GetCustomAttribute(typeof(NullPolicyAttribute));
                var selfPolicy    = NullPolicy.Default;
                var elementPolicy = NullPolicy.Default;
                if (nullPolicyAttr != null)
                {
                    selfPolicy    = nullPolicyAttr.SelfPolicy;
                    elementPolicy = nullPolicyAttr.ElementPolicy;
                }

                // simple serialization for primitive types
                if (propType.GetTypeInfo().IsPrimitive || propType.GetTypeInfo().IsEnum)
                {
                    expressions.Add(codeEmitter.HandlePrimitiveOrEnum(tagName, property));
                    continue;
                }

                // serialize reference types that map directly to NBT tag types
                if (SerializationUtil.IsDirectlyMappedType(propType))
                {
                    expressions.Add(codeEmitter.HandleDirectlyMappedType(tagName, property, selfPolicy));
                    continue;
                }

                // check if this type can handle its own serialization
                if (typeof(INbtSerializable).IsAssignableFrom(propType))
                {
                    expressions.Add(codeEmitter.HandleINbtSerializable(tagName, property, selfPolicy));
                    continue;
                }

                // Skip serializing NbtTag properties
                if (typeof(NbtTag).IsAssignableFrom(propType))
                {
                    expressions.Add(codeEmitter.HandleNbtTag(tagName, property, selfPolicy));
                    continue;
                }

                // serialize something that implements IDictionary<string,?>
                Type iDictImpl = SerializationUtil.GetStringIDictionaryImpl(propType);
                if (iDictImpl != null)
                {
                    expressions.Add(codeEmitter.HandleStringIDictionary(tagName, property, iDictImpl, selfPolicy,
                                                                        elementPolicy));
                    continue;
                }

                // serialize something that implements IList<?>
                Type iListImpl = SerializationUtil.GetGenericInterfaceImpl(propType, typeof(IList <>));
                if (iListImpl != null)
                {
                    expressions.Add(codeEmitter.HandleIList(tagName, property, iListImpl, selfPolicy, elementPolicy));
                    continue;
                }

                // Skip serializing NbtFile properties
                if (propType == typeof(NbtFile))
                {
                    expressions.Add(codeEmitter.HandleNbtFile(tagName, property, selfPolicy));
                    continue;
                }

                // Compound expressions
                expressions.Add(codeEmitter.HandleCompoundObject(tagName, property, selfPolicy));
            }
            return(expressions);
        }
示例#18
0
 public AdminOrgNetwork CreateOrgNetwork(OrgNetworkType orgNetworkType)
 {
     try
     {
         return(new AdminOrgNetwork(this.VcloudClient, SdkUtil.Post <OrgNetworkType>(this.VcloudClient, this.Reference.href + "/networks", SerializationUtil.SerializeObject <OrgNetworkType>(orgNetworkType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.orgNetwork+xml", 201)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#19
0
        public async Task <IActionResult> Register(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "register")]
            [RequestBodyType(typeof(UserBody), "The user to create")] HttpRequest req)
        {
            // deserialize request
            UserBody userBody;

            try
            {
                userBody = await SerializationUtil.Deserialize <UserBody>(req.Body);
            }
            catch (JsonException e)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, e.Message)));
            }

            // check for required fields
            if (userBody.Name == null)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Name is required")));
            }
            if (userBody.Email == null)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Email is required")));
            }
            if (userBody.Password == null)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Password is required")));
            }
            if (userBody.Dateofbirth == null)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Dateofbirth is required")));
            }
            if (userBody.Gender == null)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Gender is required")));
            }

            // check for date of birth not in the future
            if (userBody.Dateofbirth >= DateTime.Now)
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Dateofbirth can not be in the future")));
            }

            // cannot set user type
            if (userBody.Type != null && userBody.Type != UserType.User)
            {
                return(ForbiddenObjectResult.Create(new ErrorResponse(ErrorCode.UNAUTHORIZED_TO_SET_USER_TYPE)));
            }

            // check if there is already an user with this email
            if (!await userService.EmailExists(userBody.Email))
            {
                return(new BadRequestObjectResult(new ErrorResponse(400, "Email does already exist")));
            }

            // create user
            User createdUser = await this.userService.CreateUser(userBody);

            // get the created user
            UserResponse response = await userService.GetUser(createdUser.Id);

            return(new OkObjectResult(response));
        }
示例#20
0
 public AdminOrganization UpdateAdminOrg(AdminOrgType adminOrgType)
 {
     try
     {
         return(new AdminOrganization(this.VcloudClient, SdkUtil.Put <AdminOrgType>(this.VcloudClient, this.Reference.href, SerializationUtil.SerializeObject <AdminOrgType>(adminOrgType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.organization+xml", 200)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
        public Hashtable WriteThru(CacheBase cacheImpl, string[] keys, object[] values, CacheEntry[] entries, Hashtable returnSet, OpCode operationCode, OperationContext operationContext)
        {
            Exception inner     = null;
            Hashtable hashtable = null;

            try
            {
                int num;
                if ((values == null) || (values.Length <= 0))
                {
                    hashtable = this.WriteThru(keys, values, operationCode);
                }
                num = 0;
                while (num < values.Length)
                {
                    values[num] = SerializationUtil.SafeDeserialize(values[num], _context.SerializationContext, null);
                    num++;
                }
            }
            catch (Exception exception2)
            {
                inner = exception2;
            }
            finally
            {
                if ((hashtable == null) || (hashtable.Count <= 0))
                {
                    if (inner != null)
                    {
                        throw new OperationFailedException("IWriteThruProvider.AddToSource failed. Error: " + inner.Message, inner);
                    }
                }
                string[] strArray = null;
                int      num3     = 0;
                switch (operationCode)
                {
                case OpCode.Add:
                case OpCode.Update:
                    if (inner == null)
                    {
                        strArray = new string[hashtable.Count];
                        foreach (DictionaryEntry entry in hashtable)
                        {
                            strArray[num3++] = entry.Key as string;
                        }
                        break;
                    }
                    strArray = keys;
                    if ((hashtable != null) && (hashtable.Count > 0))
                    {
                        IDictionaryEnumerator enumerator = hashtable.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            returnSet[enumerator.Key] = enumerator.Value;
                        }
                    }
                    break;

                default:
                    break;
                }
                try
                {
                    switch (operationCode)
                    {
                    case OpCode.Add:
                    case OpCode.Update:
                        if (strArray.Length > 0)
                        {
                            cacheImpl.Remove(strArray, ItemRemoveReason.Removed, false, operationContext);
                        }
                        if (inner != null)
                        {
                            throw new OperationFailedException("IWriteThruProvider.AddToSource failed. Error: " + inner.Message, inner);
                        }
                        break;
                    }
                }
                catch (Exception exception3)
                {
                    throw new OperationFailedException("error while trying to synchronize the cache with data source. Error: " + exception3.Message, exception3);
                }
                if (inner != null)
                {
                    throw new OperationFailedException("IWriteThruProvider.AddToSource failed. Error: " + inner.Message, inner);
                }
            }
            return(hashtable);
        }
示例#22
0
 public void CreateEvent(EventType eventType)
 {
     try
     {
         SdkUtil.Post <EventType>(this.VcloudClient, this.Reference.href + "/events", SerializationUtil.SerializeObject <EventType>(eventType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.event+xml", 204);
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
 //================================================================================
 public DataItemCollectionBase <T> Clone()
 {
     return(SerializationUtil.BinaryCloneObject(this) as DataItemCollectionBase <T>);
 }
示例#24
0
 public SspiKeytabUploadSocketType UpdateLdapSspiKeytab(
     SspiKeytabUpdateParamsType sspiKeytabUpdateParamsType)
 {
     try
     {
         return(SdkUtil.Post <SspiKeytabUploadSocketType>(this.VcloudClient, this.Reference.href + "/settings/ldap/action/updateLdapSspiKeytab", SerializationUtil.SerializeObject <SspiKeytabUpdateParamsType>(sspiKeytabUpdateParamsType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.sspiKeytabUpdateParams+xml", 200));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
示例#25
0
 public void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     SerializationUtil.SetXmlElementList(info, Any);
 }
示例#26
0
 public OrgLdapSettingsType UpdateLdapSettings(
     OrgLdapSettingsType orgLdapSettingsType)
 {
     return(SdkUtil.Put <OrgLdapSettingsType>(this.VcloudClient, this.Reference.href + "/settings/ldap", SerializationUtil.SerializeObject <OrgLdapSettingsType>(orgLdapSettingsType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.organizationLdapSettings+xml", 200));
 }
示例#27
0
        // Use a forward-only XmlReader to scan through a possibly huge bundled file,
        // and yield the feed entries, so only one entry is in memory at a time
        private IEnumerable <(JObject element, string fullUrl)> streamResources(Stream input, string resourceType)
        {
            if (resourceType == null)
            {
                throw Error.ArgumentNull(nameof(resourceType));
            }

            JsonReader reader = SerializationUtil.JsonReaderFromStream(input);

            if (resourceType == "Bundle")
            {
                if (!skipTo(reader, "entry"))
                {
                    yield break;
                }

                while (reader.Read())
                {
                    if (reader.TokenType == JsonToken.StartObject && reader.Path.StartsWith("entry["))
                    {
                        var entry = JObject.ReadFrom(reader);

                        var fullUrl = entry.Value <string>("fullUrl");
                        if (fullUrl != null)
                        {
                            var resourceNode = entry["resource"];
                            if (resourceNode is JObject resource)
                            {
                                yield return(resource, fullUrl);
                            }
                        }
                    }
                }
            }

            else
            {
                var resource = (JObject)JObject.ReadFrom(reader);

                if (resource != null)
                {
                    // First try to initialize from canonical url (conformance resources)
                    var canonicalUrl = resource.Value <string>("url");

                    if (canonicalUrl != null)
                    {
                        yield return(resource, canonicalUrl);
                    }

                    // Otherwise try to initialize from resource id
                    else
                    {
                        var resourceId = resource.Value <string>("id");
                        if (resourceId != null)
                        {
                            var fullUrl = "http://example.org/" + resourceType + "/" + resourceId;
                            yield return(resource, fullUrl);
                        }
                    }
                }
            }
        }
示例#28
0
 public OrgSettingsType UpdateOrgSettings(OrgSettingsType orgSettingsType)
 {
     try
     {
         return(SdkUtil.Put <OrgSettingsType>(this.VcloudClient, this.Reference.href + "/settings", SerializationUtil.SerializeObject <OrgSettingsType>(orgSettingsType, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.admin.orgSettings+xml", 200));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
        public void ValidateInvariantAllExamples()
        {
            FhirXmlParser            parser               = new FhirXmlParser();
            int                      errorCount           = 0;
            int                      testFileCount        = 0;
            Dictionary <string, int> failedInvariantCodes = new Dictionary <string, int>();

            var zip = TestDataHelper.ReadTestZip("examples.zip");

            using (zip)
            {
                foreach (var entry in zip.Entries)
                {
                    Stream file = entry.Open();
                    using (file)
                    {
                        // Verified examples that fail validations
                        // dom-3
                        if (entry.Name.EndsWith("list-example-familyhistory-genetics-profile-annie(prognosis).xml"))
                        {
                            continue;
                        }
                        if (entry.Name.EndsWith("questionnaire-sdc-profile-example-loinc(questionnaire-sdc-profile-example-loinc).xml"))
                        {
                            continue;
                        }
                        if (entry.Name.EndsWith("questionnaireresponse-example(3141).xml"))
                        {
                            continue;
                        }

                        // vsd-3, vsd-8
                        //if (file.EndsWith("valueset-ucum-common(ucum-common).xml"))
                        //    continue;

                        // vsd-9
                        if (entry.Name.EndsWith("valueset-example-expansion(example-expansion).xml"))
                        {
                            continue;
                        }


                        var reader   = SerializationUtil.WrapXmlReader(XmlReader.Create(file));
                        var resource = parser.Parse <Resource>(reader);

                        testFileCount++;
                        // Debug.WriteLine(String.Format("Validating {0}", entry.Name));
                        resource.InvariantConstraints = new List <ElementDefinition.ConstraintComponent>();
                        resource.AddDefaultConstraints();
                        var outcome = new OperationOutcome();
                        resource.ValidateInvariants(outcome);
                        if (outcome.Issue.Count > 0)
                        {
                            Debug.WriteLine(String.Format("Validating {0} failed:", entry.Name));
                            foreach (var item in outcome.Issue)
                            {
                                if (!failedInvariantCodes.ContainsKey(item.Details.Coding[0].Code))
                                {
                                    failedInvariantCodes.Add(item.Details.Coding[0].Code, 1);
                                }
                                else
                                {
                                    failedInvariantCodes[item.Details.Coding[0].Code]++;
                                }

                                Trace.WriteLine("\t" + item.Details.Coding[0].Code + ": " + item.Details.Text);
                            }

                            Trace.WriteLine("-------------------------");
                            Trace.WriteLine(new FhirXmlSerializer().SerializeToString(resource));
                            Trace.WriteLine("-------------------------");
                        }
                        if (outcome.Issue.Count != 0)
                        {
                            errorCount++;
                        }
                    }
                }
            }

            Debug.WriteLine(String.Format("\r\n------------------\r\nValidation failed in {0} of {1} examples", errorCount, testFileCount));
            if (failedInvariantCodes.Count > 0)
            {
                Debug.Write("Issues with Invariant: ");
                bool b = false;
                foreach (var item in failedInvariantCodes)
                {
                    if (b)
                    {
                        Debug.Write(", ");
                    }
                    Debug.Write(String.Format("{0} ({1})", item.Key, item.Value));
                    b = true;
                }
            }
            Assert.AreEqual(0, errorCount, String.Format("Failed Validating {0} of {1} examples", errorCount, testFileCount));
        }
示例#30
0
 public Task CaptureVapp(CaptureVAppParamsType captureVappParams)
 {
     try
     {
         return(new Task(this.VcloudClient, SdkUtil.Post <TaskType>(this.VcloudClient, this.Reference.href + "/action/captureVApp", SerializationUtil.SerializeObject <CaptureVAppParamsType>(captureVappParams, "com.vmware.vcloud.api.rest.schema"), "application/vnd.vmware.vcloud.captureVAppParams+xml", 202)));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }