Ejemplo n.º 1
0
 internal void LoadFromXml(XmlNode node)
 {
     try
     {
         this.FSourceNode        = node;
         this.FPurpose           = (MetadataPropertyPurpose)XmlUtils.GetEnumAttr(node, "purpose", MetadataProperty.FPurposeNames);
         this.FCaption           = XmlUtils.GetAttr(node, "caption", this.FCaption);
         this.FDataField         = XmlUtils.GetAttr(node, "data-field", this.FDataField);
         this.FDataTypeName      = XmlUtils.GetAttr(node, "data-type", this.FDataTypeName);
         this.FDataType          = InDbUtils.InMetaDataTypeToDataType(this.FDataTypeName);
         this.FDataLength        = XmlUtils.GetIntAttr(node, "data-length", this.FDataLength);
         this.FInitialValue      = XmlUtils.GetAttr(node, "default-value", this.FInitialValue);
         this.FIsExtension       = XmlUtils.GetBoolAttr(node, "is-virtual", this.FIsExtension);
         this.FExtensionClass    = XmlUtils.GetAttr(node, "virtual-aggregation", this.FExtensionClass);
         this.FExtensionProperty = XmlUtils.GetAttr(node, "virtual-ref-property", this.FExtensionProperty);
         if (this.FDataField.Length == 0)
         {
             this.FDataField = this.Name;
         }
         if (this.FDataType == DataType.Unknown)
         {
             throw new MetadataException("Не задан тип данных");
         }
         this.FMemberName = XmlUtils.GetAttr(node, "prog-id", this.Name);
         this.LookupValues.LoadFromXml(node);
     }
     catch (Exception ex)
     {
         throw new MetadataException(string.Format("Ошибка загрузки метаданных свойства {0}", (object)this.Name), ex);
     }
 }
Ejemplo n.º 2
0
        internal override int SaveValueToDb(ref object value, ref object exValue)
        {
            if (!this.IsAssigned)
            {
                throw new DataException("Попытка записать в БД неприсвоенное значение.");
            }
            MetadataAssociationRefList refs = this.Metadata.Association.Refs;
            DataObject dataObject           = (DataObject)base.GetValue();

            if (dataObject != null && !dataObject.IsNull)
            {
                value = (object)dataObject.Id.ToString();
                if (this.Metadata.Association.Selector != null)
                {
                    exValue = InDbUtils.Convert((object)refs.Need(dataObject.Class).SelectorValue, this.Metadata.Association.Selector.DataType);
                }
            }
            return(this.Metadata.Association.Selector != null ? 2 : 1);
        }
Ejemplo n.º 3
0
 public static void ConvertObjectsToInDbParams(
     object[] args,
     out DataType[] types,
     out object[] values)
 {
     if (args == null || args.Length == 0)
     {
         types  = (DataType[])null;
         values = (object[])null;
     }
     else
     {
         types  = new DataType[args.Length];
         values = new object[args.Length];
         for (int index = 0; index < args.Length; ++index)
         {
             object compatibleParamValue = SqlUtils.GetInDbCompatibleParamValue(args[index]);
             types[index]  = InDbUtils.TypeCodeToDataType(Type.GetTypeCode(compatibleParamValue.GetType()));
             values[index] = compatibleParamValue;
         }
     }
 }