Exemplo n.º 1
0
 internal static bool IsWildcard(SpecialMapping mapping)
 {
     if (mapping is SerializableMapping)
     {
         return(((SerializableMapping)mapping).IsAny);
     }
     return(mapping.TypeDesc.CanBeElementValue);
 }
Exemplo n.º 2
0
        public static List <SpecialMapping> GetSpecialMappingList(string script)
        {
            List <SpecialMapping> specialmapping = new List <SpecialMapping>();
            DataTable             dt             = GetDataTable(script, DestinationDBConnectionStr);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SpecialMapping smp = new SpecialMapping();
                smp.Concept = dt.Rows[i][0].ToString();
                smp.ReferenceDBColumnname    = dt.Rows[i][1].ToString();
                smp.DestionationDBColumnname = dt.Rows[i][2].ToString();
                smp.Key = dt.Rows[i][3].ToString();
                specialmapping.Add(smp);
            }

            return(specialmapping);
        }
        private void WriteText(object o, TextAccessor text)
        {
            if (text.Mapping is PrimitiveMapping)
            {
                PrimitiveMapping mapping = (PrimitiveMapping)text.Mapping;
                string           stringValue;
                if (text.Mapping is EnumMapping)
                {
                    stringValue = WriteEnumMethod((EnumMapping)mapping, o);
                }
                else
                {
                    if (!WritePrimitiveValue(mapping.TypeDesc, o, false, out stringValue))
                    {
                        // #10593: Add More Tests for Serialization Code
                        Debug.Assert(o is byte[]);
                    }
                }

                if (o is byte[])
                {
                    WriteValue((byte[])o);
                }
                else
                {
                    WriteValue(stringValue);
                }
            }
            else if (text.Mapping is SpecialMapping)
            {
                SpecialMapping mapping = (SpecialMapping)text.Mapping;
                switch (mapping.TypeDesc.Kind)
                {
                case TypeKind.Node:
                    ((XmlNode)o).WriteTo(Writer);
                    break;

                default:
                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
                }
            }
        }
 private void WriteAttribute(object memberValue, AttributeAccessor attribute, object parent)
 {
     if (attribute.Mapping is SpecialMapping)
     {
         SpecialMapping special = (SpecialMapping)attribute.Mapping;
         if (special.TypeDesc.Kind == TypeKind.Attribute || special.TypeDesc.CanBeAttributeValue)
         {
             WriteXmlAttribute((XmlNode)memberValue, parent);
         }
         else
         {
             throw new InvalidOperationException(SR.XmlInternalError);
         }
     }
     else
     {
         string ns = attribute.Form == XmlSchemaForm.Qualified ? attribute.Namespace : "";
         WritePrimitive(WritePrimitiveMethodRequirement.WriteAttribute, attribute.Name, ns, attribute.Default, memberValue, attribute.Mapping, false, false, false);
     }
 }