コード例 #1
0
        public void Cloner_Strategy_Collection()
        {
            //Arange

            var strategy = new CollectionStrategy();

            //Act

            var result = strategy.IsMatch(typeof(Collection <Class1>));


            //Assert

            Assert.IsTrue(result, "CollectionStrategy should be able to make cloner for type Collection<Class1>");
        }
コード例 #2
0
        private static IEnumerable <MemberInfo> MembersToLog(Type type, CollectionStrategy collectionStrategy)
        {
            var t = type.TryGetAttribute(out LoggingModelAttribute lmAttr)
                ? lmAttr.LoggingModelType
                : type;

            var(primitives, objects) = PrimitivesAndObjects(t);

            foreach (var memberInfo in objects)
            {
                if (memberInfo.TryGetAttribute(out LogByValueAttribute lgvAttr) ||
                    memberInfo.IsEnum() ||
                    collectionStrategy != CollectionStrategy.Newline
                    )
                {
                    primitives.Add(memberInfo);
                }
コード例 #3
0
        private ISchemaRequiredField GetCollectionField(PropertyInfo child, KeyValuePair <int, AgreementSchemaType> parent)
        {
            var collectionStrategy = new CollectionStrategy <ISchemaRequiredField>(
                dictionaryAction: collectionType =>
            {
                var keyValueTypes = CollectionElementTypeProvider.Get(collectionType);
                var keyType       = keyValueTypes[0];
                var keySchema     = dictionaryBase.Get(keyType);
                var valueType     = keyValueTypes[1];
                var valueSchema   = dictionaryBase.Get(valueType);

                return(new DictionaryRequiredField(name: child.Name,
                                                   level: parent.Key,
                                                   type: string.Format(TypesNamesConsts.DictionaryOf,
                                                                       dictionaryRootNameBase.Get(keyType),
                                                                       dictionaryRootNameBase.Get(valueType)),
                                                   keyFields: keySchema,
                                                   valueFields: valueSchema));
            },
                simpleNonGenericAction: collectionType =>
            {
                var elementType = CollectionElementTypeProvider.Get(collectionType)[0];
                return(new ComplexCollectionRequiredField(
                           name: child.Name,
                           level: parent.Key,
                           type: TypesNamesConsts.CollectionOf + elementType.Name,
                           requiredFields: GetRequiredFields(elementType)));
            },
                complexNonGenericAction: collectionType =>
            {
                var elementType = CollectionElementTypeProvider.Get(collectionType)[0];
                return(new SimpleCollectionRequiredField(
                           name: child.Name,
                           level: parent.Key,
                           type: TypesNamesConsts.CollectionOf + elementType.FullName));
            });

            return(collectionStrategy.Get(child.PropertyType));
        }
コード例 #4
0
 public CsvConfig(char delimeter)
 {
     this.delimiter          = delimeter;
     this.collectionStrategy = CollectionStrategy.Newline;
 }
コード例 #5
0
 public CsvConfig(char delimeter, CollectionStrategy collectionStrategy)
 {
     this.delimiter          = delimeter;
     this.collectionStrategy = collectionStrategy;
 }