private byte[] GetNativeValue(IValueManager AManager, object AValue) { if (AValue is byte[]) return (byte[])AValue; using (Scalar LScalar = new Scalar(AManager, ScalarType, (StreamID)AValue)) { return LScalar.AsByteArray; } }
/// <summary>Returns the host representation of the given native value. This is a by-reference operation.</summary> public static IDataValue FromNative(IValueManager manager, Schema.IDataType dataType, object tempValue) { // This code is duplicated in the Copy method and the FromNative overloads for performance Schema.IScalarType scalarType = dataType as Schema.IScalarType; if (scalarType != null) { if (tempValue is StreamID) { return(new Scalar(manager, scalarType, (StreamID)tempValue)); } if (scalarType.IsGeneric) { return(new Scalar(manager, (Schema.ScalarType)manager.GetRuntimeType(tempValue.GetType()), tempValue)); } return(new Scalar(manager, scalarType, tempValue)); } if (tempValue == null) { return(null); } Schema.IRowType rowType = dataType as Schema.IRowType; if (rowType != null) { return(new Row(manager, rowType, (NativeRow)tempValue)); } Schema.IListType listType = dataType as Schema.IListType; if (listType != null) { return(new ListValue(manager, listType, (NativeList)tempValue)); } Schema.ITableType tableType = dataType as Schema.ITableType; if (tableType != null) { return(new TableValue(manager, tableType, (NativeTable)tempValue)); } Schema.ICursorType cursorType = dataType as Schema.ICursorType; if (cursorType != null) { return(new CursorValue(manager, cursorType, (int)tempValue)); } var runtimeType = manager.GetRuntimeType(tempValue); if (runtimeType != null) { return(FromNative(manager, runtimeType, tempValue)); } throw new RuntimeException(RuntimeException.Codes.InvalidValueType, dataType == null ? "<null>" : dataType.GetType().Name); }
protected override void CustomizeModelApplicationCreatorProperties(ModelApplicationCreatorProperties creatorProperties) { base.CustomizeModelApplicationCreatorProperties(creatorProperties); lock (_lockObject) { if (_instanceModelApplicationCreatorPropertiesManager == null) _instanceModelApplicationCreatorPropertiesManager = ValueManager.CreateValueManager<ModelApplicationCreatorProperties>(); if (_instanceModelApplicationCreatorPropertiesManager.Value == null || _instanceModelApplicationCreatorPropertiesManager.Value != creatorProperties) _instanceModelApplicationCreatorPropertiesManager.Value = creatorProperties; } }
public override string ToLiteral(IValueManager AManager, object AValue) { if (AValue == null) { return(String.Format("cast(null as {0})", DomainName())); } return(String.Format("cast('{0}' as {1})", Convert.ToBase64String((byte[])AValue), DomainName())); }
public override string ToLiteral(IValueManager AManager, object AValue) { if (AValue == null) { return(String.Format("cast(null as {0})", DomainName())); } return(String.Format("cast('{0}' as {1})", ((DateTime)AValue).ToString(TimeFormat, DateTimeFormatInfo.InvariantInfo), DomainName())); }
/// <remarks> Scan range keys are inclusive. </remarks> public Scan(IValueManager manager, NativeTable table, NativeRowTree accessPath, ScanDirection direction, IRow firstKey, IRow lastKey) { _manager = manager; _table = table; _accessPath = accessPath; _direction = direction; _firstKey = firstKey; _lastKey = lastKey; }
public void Insert(IValueManager manager, IRow row, Database db) { if (row.HasValue(0)) { object[] items = ((NativeRow)row.AsNative).Values; db.Include(_columns, items[0], items); } }
//public CacheSQLBoolean(ScalarType AScalarType, D4.ClassDefinition AClassDefinition) : base(AScalarType, AClassDefinition){} //public CacheSQLBoolean(ScalarType AScalarType, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AScalarType, AClassDefinition, AIsSystem){} public override string ToLiteral(IValueManager AManager, object AValue) { if (AValue == null) { return(String.Format("cast(null as {0})", DomainName())); } return(String.Format("cast({0} as {1})", (bool)AValue ? "1" : "0", DomainName())); }
internal sealed override void TryMakeConcrete() { if (!IsConcrete && !_isConcrete.HasValue) { _isConcrete = true; Debug.Assert(_valueManager == null); _valueManager = ValueManager.EnsureConcrete(this); } }
public override string ToLiteral(IValueManager AManager, object AValue) { if (AValue == null) { return(String.Format("cast(null as {0})", DomainName())); } return(String.Format("cast('{0}' as {1})", (Guid)AValue, DomainName())); }
public override object ParameterToScalar(IValueManager AManager, object AValue) { return (DateTime.ParseExact ( (string)AValue, DateTimeFormat, DateTimeFormatInfo.InvariantInfo )); }
public void Update(IValueManager manager, object oldValue, object newValue) { DisposeValue(manager, oldValue); InternalRemove(manager, oldValue); if (newValue != null) { InternalAdd(manager, newValue); } }
public override object ToScalar(IValueManager manager, object tempValue) { if ((tempValue is string) && ((string)tempValue == " ")) { return(""); } else { return(tempValue); } }
public Row(IValueManager manager, Schema.IRowType dataType) : base(manager, dataType) { _row = new NativeRow(DataType.Columns.Count); #if USEDATATYPESINNATIVEROW for (int index = 0; index < DataType.Columns.Count; index++) { _row.DataTypes[index] = DataType.Columns[index].DataType; } #endif ValuesOwned = true; }
protected override void Dispose(bool disposing) { if (Manager != null) { #if LOCKROWTREE Manager.Unlock(Node.LockID); #endif Manager = null; } base.Dispose(disposing); }
public override object ToScalar(IValueManager AManager, object AValue) { if (AValue is bool) { return((bool)AValue); } else { return((int)AValue == 0 ? false : true); } }
public RowTreeNode(IValueManager manager, NativeRowTree tree, NativeRowTreeNode node, LockMode lockMode) { Manager = manager; Tree = tree; Node = node; DataNode = Node as NativeRowTreeDataNode; RoutingNode = Node as NativeRowTreeRoutingNode; #if LOCKROWTREE Manager.Lock(Node.LockID, ALockMode); #endif }
public override void CustomizeTypesInfo(ITypesInfo typesInfo) { base.CustomizeTypesInfo(typesInfo); CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo); IValueManager <string> valueManager = ValueManager.GetValueManager <string>("FullName"); if (valueManager.CanManageValue) { valueManager.Value = "concat(FirstName, ' ', LastName)"; } }
public override object ToScalar(IValueManager AManager, object AValue) { if (AValue is string) { return(new Guid((string)AValue)); } else { return((Guid)AValue); } }
private void InternalAdd(IValueManager manager, NativeRow key, NativeRow data) { _manager = manager; try { _rows.Add(key, data); } finally { _manager = null; } }
public override void Drop(IValueManager manager) { foreach (var key in _rows.Keys) { DisposeKey(manager, key); } foreach (var data in _rows.Values) { DisposeData(manager, data); } }
public void Drop(IValueManager manager) { for (int index = NonClusteredIndexes.Count - 1; index >= 0; index--) { NonClusteredIndexes[index].Drop(manager); NonClusteredIndexes.RemoveAt(index); } ClusteredIndex.Drop(manager); _rowCount = 0; }
private void InternalAdd(IValueManager manager, object value) { _manager = manager; try { _elements.Add(value); } finally { _manager = null; } }
public void Dispose() { if (_manager != null) { #if USEFINALIZER System.GC.SuppressFinalize(this); #endif Dispose(true); _manager = null; _dataType = null; } }
private void InternalRemove(IValueManager manager, NativeRow key) { _manager = manager; try { _rows.Remove(key); } finally { _manager = null; } }
/// <summary> /// Compares two native values directly. /// </summary> /// <remarks> /// The method expects both values to be non-null. /// The method uses direct comparison, it does not attempt to invoke the D4 equality operator for the values. /// Note that this method expects that neither argument is null. /// </remarks> /// <returns>True if the values are equal, false otherwise.</returns> public static bool NativeValuesEqual(IValueManager manager, object LOldValue, object LCurrentValue) { if (((LOldValue is StreamID) || (LOldValue is byte[])) && ((LCurrentValue is StreamID) || (LCurrentValue is byte[]))) { Stream oldStream = LOldValue is StreamID ? manager.StreamManager.Open((StreamID)LOldValue, LockMode.Exclusive) : new MemoryStream((byte[])LOldValue, false); try { Stream currentStream = LCurrentValue is StreamID ? manager.StreamManager.Open((StreamID)LCurrentValue, LockMode.Exclusive) : new MemoryStream((byte[])LCurrentValue, false); try { bool valuesEqual = true; int oldByte; int currentByte; while (valuesEqual) { oldByte = oldStream.ReadByte(); currentByte = currentStream.ReadByte(); if (oldByte != currentByte) { valuesEqual = false; break; } if (oldByte == -1) { break; } } return(valuesEqual); } finally { currentStream.Close(); } } finally { oldStream.Close(); } } return(LOldValue.Equals(LCurrentValue)); }
public override Stream GetStreamAdapter(IValueManager AManager, Stream AStream) { using (StreamReader LReader = new StreamReader(AStream)) { string LValue = LReader.ReadToEnd(); Streams.IConveyor LConveyor = AManager.GetConveyor(ScalarType); MemoryStream LStream = new MemoryStream(LConveyor.GetSize(LValue)); LStream.SetLength(LStream.GetBuffer().Length); LConveyor.Write(LValue, LStream.GetBuffer(), 0); return LStream; } }
public override object FromScalar(IValueManager manager, object tempValue) { string localTempValue = (string)tempValue; if (localTempValue == String.Empty) { return(" "); } else { return(localTempValue); } }
public bool HasRow(IValueManager manager, IRow row) { IRow key = GetIndexData(manager, Index.KeyRowType, new IRow[] { row }); try { return(Index.ContainsKey(manager, (NativeRow)key.AsNative)); } finally { key.Dispose(); } }
public virtual string ToLiteral(IValueManager AManager, object AValue) { if (AValue == null) return String.Format("cast(null as {0})", DomainName()); object LValue = FromScalar(AManager, AValue); string LString = LValue as string; if (LString != null) return String.Format("cast('{0}' as {1})", LString.Replace("'", "''"), DomainName()); return String.Format("cast('{0}' as {1})", LValue.ToString(), DomainName()); }
public override object ToScalar(IValueManager AManager, object AValue) { var LDateTime = (DateTime)AValue; // If the value is equal to the Device's zero date, set it to Dataphor's zero date if (LDateTime == MSSQLDateTime.MinValue) { LDateTime = DateTime.MinValue; } long LTicks = LDateTime.Ticks; return(new DateTime(LTicks - (LTicks % TimeSpan.TicksPerDay))); }
void InitializeInstanceXafApplicationManager() { lock (_lockObject) { if (_instanceXafApplicationManager == null) _instanceXafApplicationManager = ValueManager.CreateValueManager<XafApplication>(); if (_instanceXafApplicationManager.Value == null) _instanceXafApplicationManager.Value = base.Application; } }
void ApplicationOnSetupComplete(object sender, EventArgs eventArgs) { lock (_lockObject) { if (_instanceModelApplicationCreatorManager == null) _instanceModelApplicationCreatorManager = ValueManager.CreateValueManager<ModelApplicationCreator>(); if (_instanceModelApplicationCreatorManager.Value == null) _instanceModelApplicationCreatorManager.Value = ((ModelApplicationBase)Application.Model).CreatorInstance; } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _instanceXafApplicationManager = null; _instanceModelApplicationCreatorManager = null; _instanceXafApplicationManager = null; }