private static string SnippetDefaultFilterSaveOnRecompute(KeepSynchronizedInfo info)
 {
     return string.Format(@"
     filterSave = filterSave ?? FilterSaveKeepSynchronizedOnChangedItems_{3}_{4};",
         info.EntityComputedFrom.Target.Module.Name, info.EntityComputedFrom.Target.Name, info.FilterSaveExpression,
         info.EntityComputedFrom.Source.Module.Name, info.EntityComputedFrom.Source.Name);
 }
        private static string FilterSaveFunction(KeepSynchronizedInfo info)
        {
            if (!string.IsNullOrWhiteSpace(info.FilterSaveExpression))
                return string.Format(
@"        private static readonly Func<IEnumerable<{0}.{1}>, Common.DomRepository, IEnumerable<{0}.{1}>> _filterSaveKeepSynchronizedOnChangedItems_{3}_{4} =
        {2};

        public IEnumerable<{0}.{1}> FilterSaveKeepSynchronizedOnChangedItems_{3}_{4}(IEnumerable<{0}.{1}> items)
        {{
            return _filterSaveKeepSynchronizedOnChangedItems_{3}_{4}(items, _domRepository);
        }}

",
                    info.EntityComputedFrom.Target.Module.Name, info.EntityComputedFrom.Target.Name, info.FilterSaveExpression,
                    info.EntityComputedFrom.Source.Module.Name, info.EntityComputedFrom.Source.Name);
            else
                return string.Format(
@"        public IEnumerable<{0}.{1}> FilterSaveKeepSynchronizedOnChangedItems_{3}_{4}(IEnumerable<{0}.{1}> items)
        {{
            return items;
        }}

",
                    info.EntityComputedFrom.Target.Module.Name, info.EntityComputedFrom.Target.Name, info.FilterSaveExpression,
                    info.EntityComputedFrom.Source.Module.Name, info.EntityComputedFrom.Source.Name);
        }
 private static string KeepSynchronizedMetadataSnippet(KeepSynchronizedInfo info)
 {
     return string.Format(
     @"new Common.KeepSynchronizedMetadata {{ Target = {0}, Source = {1}, Context = {2} }},
     ",
         CsUtility.QuotedString(info.EntityComputedFrom.Target.GetKeyProperties()),
         CsUtility.QuotedString(info.EntityComputedFrom.Source.GetKeyProperties()),
         CsUtility.QuotedString(GetKeepSynchronizedContext(info)));
 }
 /// <summary>
 /// The Context property serves as cache-invalidation mechanism.
 /// When the context is changed in the new version of the application,
 /// then the old persisted data should be recomputed on deployment.
 /// This does not cover all situations when the persisted data should be recomputed
 /// on deployment, but at least handles some obvious ones.
 /// </summary>
 private static string GetKeepSynchronizedContext(KeepSynchronizedInfo info)
 {
     return info.EntityComputedFrom.Source.GetFullDescription();
 }