예제 #1
11
		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;
			}
		}
예제 #2
4
        /// <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);
        }
예제 #3
0
 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;
     }
 }
예제 #4
0
        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()));
        }
예제 #5
0
        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()));
        }
예제 #6
0
 /// <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;
 }
예제 #7
0
        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);
            }
        }
예제 #8
0
        //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()));
        }
예제 #9
0
파일: Column_T.cs 프로젝트: aTiKhan/RDO.Net
 internal sealed override void TryMakeConcrete()
 {
     if (!IsConcrete && !_isConcrete.HasValue)
     {
         _isConcrete = true;
         Debug.Assert(_valueManager == null);
         _valueManager = ValueManager.EnsureConcrete(this);
     }
 }
예제 #10
0
        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()));
        }
예제 #11
0
 public override object ParameterToScalar(IValueManager AManager, object AValue)
 {
     return
         (DateTime.ParseExact
          (
              (string)AValue,
              DateTimeFormat,
              DateTimeFormatInfo.InvariantInfo
          ));
 }
예제 #12
0
        public void Update(IValueManager manager, object oldValue, object newValue)
        {
            DisposeValue(manager, oldValue);
            InternalRemove(manager, oldValue);

            if (newValue != null)
            {
                InternalAdd(manager, newValue);
            }
        }
예제 #13
0
 public override object ToScalar(IValueManager manager, object tempValue)
 {
     if ((tempValue is string) && ((string)tempValue == " "))
     {
         return("");
     }
     else
     {
         return(tempValue);
     }
 }
예제 #14
0
 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;
 }
예제 #15
0
 protected override void Dispose(bool disposing)
 {
     if (Manager != null)
     {
                         #if LOCKROWTREE
         Manager.Unlock(Node.LockID);
                         #endif
         Manager = null;
     }
     base.Dispose(disposing);
 }
예제 #16
0
 public override object ToScalar(IValueManager AManager, object AValue)
 {
     if (AValue is bool)
     {
         return((bool)AValue);
     }
     else
     {
         return((int)AValue == 0 ? false : true);
     }
 }
예제 #17
0
 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
 }
예제 #18
0
        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)";
            }
        }
예제 #19
0
 public override object ToScalar(IValueManager AManager, object AValue)
 {
     if (AValue is string)
     {
         return(new Guid((string)AValue));
     }
     else
     {
         return((Guid)AValue);
     }
 }
예제 #20
0
 private void InternalAdd(IValueManager manager, NativeRow key, NativeRow data)
 {
     _manager = manager;
     try
     {
         _rows.Add(key, data);
     }
     finally
     {
         _manager = null;
     }
 }
예제 #21
0
        public override void Drop(IValueManager manager)
        {
            foreach (var key in _rows.Keys)
            {
                DisposeKey(manager, key);
            }

            foreach (var data in _rows.Values)
            {
                DisposeData(manager, data);
            }
        }
예제 #22
0
        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;
        }
예제 #23
0
 private void InternalAdd(IValueManager manager, object value)
 {
     _manager = manager;
     try
     {
         _elements.Add(value);
     }
     finally
     {
         _manager = null;
     }
 }
예제 #24
0
 public void Dispose()
 {
     if (_manager != null)
     {
                         #if USEFINALIZER
         System.GC.SuppressFinalize(this);
                         #endif
         Dispose(true);
         _manager  = null;
         _dataType = null;
     }
 }
예제 #25
0
 private void InternalRemove(IValueManager manager, NativeRow key)
 {
     _manager = manager;
     try
     {
         _rows.Remove(key);
     }
     finally
     {
         _manager = null;
     }
 }
예제 #26
0
        /// <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));
        }
예제 #27
0
		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;
			}
		}
예제 #28
0
        public override object FromScalar(IValueManager manager, object tempValue)
        {
            string localTempValue = (string)tempValue;

            if (localTempValue == String.Empty)
            {
                return(" ");
            }
            else
            {
                return(localTempValue);
            }
        }
예제 #29
0
        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();
            }
        }
예제 #30
0
		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());
		}
예제 #31
0
        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)));
        }
예제 #32
0
 void InitializeInstanceXafApplicationManager() {
     lock (_lockObject) {
         if (_instanceXafApplicationManager == null)
             _instanceXafApplicationManager = ValueManager.CreateValueManager<XafApplication>();
         if (_instanceXafApplicationManager.Value == null)
             _instanceXafApplicationManager.Value = base.Application;
     }
 }
예제 #33
0
 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;
     }
 }
예제 #34
0
 protected override void Dispose(bool disposing) {
     base.Dispose(disposing);
     _instanceXafApplicationManager = null;
     _instanceModelApplicationCreatorManager = null;
     _instanceXafApplicationManager = null;
 }