public void AddColumnPrescriptions() { var fileName = Temporary.GetTempFilePath(); var project = CreateProject(); ValueFactoryManager.Initialize(); var i = 0; foreach (var tableDescription in project.Descriptor.TableDescriptions) { var tablePrescription = new TablePrescription(tableDescription); foreach (var columnDescription in tableDescription.ColumnDescriptions) { if (columnDescription.Identity != null || !columnDescription.IsWritable()) { continue; } var type = columnDescription.UserType switch { "sql_variant" => typeof(int), _ => SqlTypeUtility.GetDataType(columnDescription.UserType, columnDescription.MaxLength), }; var factory = ValueFactoryManager.ValueFactoryInfos.FilterByType(type).FirstOrDefault(); Assert.NotNull(factory); var configuration = factory.Configurator.CreateConfiguration(); var valueFactoryPrescription = new ValueFactoryPrescription(factory.Name + i++, factory.Name, configuration); project.Prescriptor.AddValueFactory(valueFactoryPrescription); var columnPrescription = new ColumnPrescription(columnDescription, valueFactoryPrescription, null); tablePrescription.AddColumn(columnPrescription); } project.Prescriptor.AddTable(tablePrescription); } ProjectManager.SaveToFile(project, fileName); Output.WriteLine(File.ReadAllText(fileName)); var project2 = ProjectManager.LoadFromFile(fileName); IoAssert.AsExpected(project2); }
public void AddAllValueFactories() { var fileName = Temporary.GetTempFilePath(); var project = CreateProject(); ValueFactoryManager.Initialize(); foreach (var factory in ValueFactoryManager.ValueFactoryInfos) { var configuration = factory.Configurator.CreateConfiguration(); var valueFactoryPrescription = new ValueFactoryPrescription("default-" + factory.Name, factory.Name, configuration); project.Prescriptor.AddValueFactory(valueFactoryPrescription); } ProjectManager.SaveToFile(project, fileName); Output.WriteLine(File.ReadAllText(fileName)); var project2 = ProjectManager.LoadFromFile(fileName); IoAssert.AsExpected(project2); }
private int _valueIdIndex; // The ID of the next instance to unmarshal. #endregion Fields #region Constructors internal EncapsDecoder11(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr, CompactIdResolver r) : base(stream, encaps, sliceValues, f, cr) { _compactIdResolver = r; _current = null; _valueIdIndex = 1; }
internal EncapsDecoder10(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr) : base(stream, encaps, sliceValues, f, cr) { _sliceType = SliceType.NoSlice; }
internal EncapsDecoder(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr) { _stream = stream; _encaps = encaps; _sliceValues = sliceValues; _valueFactoryManager = f; _classResolver = cr; _typeIdIndex = 0; _unmarshaledMap = new Dictionary<int, Ice.Object>(); }
private void initialize(IceInternal.Instance instance, EncodingVersion encoding) { initialize(encoding); instance_ = instance; _traceSlicing = instance_.traceLevels().slicing > 0; _valueFactoryManager = instance_.initializationData().valueFactoryManager; _logger = instance_.initializationData().logger; _classResolver = instance_.resolveClass; }
/// <summary> /// Swaps the contents of one stream with another. /// </summary> /// <param name="other">The other stream.</param> public void swap(InputStream other) { Debug.Assert(instance_ == other.instance_); IceInternal.Buffer tmpBuf = other._buf; other._buf = _buf; _buf = tmpBuf; EncodingVersion tmpEncoding = other._encoding; other._encoding = _encoding; _encoding = tmpEncoding; bool tmpTraceSlicing = other._traceSlicing; other._traceSlicing = _traceSlicing; _traceSlicing = tmpTraceSlicing; object tmpClosure = other._closure; other._closure = _closure; _closure = tmpClosure; bool tmpSliceValues = other._sliceValues; other._sliceValues = _sliceValues; _sliceValues = tmpSliceValues; // // Swap is never called for InputStreams that have encapsulations being read. However, // encapsulations might still be set in case un-marshalling failed. We just // reset the encapsulations if there are still some set. // resetEncapsulation(); other.resetEncapsulation(); int tmpStartSeq = other._startSeq; other._startSeq = _startSeq; _startSeq = tmpStartSeq; int tmpMinSeqSize = other._minSeqSize; other._minSeqSize = _minSeqSize; _minSeqSize = tmpMinSeqSize; ValueFactoryManager tmpVfm = other._valueFactoryManager; other._valueFactoryManager = _valueFactoryManager; _valueFactoryManager = tmpVfm; Logger tmpLogger = other._logger; other._logger = _logger; _logger = tmpLogger; CompactIdResolver tmpCompactIdResolver = other._compactIdResolver; other._compactIdResolver = _compactIdResolver; _compactIdResolver = tmpCompactIdResolver; ClassResolver tmpClassResolver = other._classResolver; other._classResolver = _classResolver; _classResolver = tmpClassResolver; }
/// <summary> /// Sets the value factory manager to use when marshaling value instances. If the stream /// was initialized with a communicator, the communicator's value factory manager will /// be used by default. /// </summary> /// <param name="vfm">The value factory manager.</param> public void setValueFactoryManager(ValueFactoryManager vfm) { _valueFactoryManager = vfm; }