/// <summary> /// Initializes a new instance of <see cref="Resource" /> using the specified parameters. /// </summary> /// <param name="parentUri">The parent URI.</param> /// <param name="contentType">The content type.</param> /// <param name="folderName">The folder name.</param> /// <param name="hasChildren">The child count.</param> /// <param name="appendFolderName">if set to <c>true</c> append folder name.</param> /// <returns>A new <see cref="Resource"/> instance.</returns> public static Resource NewFolder(EtpUri parentUri, EtpContentType contentType, string folderName, int hasChildren = -1, bool appendFolderName = false) { var folderUri = parentUri; if (!parentUri.ObjectType.EqualsIgnoreCase(contentType.ObjectType)) { folderUri = folderUri.Append(contentType.ObjectType); } if (appendFolderName) { folderUri = folderUri.Append(folderName); } var resource = New( uuid: string.Empty, uri: folderUri, resourceType: ResourceTypes.Folder, name: folderName, count: hasChildren); resource.ContentType = contentType; return(resource); }
/// <summary> /// Gets the <see cref="EtpUri"/> for a given <see cref="Energistics.DataAccess.WITSML200.ComponentSchemas.DataObjectReference"/>. /// </summary> /// <param name="reference">The data object reference.</param> /// <returns>An <see cref="EtpUri"/> instance.</returns> public static EtpUri GetUri(this Witsml200.ComponentSchemas.DataObjectReference reference) { var contentType = new EtpContentType(reference.ContentType); return(string.IsNullOrWhiteSpace(reference.Uri) ? Witsml200.Append(contentType.ObjectType, reference.Uuid) : new EtpUri(reference.Uri)); }
/// <summary> /// Determines whether the specified property name is for a child data object reference. /// </summary> /// <param name="contentType">The content type.</param> /// <param name="propertyName">The property name.</param> /// <returns><c>true</c> if the property name is for a child data object reference; otherwise, <c>false</c>.</returns> public static bool IsChildObjectReference(EtpContentType contentType, string propertyName) { string[] values; return(ChildObjectReferences.TryGetValue(contentType, out values) && (values?.ContainsIgnoreCase(propertyName) ?? false)); }
/// <summary> /// Initializes a new instance of <see cref="IResource" /> using the specified parameters. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="parentUri">The parent URI.</param> /// <param name="contentType">The content type.</param> /// <param name="folderName">The folder name.</param> /// <param name="childCount">The child count.</param> /// <param name="appendFolderName">if set to <c>true</c> append folder name.</param> /// <returns>A new <see cref="IResource"/> instance.</returns> public static IResource NewFolder(this IEtpAdapter etpAdapter, EtpUri parentUri, EtpContentType contentType, string folderName, int childCount = -1, bool appendFolderName = false) { if (etpAdapter is Energistics.Etp.v11.Etp11Adapter) { return(Discovery11StoreProvider.NewFolder(parentUri, contentType, folderName, childCount, appendFolderName)); } return(Discovery12StoreProvider.NewFolder(parentUri, contentType, folderName, childCount, appendFolderName)); }
/// <summary> /// Determines whether this <see cref="EtpUri"/> instance is related to the specified <see cref="EtpContentType"/>. /// </summary> /// <param name="uri">The uri.</param> /// <param name="contentType">The content type.</param> /// <returns></returns> public static bool IsRelatedTo(this EtpUri uri, EtpContentType contentType) { return(uri.Family.EqualsIgnoreCase(contentType.Family) && uri.Version.EqualsIgnoreCase(contentType.Version) && uri.ObjectType.EqualsIgnoreCase(contentType.ObjectType)); }
/// <summary> /// Creates <see cref="ObjectName"/> instance from <see cref="EtpContentType"/> instance. /// </summary> /// <param name="contentType"></param> /// <returns></returns> public static ObjectName ToObjectName(this EtpContentType contentType) { return(new ObjectName(contentType.ObjectType, contentType.Version)); }
/// <summary> /// Initializes a new instance of <see cref="IResource" /> using the specified parameters. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="parentUri">The parent URI.</param> /// <param name="contentType">The content type.</param> /// <param name="folderName">The folder name.</param> /// <param name="childCount">The child count.</param> /// <param name="appendFolderName">if set to <c>true</c> append folder name.</param> /// <returns>A new <see cref="IResource"/> instance.</returns> public static IResource NewFolder(this IEtpAdapter etpAdapter, EtpUri parentUri, EtpContentType contentType, string folderName, int childCount = -1, bool appendFolderName = false) { if (etpAdapter.SupportedVersion == EtpVersion.v11) { return(Discovery11StoreProvider.NewFolder(parentUri, contentType, folderName, childCount, appendFolderName)); } return(Discovery12StoreProvider.NewFolder(parentUri, contentType, folderName, childCount, appendFolderName)); }