public YamlDeserializer(IMappingRegistry mappingRegistry, ITypeCreator typeCreator, IEnumerable <IJsonPrimitiveHandler> customPrimitiveHandlers = null) : base(mappingRegistry, typeCreator, customPrimitiveHandlers) { _yamlDeserializer = new DeserializerBuilder().Build(); _yamlSerializer = new SerializerBuilder().JsonCompatible().Build(); }
/// <summary> /// creates a new <see cref="LuaService"/> /// </summary> /// <param name="serviceprovider">provider for installed services</param> /// <param name="typecreator">service used to create new known types</param> public LuaService(IServiceProvider serviceprovider, ITypeCreator typecreator) { this.serviceprovider = serviceprovider; this.typecreator = typecreator; Script.GlobalOptions.Platform = new LuaPlatformAccessor(); UserData.RegistrationPolicy = new LuaRegistrationPolicy(); }
/// <summary> /// Default constructor /// </summary> /// <param name="configuration"></param> public ComplexConvention(IFixtureConfiguration configuration) { _configuration = configuration; _typeCreator = configuration.Locate <ITypeCreator>(); _typePopulator = configuration.Locate <ITypePopulator>(); _circularReferenceHandler = configuration.Locate <ICircularReferenceHandler>(); _modelService = configuration.Locate <IModelService>(); }
public MessageHandler( IMessageHandlerRegistry messageHandlerRegistry, ITypeCreator typeCreator ) { _messageHandlerRegistry = messageHandlerRegistry; _typeCreator = typeCreator; }
public BsonSanityTests(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; _typeCreator = new TypeCreator(); var analyzer = new TypeAnalyzer(); var mapper = new EverythingTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
public ModelInterchangableTests(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; _typeCreator = new TypeCreator(); var analyzer = new TypeAnalyzer(); var mapper = new EverythingTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
public NulledModelSerializationTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; _typeCreator = new TypeCreator(); var analyzer = new TypeAnalyzer(); var mapper = new DefaultTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
public DynamicModelSerializationTests(ITestOutputHelper testOutputHelper) { this.testOutputHelper = testOutputHelper; _typeCreator = new TypeCreator(); var analyzer = new TypeAnalyzer(); var mapper = new DefaultTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
public CyclicSerializationTests(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; _typeCreator = new TypeCreator(); var analyzer = new TypeAnalyzer(); var mapper = new EverythingTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
/// <summary> /// Initializes a new instance of the <see cref="BuildCapability" /> class. /// </summary> /// <param name="typeCreator">The type creator that provides the build functions.</param> /// <param name="supportsCreate"> /// <c>true</c> if the <paramref name="typeCreator" /> can create an instance; otherwise /// <c>false</c>. /// </param> /// <param name="supportsPopulate"> /// <c>true</c> if the <paramref name="typeCreator" /> can populate an instance; otherwise /// <c>false</c>. /// </param> /// <exception cref="ArgumentNullException">The <paramref name="typeCreator" /> parameter is <c>null</c>.</exception> public BuildCapability(ITypeCreator typeCreator, bool supportsCreate, bool supportsPopulate) { typeCreator = typeCreator ?? throw new ArgumentNullException(nameof(typeCreator)); ImplementedByType = typeCreator.GetType(); SupportsCreate = supportsCreate; SupportsPopulate = supportsPopulate; AutoPopulate = typeCreator.AutoPopulate; _createType = typeCreator.Create; _createProperty = typeCreator.Create; _createParameter = typeCreator.Create; _populate = typeCreator.Populate; }
static Transformer() { _typeCreator = new TypeCreator(); _typeAnalyzer = new TypeAnalyzer(); _typeMapper = new EverythingTypeMapper(_typeAnalyzer); _mappingRegistry = new MappingRegistry(_typeMapper); _jsonSerializer = new JsonSerializer(_mappingRegistry); _jsonDeserializer = new JsonDeserializer(_mappingRegistry, _typeCreator); _binarySerializer = new BinarySerializer(_mappingRegistry); _binaryDeserializer = new BinaryDeserializer(_mappingRegistry, _typeCreator); _xmlSerializer = new XmlSerializer(_mappingRegistry); _xmlDeserializer = new XmlDeserializer(_mappingRegistry, _typeCreator); }
public NumericsModelSerializationTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; _typeCreator = new TypeCreator(); var primitiveRegistry = new PrimitiveRegistry(); primitiveRegistry.AddPrimitiveCheck(new BasicPrimitiveChecker()); primitiveRegistry.AddPrimitiveCheck(new NumericsPrimitiveChecker()); var analyzer = new TypeAnalyzer(primitiveRegistry); var mapper = new EverythingTypeMapper(analyzer); _mappingRegistry = new MappingRegistry(mapper); }
/// <summary> /// Adds a new type creator to the configuration. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="typeCreator">The type creator.</param> /// <returns>The configuration.</returns> /// <exception cref="ArgumentNullException">The <paramref name="configuration" /> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="typeCreator" /> parameter is <c>null</c>.</exception> public static IBuildConfiguration Add(this IBuildConfiguration configuration, ITypeCreator typeCreator) { configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); typeCreator = typeCreator ?? throw new ArgumentNullException(nameof(typeCreator)); configuration.TypeCreators.Add(typeCreator); return(configuration); }
/// <summary> /// creates a new <see cref="PythonService"/> /// </summary> /// <param name="importservice">service used to import hosts</param> /// <param name="typecreator">service used to create custom types</param> public PythonService(IScriptImportService importservice, ITypeCreator typecreator) { this.importservice = importservice; this.typecreator = typecreator; }
public GenericType(Type type, ICFType[] genericArgs) : this(ITypeCreator.Create(type), genericArgs) { }
public TypeFieldInfo(Type type, string name, string dmName) : this(ITypeCreator.Create(type), name, dmName) { }
public TypeInfo(string name, string dcNamespace, string dcName, TypeFieldInfo[] fieldInfos) : this(ITypeCreator.Create(typeof(object)), name, dcNamespace, dcName, fieldInfos) { }
public ListType(Type type) : this(ITypeCreator.Create(type)) { }
public ListType(string type) : this(ITypeCreator.Create(type)) { }
public BsonDeserializer(IMappingRegistry mappingRegistry, ITypeCreator typeCreator, IEnumerable <IJsonPrimitiveHandler> customPrimitiveHandlers = null) : base(mappingRegistry, typeCreator, customPrimitiveHandlers) { }
protected GenericDeserializer(IMappingRegistry mappingRegistry, ITypeCreator typeCreator, IEnumerable <IPrimitiveHandler <TSerializeState, TDeserializeState> > customPrimitiveHandlers) { MappingRegistry = mappingRegistry; TypeCreator = typeCreator; CustomPrimitiveHandlers = customPrimitiveHandlers ?? new IPrimitiveHandler <TSerializeState, TDeserializeState> [0]; }
private object CreateAndPopulate( Type type, string referenceName, LinkedList<object> buildChain, object[] args, ITypeCreator typeCreator) { var instance = CreateInstance(typeCreator, type, referenceName, buildChain, args); if (instance == null) { return null; } try { _buildChain.Push(instance); if (typeCreator.AutoPopulate) { // The type creator has indicated that this type should be auto populated by the execute strategy instance = PopulateInstance(instance); Debug.Assert(instance != null, "Populating the instance did not return the original instance"); } // Allow the type creator to do its own population of the instance instance = typeCreator.Populate(instance, this); var postBuildActions = Configuration.PostBuildActions?.Where(x => x.IsSupported(type, referenceName, BuildChain)) .OrderByDescending(x => x.Priority); if (postBuildActions != null) { foreach (var postBuildAction in postBuildActions) { postBuildAction.Execute(type, referenceName, BuildChain); } } return instance; } finally { _buildChain.Pop(); } }
private object CreateInstance( ITypeCreator typeCreator, Type type, string referenceName, LinkedList<object> buildChain, object[] args) { object item; if (args?.Length > 0) { // We have arguments so will just let the type creator do the work here item = typeCreator.Create(type, referenceName, buildChain, args); } else if (typeCreator.AutoDetectConstructor) { // Use constructor detection to figure out how to create this instance var constructor = Configuration.ConstructorResolver.Resolve(type, args); var parameterInfos = constructor.GetParameters(); if (parameterInfos.Length == 0) { item = typeCreator.Create(type, referenceName, buildChain); } else { // Get values for each of the constructor parameters var parameters = new Collection<object>(); foreach (var parameterInfo in parameterInfos) { var context = buildChain.Last?.Value; Log.CreateParameter(type, parameterInfo.ParameterType, parameterInfo.Name, context); // Recurse to build this parameter value var parameterValue = Build(parameterInfo.ParameterType, parameterInfo.Name, null); parameters.Add(parameterValue); } item = typeCreator.Create(type, referenceName, buildChain, parameters.ToArray()); } } else { // The type creator is going to be solely responsible for creating this instance item = typeCreator.Create(type, referenceName, buildChain); } return item; }