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)); }
internal PocoElementNode(ModelInspector inspector, Base root, string rootName = null) { Current = root; _inspector = inspector; _myClassMapping = _inspector.ImportType(root.GetType()); InstanceType = ((IStructureDefinitionSummary)_myClassMapping).TypeName; Definition = ElementDefinitionSummary.ForRoot(_myClassMapping, rootName ?? root.TypeName); Location = InstanceType; ShortPath = InstanceType; }
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)); }
private (string instanceType, IElementDefinitionSummary definition) buildRootPosition(string type) { var rootType = type ?? _source.GetResourceTypeIndicator(); if (rootType == null) { if (_settings.ErrorMode == TypedElementSettings.TypeErrorMode.Report) { throw Error.Format(nameof(type), $"Cannot determine the type of the root element at '{_source.Location}', " + $"please supply a type argument."); } else { return(rootType, null); } } var elementType = Provider.Provide(rootType); if (elementType == null) { if (_settings.ErrorMode == TypedElementSettings.TypeErrorMode.Report) { throw Error.Format(nameof(type), $"Cannot locate type information for type '{rootType}'"); } else { return(rootType, null); } } if (elementType.IsAbstract) { throw Error.Argument(nameof(elementType), $"The type of a node must be a concrete type, '{elementType.TypeName}' is abstract."); } var rootTypeDefinition = ElementDefinitionSummary.ForRoot(elementType, _source.Name); return(rootType, rootTypeDefinition); }
public static ElementNode Root(IStructureDefinitionSummaryProvider provider, string type, string name = null, object value = null) { if (provider == null) { throw Error.ArgumentNull(nameof(provider)); } if (type == null) { throw Error.ArgumentNull(nameof(type)); } var sd = provider.Provide(type); IElementDefinitionSummary definition = null; // Should we throw if type is not found? if (sd != null) { definition = ElementDefinitionSummary.ForRoot(sd); } return(new ElementNode(name ?? type, value, type, definition)); }