예제 #1
0
        /// <summary>Apply the patch to a list asset.</summary>
        /// <typeparam name="TValue">The list value type.</typeparam>
        /// <param name="asset">The asset to edit.</param>
        private void ApplyList <TValue>(IAssetData asset)
        {
            // TODO: this is a horrible hack.
            Dictionary <string, TValue> data = ((List <TValue>)asset.Data).ToDictionary(this.GetId);
            IAssetData newAsset = (IAssetData)asset
                                  .GetType()
                                  .GetConstructor(new[] { typeof(string), typeof(string), typeof(object), typeof(Func <string, string>) })
                                  .Invoke(new[] { asset.Locale, asset.AssetName, data, asset.GetType().GetField("GetNormalisedPath", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).GetValue(asset) });

            this.ApplyDictionary <string, TValue>(newAsset);

            asset.ReplaceWith(data.Values.ToList());
        }