Example #1
0
 private static DA.Value ToEntity(DT.Value source, DA.Run run, DA.ValueNameCategory category, DA.OKBDataContext okb, List<DA.BinaryData> binCache) {
   if (source == null) return null;
   var entity = new DA.Value();
   entity.Run = run;
   entity.DataType = Convert.ToEntity(source.DataType, okb);
   if (source is DT.BoolValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Bool, okb);
     entity.BoolValue = ((DT.BoolValue)source).Value;
   } else if (source is DT.IntValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Int, okb);
     entity.IntValue = ((DT.IntValue)source).Value;
   } else if (source is DT.TimeSpanValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.TimeSpan, okb);
     entity.LongValue = ((DT.TimeSpanValue)source).Value;
   } else if (source is DT.LongValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Long, okb);
     entity.LongValue = ((DT.LongValue)source).Value;
   } else if (source is DT.FloatValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Float, okb);
     entity.FloatValue = ((DT.FloatValue)source).Value;
   } else if (source is DT.DoubleValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Double, okb);
     entity.DoubleValue = ((DT.DoubleValue)source).Value;
   } else if (source is DT.PercentValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Percent, okb);
     entity.DoubleValue = ((DT.PercentValue)source).Value;
   } else if (source is DT.StringValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.String, okb);
     entity.StringValue = ((DT.StringValue)source).Value;
   } else if (source is DT.BinaryValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Binary, okb);
     entity.BinaryData = Convert.ToEntity(((DT.BinaryValue)source).Value, okb, binCache);
   } else {
     throw new ArgumentException("Unknown value type.", "source");
   }
   return entity;
 }
        private static DA.Value ToEntity(DT.Value source, DA.Run run, DA.ValueNameCategory category, DA.OKBDataContext okb, List <DA.BinaryData> binCache)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new DA.Value();

            entity.Run      = run;
            entity.DataType = Convert.ToEntity(source.DataType, okb);
            if (source is DT.BoolValue)
            {
                entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Bool, okb);
                entity.BoolValue = ((DT.BoolValue)source).Value;
            }
            else if (source is DT.IntValue)
            {
                entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Int, okb);
                entity.IntValue  = ((DT.IntValue)source).Value;
            }
            else if (source is DT.TimeSpanValue)
            {
                entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.TimeSpan, okb);
                entity.LongValue = ((DT.TimeSpanValue)source).Value;
            }
            else if (source is DT.LongValue)
            {
                entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Long, okb);
                entity.LongValue = ((DT.LongValue)source).Value;
            }
            else if (source is DT.FloatValue)
            {
                entity.ValueName  = Convert.ToEntity(source.Name, category, DA.ValueNameType.Float, okb);
                entity.FloatValue = ((DT.FloatValue)source).Value;
            }
            else if (source is DT.DoubleValue)
            {
                entity.ValueName   = Convert.ToEntity(source.Name, category, DA.ValueNameType.Double, okb);
                entity.DoubleValue = ((DT.DoubleValue)source).Value;
            }
            else if (source is DT.PercentValue)
            {
                entity.ValueName   = Convert.ToEntity(source.Name, category, DA.ValueNameType.Percent, okb);
                entity.DoubleValue = ((DT.PercentValue)source).Value;
            }
            else if (source is DT.StringValue)
            {
                entity.ValueName   = Convert.ToEntity(source.Name, category, DA.ValueNameType.String, okb);
                entity.StringValue = ((DT.StringValue)source).Value;
            }
            else if (source is DT.BinaryValue)
            {
                entity.ValueName  = Convert.ToEntity(source.Name, category, DA.ValueNameType.Binary, okb);
                entity.BinaryData = Convert.ToEntity(((DT.BinaryValue)source).Value, okb, binCache);
            }
            else
            {
                throw new ArgumentException("Unknown value type.", "source");
            }
            return(entity);
        }
Example #3
0
 partial void DeleteValue(Value instance);
Example #4
0
 private static DT.Value ToDto(DA.Value source, bool includeBinaryValues)
 {
     if (source == null)
     {
         return(null);
     }
     if (source.ValueName.Type == DA.ValueNameType.Bool)
     {
         return(new DT.BoolValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.BoolValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Int)
     {
         return(new DT.IntValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.IntValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.TimeSpan)
     {
         return(new DT.TimeSpanValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Long)
     {
         return(new DT.LongValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Float)
     {
         return(new DT.FloatValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.FloatValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Double)
     {
         return(new DT.DoubleValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Percent)
     {
         return(new DT.PercentValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault()
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.String)
     {
         return(new DT.StringValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = source.StringValue
         });
     }
     else if (source.ValueName.Type == DA.ValueNameType.Binary)
     {
         return(new DT.BinaryValue {
             Name = source.ValueName.Name, DataType = Convert.ToDto(source.DataType), Value = includeBinaryValues ? source.BinaryData.Data.ToArray() : null
         });
     }
     else
     {
         throw new ArgumentException("Unknown value type.", "source");
     }
 }
Example #5
0
 partial void UpdateValue(Value instance);
Example #6
0
 partial void InsertValue(Value instance);
Example #7
0
		private void detach_Values(Value entity)
		{
			this.SendPropertyChanging();
			entity.Run = null;
		}
Example #8
0
		private void attach_Values(Value entity)
		{
			this.SendPropertyChanging();
			entity.Run = this;
		}
Example #9
0
		private void attach_Values(Value entity)
		{
			this.SendPropertyChanging();
			entity.BinaryData = this;
		}