Ejemplo n.º 1
0
        public static NavigatorPosition ForRoot(ISourceNode element, IStructureDefinitionSummary elementType, string elementName)
        {
            if (elementName == null)
            {
                throw Error.ArgumentNull(nameof(elementName));
            }

            var rootElement = elementType != null?ElementDefinitionSummary.ForRoot(elementName, elementType) : null;

            return(new NavigatorPosition(element, rootElement, elementName, elementType?.TypeName));
        }
Ejemplo n.º 2
0
        private static void checkType(IStructureDefinitionSummary parent, string ename, bool mayRepeat, params string[] types)
        {
            var child = parent.GetElements().SingleOrDefault(c => c.ElementName == ename);

            Assert.IsNotNull(child);
            Assert.AreEqual(types.Count() > 1, child.IsChoiceElement);
            Assert.AreEqual(mayRepeat, child.IsCollection);
            Assert.IsTrue(child.Type.All(t => t is IStructureDefinitionReference));
            CollectionAssert.AreEqual(types, child.Type
                                      .Cast <IStructureDefinitionReference>()
                                      .Select(t => t.ReferredType).ToArray());
        }
Ejemplo n.º 3
0
        private static IStructureDefinitionSummary checkBBType(IStructureDefinitionSummary parent, string ename, string bbType, bool mayRepeat)
        {
            var child = parent.GetElements().SingleOrDefault(c => c.ElementName == ename);

            Assert.IsNotNull(child);
            Assert.AreEqual(mayRepeat, child.IsCollection);
            var result = child.Type.Single() as IStructureDefinitionSummary;

            Assert.AreEqual(bbType, result.TypeName);
            Assert.IsNotNull(result);

            return(result);
        }
Ejemplo n.º 4
0
        public static NavigatorPosition ForRoot(ISourceNode element, IStructureDefinitionSummary elementType, string elementName)
        {
            if (elementName == null)
            {
                throw Error.ArgumentNull(nameof(elementName));
            }

            if (elementType != null && elementType.IsAbstract)
            {
                throw Error.Argument(nameof(elementType), $"The given type must be a concrete type, '{elementType.TypeName}' is abstract.");
            }

            var rootElement = elementType != null?ElementDefinitionSummary.ForRoot(elementName, elementType) : null;

            return(new NavigatorPosition(element, rootElement, elementName, elementType?.TypeName));
        }
 public static ElementDefinitionSummaryCache ForType(IStructureDefinitionSummary type)
 => new ElementDefinitionSummaryCache(type.GetElements());
Ejemplo n.º 6
0
 public static ElementDefinitionSummary ForRoot(IStructureDefinitionSummary rootType, string rootName = null) =>
 new ElementDefinitionSummary(rootName ?? rootType.TypeName, isCollection: false, isChoice: false,
                              isResource: rootType.IsResource,
                              representation: XmlRepresentation.XmlElement,
                              defaultType: null,
                              type: new[] { rootType }, order: 0, nonDefaultNS: null, inSummary: true, isRequired: false);
Ejemplo n.º 7
0
 public static ElementDefinitionSummaryCache ForType(IStructureDefinitionSummary type)
 => new ElementDefinitionSummaryCache(type.GetElements().ToDictionary(c => c.ElementName));