public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration configuration) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(configuration, "configuration"); _logger = logger; _disableTransparentSync = !configuration.EnableTransparentSync; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, PredicateRootPathResolver rootPathResolver) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(dataProviderConfiguration, "configuration"); Assert.ArgumentNotNull(rootPathResolver, "rootPathResolver"); _logger = logger; _dataProviderConfiguration = dataProviderConfiguration; _rootPathResolver = rootPathResolver; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; // enable capturing recycle bin and archive restores to serialize the target item if included EventManager.Subscribe <RestoreItemCompletedEvent>(HandleItemRestored); try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration configuration) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(configuration, "configuration"); _logger = logger; _configuration = configuration; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
// TODO private UnicornDataProvider CreateTestProvider(Database db, ITargetDataStore targetDataStore = null, ISourceDataStore sourceDataStore = null, IPredicate predicate = null, IFieldFilter filter = null, IUnicornDataProviderLogger logger = null, bool enableTransparentSync = false) { if (predicate == null) { predicate = CreateInclusiveTestPredicate(); } if (filter == null) { filter = Substitute.For<IFieldFilter>(); filter.Includes(Arg.Any<Guid>()).Returns(true); } targetDataStore = targetDataStore ?? Substitute.For<ITargetDataStore>(); sourceDataStore = sourceDataStore ?? Substitute.For<ISourceDataStore>(); var dp = new UnicornDataProvider(targetDataStore, sourceDataStore, predicate, filter, logger ?? Substitute.For<IUnicornDataProviderLogger>(), new DefaultUnicornDataProviderConfiguration(enableTransparentSync), new PredicateRootPathResolver(predicate, targetDataStore, sourceDataStore, Substitute.For<ILogger>())); dp.ParentDataProvider = db.GetDataProviders().First(); return dp; }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, ISyncConfiguration syncConfiguration, PredicateRootPathResolver rootPathResolver) { Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore)); Assert.ArgumentNotNull(predicate, nameof(predicate)); Assert.ArgumentNotNull(fieldFilter, nameof(fieldFilter)); Assert.ArgumentNotNull(logger, nameof(logger)); Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore)); Assert.ArgumentNotNull(dataProviderConfiguration, nameof(dataProviderConfiguration)); Assert.ArgumentNotNull(rootPathResolver, nameof(rootPathResolver)); Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration)); _logger = logger; _dataProviderConfiguration = dataProviderConfiguration; _syncConfiguration = syncConfiguration; _rootPathResolver = rootPathResolver; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; // enable capturing recycle bin and archive restores to serialize the target item if included EventManager.Subscribe<RestoreItemCompletedEvent>(HandleItemRestored); try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public DefaultDeserializer(IDefaultDeserializerLogger logger, IFieldFilter fieldFilter) { Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); _logger = logger; _fieldFilter = fieldFilter; }
private void AssertNullStringIsHanldedByFilter(IFieldFilter filter) { string nullString = null; var filterredString = filter.Filter(nullString); Assert.IsNull(filterredString); }
/// <summary> /// Adds field interception support to the target type. /// </summary> /// <param name="targetType">The type that will be modified.</param> /// <param name="hostTypeFilter">The filter that determines the host types to be modified.</param> /// <param name="fieldFilter">The field filter that determines the fields that will be intercepted.</param> public static void InterceptFields(this IReflectionStructureVisitable targetType, ITypeFilter hostTypeFilter, IFieldFilter fieldFilter) { var typeWeaver = new ImplementFieldInterceptionHostWeaver(hostTypeFilter.ShouldWeave); var fieldWeaver = new InterceptFieldAccess(fieldFilter); targetType.WeaveWith(fieldWeaver, m => true); targetType.Accept(typeWeaver); }
// used for testing protected YamlSerializationFormatter(IFieldFilter fieldFilter, params IFieldFormatter[] fieldFormatters) { _fieldFilter = fieldFilter; if (fieldFormatters != null) { FieldFormatters.AddRange(fieldFormatters); } }
/// <summary> /// 选择被排除以外的列(用于列多时排除某几列的情况) /// </summary> /// <param name="filter"></param> /// <returns></returns> public QuerySection <T> Select(IFieldFilter filter) { Field[] fields = new Field[0]; if (filter != null) { fields = filter.GetFields(fromSection.GetSelectFields()); } return(Select(fields)); }
public DefaultDeserializer(bool ignoreBranchId, IDefaultDeserializerLogger logger, IFieldFilter fieldFilter) { Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); // In reference to issue 283. https://github.com/SitecoreUnicorn/Unicorn/issues/283 IgnoreBranchId = ignoreBranchId; _logger = logger; _fieldFilter = fieldFilter; }
/// <summary> /// 書きだすファイルパスとエンコーディングとフィルターを指定して CsvWriter オブジェクトを作成します。 /// </summary> /// <param name="path">書きだすファイルのパス。</param> /// <param name="fileEncoding">書き込み用のエンコーディング。</param> /// <param name="filter"></param> public CsvWriter(string path, Encoding fileEncoding, IFieldFilter filter) { FileInfo file = new FileInfo( path ); if ( file.Exists ) this.writer_ = new StreamWriter( file.Open( FileMode.Truncate, FileAccess.Write ), fileEncoding ); else this.writer_ = new StreamWriter( file.Open( FileMode.CreateNew, FileAccess.Write ), fileEncoding ); this.filter_ = filter; }
public SerializedAsMasterEvaluator(ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore) { Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(itemComparer, "itemComparer"); Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); _logger = logger; _itemComparer = itemComparer; _fieldFilter = fieldFilter; _sourceDataStore = sourceDataStore; }
public void ToBytesSink(IBytesSink to, IFieldFilter p) { var serializer = new BinarySerializer(to); foreach (var field in this) { if (p.Evaluate(field)) { var value = fields[field]; serializer.Add(field, value); } } }
public YamlSerializationFormatter(XmlNode configNode, IFieldFilter fieldFilter) { _fieldFilter = fieldFilter; if (configNode == null) return; var formatters = configNode.ChildNodes; foreach (XmlNode formatter in formatters) { if (formatter.NodeType == XmlNodeType.Element && formatter.Name.Equals("fieldFormatter")) FieldFormatters.Add(Factory.CreateObject<IFieldFormatter>(formatter)); } }
public SerializedAsMasterEvaluator(ILogger globalLogger, ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore) : base(logger, sourceDataStore, targetDataStore) { Assert.ArgumentNotNull(globalLogger, "globalLogger"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(itemComparer, "itemComparer"); Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); _globalLogger = globalLogger; _logger = logger; _itemComparer = itemComparer; _fieldFilter = fieldFilter; _sourceDataStore = sourceDataStore; }
public void Add_UnitTest() { IFieldFilter filter = default(IFieldFilter); ExecuteMethod( () => { return((IFieldFilterList)GetInstance()); }, instance => { filter = FieldFilterImpl_UnitTests.GetInstance(); Add_PreCondition(instance, ref filter); }, instance => { instance.Add(filter); }, instance => { Add_PostValidate(instance, filter); }); }
public void Remove_UnitTest() { IFieldFilter value = default(IFieldFilter); ExecuteMethod( () => { return((IFieldFilterList)GetInstance()); }, instance => { value = FieldFilterImpl_UnitTests.GetInstance(); Remove_PreCondition(instance, ref value); }, instance => { instance.Remove(value); }, instance => { Remove_PostValidate(instance, value); }); }
public SerializedAsMasterEvaluator(ILogger globalLogger, ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore, IConfiguration parentConfiguration) : base(logger, sourceDataStore, targetDataStore, parentConfiguration) { Assert.ArgumentNotNull(globalLogger, "globalLogger"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(itemComparer, "itemComparer"); Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); _globalLogger = globalLogger; _logger = logger; _itemComparer = itemComparer; _fieldFilter = fieldFilter; _sourceDataStore = sourceDataStore; _parentConfiguration = parentConfiguration; }
private static YamlSerializationFormatter CreateFormatter(IFieldFilter filter) { // shut yer gob again :D var config = @"<serializationFormatter type=""Rainbow.Storage.Yaml.YamlSerializationFormatter, Rainbow.Storage.Yaml"" singleInstance=""true""> <fieldFormatter type=""Rainbow.Formatting.FieldFormatters.MultilistFormatter, Rainbow"" /> <fieldFormatter type=""Rainbow.Formatting.FieldFormatters.XmlFieldFormatter, Rainbow"" /> <fieldFormatter type=""Rainbow.Formatting.FieldFormatters.CheckboxFieldFormatter, Rainbow"" /> </serializationFormatter>" ; var doc = new XmlDocument(); doc.LoadXml(config); return(new YamlSerializationFormatter(doc.DocumentElement, filter)); }
/// <summary> /// Adds field interception support to the target type. /// </summary> /// <param name="targetAssembly">The type that will be modified.</param> /// <param name="hostTypeFilter">The filter that determines the host types to be modified.</param> /// <param name="fieldFilter">The field filter that determines the fields that will be intercepted.</param> public static void InterceptFields(this AssemblyDefinition targetAssembly, ITypeFilter hostTypeFilter, IFieldFilter fieldFilter) { var typeWeaver = new ImplementFieldInterceptionHostWeaver(hostTypeFilter.ShouldWeave); var fieldWeaver = new InterceptFieldAccess(fieldFilter); var module = targetAssembly.MainModule; var targetTypes = module.Types.Where(hostTypeFilter.ShouldWeave).ToArray(); foreach (var type in targetTypes) { typeWeaver.Weave(type); foreach (var method in type.Methods.Where(m => m.HasBody)) { fieldWeaver.Rewrite(method, method.GetILGenerator(), method.Body.Instructions.ToArray()); } } }
public YamlSerializationFormatter(XmlNode configNode, IFieldFilter fieldFilter) { _fieldFilter = fieldFilter; if (configNode == null) { return; } var formatters = configNode.ChildNodes; foreach (XmlNode formatter in formatters) { if (formatter.NodeType == XmlNodeType.Element && formatter.Name.Equals("fieldFormatter")) { FieldFormatters.Add(Factory.CreateObject <IFieldFormatter>(formatter)); } } }
/// <summary> /// Initializes a new instance of the InterceptFieldAccess class. /// </summary> /// <param name="filter">The filter that determines which fields should be intercepted.</param> public InterceptFieldAccess(IFieldFilter filter) { _filter = filter; }
/// <summary> /// Initializes a new instance of the InterceptFieldAccess class. /// </summary> /// <param name="filter">The filter that determines which fields should be intercepted.</param> public InterceptFieldAccess(Func <FieldReference, bool> filter) { _filter = new FieldFilterAdapter(filter); }
/// <summary> /// 指定されたテキストライターとフィールドフィルターを /// 使用して CsvWriter オブジェクトを構築します。 /// </summary> /// <param name="writer"></param> /// <param name="filter"></param> public CsvWriter(TextWriter writer, IFieldFilter filter) { this.writer_ = writer; this.filter_ = filter; }
public FilteredItem(IItemData innerItem, IFieldFilter fieldFilter) : base(innerItem) { Assert.ArgumentNotNull(fieldFilter, "fieldFilter"); _fieldFilter = fieldFilter; }
public UnicornDeserializer(IDefaultDeserializerLogger logger, IFieldFilter fieldFilter) : base(logger, fieldFilter) { }
partial void FieldDefinition_SetCondition(ref IFieldFilter instance, ref IFieldDefinition setValue);
partial void Add_PostValidate(IFieldFilterList instance, IFieldFilter filter);
public FilteredVersion(IItemVersion innerVersion, IFieldFilter fieldFilter) : base(innerVersion) { _innerVersion = innerVersion; _fieldFilter = fieldFilter; }
partial void Value_SetCondition(ref IFieldFilter instance, ref Object setValue);
/// <summary> /// Initializes a new instance of the InterceptFieldAccess class. /// </summary> /// <param name="filter">The filter that determines which fields should be intercepted.</param> public InterceptFieldAccess(Func<FieldReference, bool> filter) { _filter = new FieldFilterAdapter(filter); }
/// <summary> /// ストリームとエンコーディング、フィルターを指定して、CsvWriter オブジェクトを作成します。 /// </summary> /// <param name="stream">書き込むターゲットへのストリーム。</param> /// <param name="streamEncoding">ストリームのエンコーディング。</param> /// <param name="filter">フィールド用のフィルター。</param> public CsvWriter(Stream stream, Encoding streamEncoding, IFieldFilter filter) : this(new StreamWriter( stream, streamEncoding ), filter) { }
public TestYamlSerializationFormatter(IFieldFilter fieldFilter, params IFieldFormatter[] fieldFormatters) : base(fieldFilter, fieldFormatters) { }
partial void Add_PreCondition(IFieldFilterList instance, ref IFieldFilter filter);
private IList<string> GetFieldSyncStatus(IItemData itemData, IItemData serializedItemData, IFieldFilter fieldFilter, IItemComparer itemComparer) { var comparison = itemComparer.Compare(new FilteredItem(itemData, fieldFilter), new FilteredItem(serializedItemData, fieldFilter)); var db = Factory.GetDatabase(itemData.DatabaseName); var changedFields = comparison.ChangedSharedFields .Concat(comparison.ChangedVersions.SelectMany(version => version.ChangedFields)) .Select(field => db.GetItem(new ID((field.SourceField ?? field.TargetField).FieldId))) .Where(field => field != null) .Select(field => field.DisplayName) .ToList(); if (comparison.IsMoved) changedFields.Add("Item has been moved"); if (comparison.IsRenamed) changedFields.Add("Item has been renamed"); if (comparison.IsTemplateChanged) changedFields.Add("Item's template has changed"); if (comparison.ChangedVersions.Any(version => version.SourceVersion == null || version.TargetVersion == null)) changedFields.Add("Item versions do not match"); return changedFields; }
partial void Remove_PostValidate(IFieldFilterList instance, IFieldFilter value);
partial void Remove_PreCondition(IFieldFilterList instance, ref IFieldFilter value);
// Overload constructor, implemented for keeping compatibility with external tools that may not yet have updated their codebase to support the branchId switch (e.g. SideKick) // ReSharper disable once UnusedMember.Global public DefaultDeserializer(IDefaultDeserializerLogger logger, IFieldFilter fieldFilter) : this(true, logger, fieldFilter) { }
public TestYamlSerializationFormatter(XmlNode configNode, IFieldFilter fieldFilter) : base(configNode, fieldFilter) { }
private IList <string> GetFieldSyncStatus(IItemData itemData, IItemData serializedItemData, IFieldFilter fieldFilter, IItemComparer itemComparer) { var comparison = itemComparer.Compare(new FilteredItem(itemData, fieldFilter), new FilteredItem(serializedItemData, fieldFilter)); var db = Factory.GetDatabase(itemData.DatabaseName); var changedFields = comparison.ChangedSharedFields .Concat(comparison.ChangedVersions.SelectMany(version => version.ChangedFields)) .Select(field => db.GetItem(new ID((field.SourceField ?? field.TargetField).FieldId))) .Where(field => field != null) .Select(field => field.DisplayName) .ToList(); if (comparison.IsMoved) { changedFields.Add("Item has been moved"); } if (comparison.IsRenamed) { changedFields.Add("Item has been renamed"); } if (comparison.IsTemplateChanged) { changedFields.Add("Item's template has changed"); } if (comparison.ChangedVersions.Any(version => version.SourceVersion == null || version.TargetVersion == null)) { changedFields.Add("Item versions do not match"); } return(changedFields); }
/// <summary> /// 書きだすファイルパスとフィルターを指定して CsvWriter オブジェクトを作成します。 /// </summary> /// <param name="path">書きだすファイルのパス。</param> /// <param name="filter"></param> public CsvWriter(string path, IFieldFilter filter) : this(path, Encoding.Default, filter) { }