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); }
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; }
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)); }
public Pergamino(TypeStrategy caracteristicas) { estado = new UnknowStrategy(caracteristicas); }
public Potion(TypeStrategy tipoEnt) { estado = tipoEnt; }