Exemple #1
0
        public static IDictionary <string, object> OnBeforeUpload(DataMap dataMap, ApplicationSchemaDefinition application)
        {
            var context  = new OnBeforeUploadContext(application, MetadataRepository, User.Current);
            var behavior = GetBehavior(context.Application);

            behavior.OnBeforeUpload(context, dataMap);
            return(context.Content);
        }
        /// <summary>
        ///     Invoked just before a data map is uploaded to the upstream
        ///     server. This method can be used to change data "in-flight"
        ///     before it's sent to the server or perform any related tasks.
        /// </summary>
        /// <param name="context">The operation context.</param>
        /// <param name="dataMap">The data map that is about to be uploaded to the server.</param>
        public virtual void OnBeforeUpload(OnBeforeUploadContext context, DataMap dataMap)
        {
            // The server expect a flattened list of fields, i.e.
            // they should not be wrapped inside a data map object.
            var flattened = new Dictionary <string, object>(dataMap
                                                            .Fields
                                                            .ToDictionary(k => k.Key, v => (object)v.Value));

            context.Content = flattened;
        }