/// <summary> /// Tries to parse a resource name in string form into a new <see cref="SecuritymarksNameOneof"/> instance. /// </summary> /// <remarks> /// To parse successfully the resource name must be one of the following: /// <list type="bullet"> /// <item><description>AssetSecurityMarksName: A resource of type 'asset_security_marks'.</description></item> /// <item><description>FindingSecurityMarksName: A resource of type 'finding_security_marks'.</description></item> /// </list> /// Or an <see cref="gax::UnknownResourceName"/> if <paramref name="allowUnknown"/> is <c>true</c>. /// </remarks> /// <param name="name">The resource name in string form. Must not be <c>null</c>.</param> /// <param name="allowUnknown">If true, will successfully parse an unknown resource name /// into an <see cref="gax::UnknownResourceName"/>.</param> /// <param name="result">When this method returns, the parsed <see cref="SecuritymarksNameOneof"/>, /// or <c>null</c> if parsing fails.</param> /// <returns><c>true</c> if the name was parsed succssfully; <c>false</c> otherwise.</returns> public static bool TryParse(string name, bool allowUnknown, out SecuritymarksNameOneof result) { gax::GaxPreconditions.CheckNotNull(name, nameof(name)); AssetSecurityMarksName assetSecurityMarksName; if (AssetSecurityMarksName.TryParse(name, out assetSecurityMarksName)) { result = new SecuritymarksNameOneof(OneofType.AssetSecurityMarksName, assetSecurityMarksName); return(true); } FindingSecurityMarksName findingSecurityMarksName; if (FindingSecurityMarksName.TryParse(name, out findingSecurityMarksName)) { result = new SecuritymarksNameOneof(OneofType.FindingSecurityMarksName, findingSecurityMarksName); return(true); } if (allowUnknown) { gax::UnknownResourceName unknownResourceName; if (gax::UnknownResourceName.TryParse(name, out unknownResourceName)) { result = new SecuritymarksNameOneof(OneofType.Unknown, unknownResourceName); return(true); } } result = null; return(false); }
/// <summary> /// Construct a new instance of <see cref="SecuritymarksNameOneof"/> from the provided <see cref="AssetSecurityMarksName"/> /// </summary> /// <param name="assetSecurityMarksName">The <see cref="AssetSecurityMarksName"/> to be contained within /// the returned <see cref="SecuritymarksNameOneof"/>. Must not be <c>null</c>.</param> /// <returns>A new <see cref="SecuritymarksNameOneof"/>, containing <paramref name="assetSecurityMarksName"/>.</returns> public static SecuritymarksNameOneof From(AssetSecurityMarksName assetSecurityMarksName) => new SecuritymarksNameOneof(OneofType.AssetSecurityMarksName, assetSecurityMarksName);