예제 #1
0
        public RequiredFieldFactory()
        {
            dictionaryBase = new TypeStrategy <IEnumerable <ISchemaRequiredField> >(
                simpleTypeAction: type => new ISchemaRequiredField[] { new SimpleRequiredField(TypesNamesConsts.DictionaryKeyName, 0, type.FullName) },
                collectionTypeAction: type =>
            {
                var elementTypes = CollectionElementTypeProvider.Get(type);
                if (elementTypes.Length > 1)
                {
                    throw new NotSupportedException("Dictionary of dictionary not supported");
                }

                return(GetRequiredFields(elementTypes.First()));
            },
                complexTypeAction: GetRequiredFields);

            dictionaryRootNameBase = new TypeStrategy <string>(
                simpleTypeAction: type => type.ToString(),
                collectionTypeAction: type =>
            {
                return(TypesNamesConsts.CollectionOf + new CollectionStrategy <string>(
                           dictionaryAction: type1 => throw new NotSupportedException("Dictionary of dictionary not supported"),
                           simpleNonGenericAction: type1 => CollectionElementTypeProvider.Get(type1)[0].Name,
                           complexNonGenericAction: type1 => CollectionElementTypeProvider.Get(type1)[0].Name).Get(type));
            },
                complexTypeAction: type => type.Name);
        }
예제 #2
0
 private void Init(byte[] requestPacketHeader)
 {
     DataTypeStrategy = TypeStrategy.GetDataTypeStrategy(typeof(T));
     if (DataTypeStrategy.DataType != Address.LsDataType)
     {
         throw new LsDataTypeConflictException(DataTypeStrategy.DataType, Address.LsDataType);
     }
     Id    = Guid.NewGuid();
     Order = _orderCounter++;
     CreateByteArray();
     CreatedOn           = DateTime.Now;
     RequestPacketHeader = requestPacketHeader;
 }
예제 #3
0
        private ISchemaRequiredField GetField(PropertyInfo child, KeyValuePair <int, AgreementSchemaType> parent)
        {
            var fieldStrategy = new TypeStrategy <ISchemaRequiredField>(
                simpleTypeAction: type => new SimpleRequiredField(name: child.Name,
                                                                  level: parent.Key,
                                                                  type: child.PropertyType.ToString()),
                collectionTypeAction: type => GetCollectionField(child, parent),
                complexTypeAction: type =>
            {
                var nextLevel = parent.Key + 1;
                complexTypeStack.Push(new KeyValuePair <int, AgreementSchemaType>(nextLevel, new AgreementSchemaType(child.PropertyType.Name, child.PropertyType)));

                return(new ClassRequiredField(name: child.Name,
                                              level: parent.Key,
                                              type: parent.Value.Name == TypesNamesConsts.InitialType ?
                                              child.PropertyType.Name :
                                              parent.Value.Name));
            });

            return(fieldStrategy.Get(child.PropertyType));
        }
예제 #4
0
 public Pergamino(TypeStrategy caracteristicas)
 {
     estado = new UnknowStrategy(caracteristicas);
 }
예제 #5
0
 public Potion(TypeStrategy tipoEnt)
 {
     estado = tipoEnt;
 }