public virtual Asset CreateDerivedAsset([NotNull] string baseLocation, out Dictionary <Guid, Guid> idRemapping) { if (baseLocation == null) { throw new ArgumentNullException(nameof(baseLocation)); } // Make sure we have identifiers for all items AssetCollectionItemIdHelper.GenerateMissingItemIds(this); // Clone this asset without overrides (as we want all parameters to inherit from base) var newAsset = AssetCloner.Clone(this, AssetClonerFlags.GenerateNewIdsForIdentifiableObjects, out idRemapping); // Create a new identifier for this asset var newId = AssetId.New(); // Register this new identifier in the remapping dictionary idRemapping?.Add((Guid)newAsset.Id, (Guid)newId); // Write the new id into the new asset. newAsset.Id = newId; // Create the base of this asset newAsset.Archetype = new AssetReference(Id, baseLocation); return(newAsset); }
/// <summary> /// Initializes a new instance of the <see cref="Asset"/> class. /// </summary> protected Asset() { Id = AssetId.New(); Tags = new TagCollection(); // Initializse asset with default versions (same code as in Package..ctor()) var defaultPackageVersion = AssetRegistry.GetCurrentFormatVersions(GetType()); if (defaultPackageVersion != null) { SerializedVersion = new Dictionary <string, PackageVersion>(defaultPackageVersion); } }