当前位置: 首页>>代码示例>>C#>>正文


C# MappingAction类代码示例

本文整理汇总了C#中MappingAction的典型用法代码示例。如果您正苦于以下问题:C# MappingAction类的具体用法?C# MappingAction怎么用?C# MappingAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MappingAction类属于命名空间,在下文中一共展示了MappingAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialize

 public static XmlDocument Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingAction action)
 {
   Stream stm = new MemoryStream();
   XmlTextWriter xtw = new XmlTextWriter(stm, Encoding.UTF8);
   xtw.Formatting = Formatting.Indented;
   xtw.Indentation = 2;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   stm.Position = 0;    
   TextReader trdr = new StreamReader(stm, new UTF8Encoding(), true, 4096);
   String s = trdr.ReadLine();
   while (s != null)
   {
     //Console.WriteLine(s);
     s = trdr.ReadLine();
   }            
   stm.Position = 0;    
   XmlDocument xdoc = new XmlDocument();
   xdoc.PreserveWhitespace = true;
   xdoc.Load(stm);
   return xdoc;
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:29,代码来源:utils.cs

示例2: Parse

 public static object Parse(
     XmlReader rdr,
     Type valueType,
     MappingAction action,
     out Type parsedType,
     out Type parsedArrayType)
 {
     parsedType = parsedArrayType = null;
     rdr.ReadToDescendant("value");
     var mappingStack = new MappingStack("request");
     return new XmlRpcDeserializer().ParseValueElement(rdr, valueType, mappingStack, action);
 }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:12,代码来源:Utils.cs

示例3: Parse

 //----------------------------------------------------------------------// 
 public static object Parse(
   string xml, 
   Type valueType, 
   MappingAction action,
   out Type parsedType,
   out Type parsedArrayType)
 {
   StringReader sr = new StringReader(xml);
   XmlReader rdr = XmlRpcXmlReader.Create(sr);
   return Parse(rdr, valueType, action, 
     out parsedType, out parsedArrayType);
 }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:13,代码来源:utils.cs

示例4: Parse

 //----------------------------------------------------------------------// 
 public static object Parse(
   string xml, 
   Type valueType, 
   MappingAction action,
   out Type parsedType,
   out Type parsedArrayType)
 {
   StringReader sr = new StringReader(xml);
   XmlDocument xdoc = new XmlDocument();
   xdoc.PreserveWhitespace = true;
   xdoc.Load(sr);        
   return Parse(xdoc, valueType, action, 
     out parsedType, out parsedArrayType);
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:15,代码来源:utils.cs

示例5: SerializeToString

 public static string SerializeToString(
   string testName,
   object obj, 
   MappingAction action)
 {
   StringWriter strwrtr = new StringWriter();
   XmlTextWriter xtw = new XmlTextWriter(strwrtr);
   //      xtw.Formatting = formatting;
   //      xtw.Indentation = indentation;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   //Console.WriteLine(strwrtr.ToString());
   return strwrtr.ToString();
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:17,代码来源:utils.cs

示例6: ParseFault

        private XmlRpcFaultException ParseFault(IEnumerator<Node> iter, MappingStack parseStack,
                                                MappingAction mappingAction)
        {
            iter.MoveNext();
            Type mappedType;
            var xmlRpcStruct = MapHashtable(iter, null, parseStack, mappingAction, out mappedType) as XmlRpcStruct;
            
            object obj1 = xmlRpcStruct["faultCode"];
            object obj2 = xmlRpcStruct["faultString"];
            if (obj1 is string)
            {
                int result;
                if (!int.TryParse(obj1 as string, out result))
                    throw new XmlRpcInvalidXmlRpcException("faultCode not int or string");
                obj1 = result;
            }
            return new XmlRpcFaultException((int)obj1, (string)obj2);

        }
开发者ID:ChrisASearles,项目名称:Infusionsoft.net,代码行数:19,代码来源:XmlRpcResponseDeserializer.cs

示例7: ParseValue

   Object ParseValue(
 XmlNode node, 
 Type ValueType, 
 ParseStack parseStack,
 MappingAction mappingAction)
   {
       Type parsedType;
         Type parsedArrayType;
         return ParseValue(node, ValueType, parseStack, mappingAction,
       out parsedType, out parsedArrayType);
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:11,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例8: ParseStruct

        Object ParseStruct(
      XmlNode node, 
      Type valueType,
      ParseStack parseStack,
      MappingAction mappingAction)
        {
            if (valueType.IsPrimitive)
              {
            throw new XmlRpcTypeMismatchException(parseStack.ParseType
              + " contains struct value where "
              + XmlRpcServiceInfo.GetXmlRpcTypeString(valueType)
              + " expected " + StackDump(parseStack));
              }
            #if !FX1_0
              if (valueType.IsGenericType
            && valueType.GetGenericTypeDefinition() == typeof(Nullable<>))
              {
            valueType = valueType.GetGenericArguments()[0];
              }
            #endif
              object retObj;
              try
              {
            retObj = Activator.CreateInstance(valueType);
              }
              catch (Exception ex)
              {
            throw new XmlRpcTypeMismatchException(parseStack.ParseType
              + " contains struct value where "
              + XmlRpcServiceInfo.GetXmlRpcTypeString(valueType)
              + " expected (as type " + valueType.Name + ") "
              + StackDump(parseStack));
              }
              // Note: mapping action on a struct is only applied locally - it
              // does not override the global mapping action when members of the
              // struct are parsed
              MappingAction localAction = mappingAction;
              if (valueType != null)
              {
            parseStack.Push("struct mapped to type " + valueType.Name);
            localAction = StructMappingAction(valueType, mappingAction);
              }
              else
              {
            parseStack.Push("struct");
              }
              // create map of field names and remove each name from it as
              // processed so we can determine which fields are missing
              // TODO: replace HashTable with lighter collection
              Hashtable names = new Hashtable();
              foreach (FieldInfo fi in valueType.GetFields())
              {
            names.Add(fi.Name, fi.Name);
              }
              foreach (PropertyInfo pi in valueType.GetProperties())
              {
            names.Add(pi.Name, pi.Name);
              }
              XmlNodeList members = node.SelectNodes("./member");
              int fieldCount = 0;
              foreach (XmlNode member in members)
              {
            if (member.Name != "member")
              continue;
            XmlNode nameNode;
            bool dupName;
            XmlNode valueNode;
            bool dupValue;
            SelectTwoNodes(member, "name", out nameNode, out dupName, "value",
              out valueNode, out dupValue);
            if (nameNode == null)
              throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
            + " contains a member with missing name element"
            + " " + StackDump(parseStack));
            if (dupName)
              throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
            + " contains member with more than one name element"
            + " " + StackDump(parseStack));
            string name = nameNode.FirstChild.Value;
            if (valueNode == null)
              throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
            + " contains struct member " + name + " with missing value "
            + " " + StackDump(parseStack));
            if (dupValue)
              throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
            + " contains member with more than one value element"
            + " " + StackDump(parseStack));
            string structName = GetStructName(valueType, name);
            if (structName != null)
              name = structName;
            if (names.Contains(name))
              names.Remove(name);
            else
            {
              if (!IgnoreDuplicateMembers
              && (valueType.GetField(name) != null || valueType.GetProperty(name) != null))
            throw new XmlRpcInvalidXmlRpcException(parseStack.ParseType
              + " contains struct value with duplicate member "
              + nameNode.FirstChild.Value
              + " " + StackDump(parseStack));
//.........这里部分代码省略.........
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:101,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例9: ParseString

   Object ParseString(
 XmlNode node, 
 Type ValueType,
 ParseStack parseStack,
 MappingAction mappingAction)
   {
       if (ValueType != null && ValueType != typeof(System.String)
       && ValueType != typeof(Object))
         {
       throw new XmlRpcTypeMismatchException(parseStack.ParseType
         + " contains string value where "
         + XmlRpcServiceInfo.GetXmlRpcTypeString(ValueType)
         + " expected " + StackDump(parseStack));
         }
         string ret;
         parseStack.Push("string");
         try
         {
       if (node.FirstChild == null)
         ret = "";
       else
         ret = node.FirstChild.Value;
         }
         finally
         {
       parseStack.Pop();
         }
         return ret;
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:29,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例10: ParseMultiDimElements

   void ParseMultiDimElements(XmlNode node, int Rank, int CurRank, 
 Type elemType, ArrayList elements, int[] dimLengths, 
 ParseStack parseStack, MappingAction mappingAction)
   {
       if (node.Name != "array")
         {
       throw new XmlRpcTypeMismatchException(
         "param element does not contain array element.");
         }
         XmlNode dataNode = node.SelectSingleNode("./data");
         XmlNodeList childNodes = dataNode.SelectNodes("./value");
         int nodeCount = childNodes.Count;
         //!! check that multi dim array is not jagged
         if (dimLengths[CurRank] != 0 && nodeCount != dimLengths[CurRank])
         {
       throw new XmlRpcNonRegularArrayException(
         "Multi-dimensional array must not be jagged.");
         }
         dimLengths[CurRank] = nodeCount;  // in case first array at this rank
         if (CurRank < (Rank-1))
         {
       foreach (XmlNode vNode in childNodes)
       {
         XmlNode arrayNode = vNode.SelectSingleNode("./array");
         ParseMultiDimElements(arrayNode, Rank, CurRank+1, elemType,
       elements, dimLengths, parseStack, mappingAction);
       }
         }
         else
         {
       foreach (XmlNode vNode in childNodes)
       {
         XmlNode vvNode = vNode.SelectSingleNode("./*");
         if (node == null)
       node = vNode.FirstChild;
         elements.Add(ParseValue(vvNode, elemType, parseStack,
       mappingAction));
       }
         }
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:40,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例11: ParseArray

   Object ParseArray(
 XmlNode node, 
 Type ValueType,
 ParseStack parseStack,
 MappingAction mappingAction)
   {
       // required type must be an array
         if (ValueType != null
       && !(ValueType.IsArray == true
       || ValueType == typeof(Array)
       || ValueType == typeof(object)))
         {
       throw new XmlRpcTypeMismatchException(parseStack.ParseType
         + " contains array value where "
         + XmlRpcServiceInfo.GetXmlRpcTypeString(ValueType)
         + " expected " + StackDump(parseStack));
         }
         if (ValueType != null)
         {
       XmlRpcType xmlRpcType = XmlRpcServiceInfo.GetXmlRpcType(ValueType);
       if (xmlRpcType == XmlRpcType.tMultiDimArray)
       {
         parseStack.Push("array mapped to type " + ValueType.Name);
         Object ret = ParseMultiDimArray(node, ValueType, parseStack,
       mappingAction);
         return ret;
       }
       parseStack.Push("array mapped to type " + ValueType.Name);
         }
         else
       parseStack.Push("array");
         XmlNode dataNode = node.SelectSingleNode("./data");
         XmlNodeList childNodes = dataNode.SelectNodes("./value");
         int nodeCount = childNodes.Count;
         Object[] elements = new Object[nodeCount];
         // determine type of array elements
         Type elemType = null;
         if (ValueType != null
       && ValueType != typeof(Array)
       && ValueType != typeof(object))
         {
       #if (!COMPACT_FRAMEWORK)
       elemType = ValueType.GetElementType();
       #else
       string[] checkMultiDim = Regex.Split(ValueType.FullName,
         "\\[\\]$");
       // determine assembly of array element type
       Assembly asmbly = ValueType.Assembly;
       string[] asmblyName = asmbly.FullName.Split(',');
       string elemTypeName = checkMultiDim[0] + ", " + asmblyName[0];
       elemType = Type.GetType(elemTypeName);
       #endif
         }
         else
         {
       elemType = typeof(object);
         }
         bool bGotType = false;
         Type useType = null;
         int i = 0;
         foreach (XmlNode vNode in childNodes)
         {
       parseStack.Push(String.Format("element {0}", i));
       XmlNode vvNode = vNode.SelectSingleNode("./*");
       if (vvNode == null)
         vvNode = vNode.FirstChild;
       Type parsedType;
       Type parsedArrayType;
       elements[i++] = ParseValue(vvNode, elemType, parseStack, mappingAction,
                               out parsedType, out parsedArrayType);
       if (bGotType == false)
       {
         useType = parsedArrayType;
         bGotType = true;
       }
       else
       {
         if (useType != parsedArrayType)
       useType = null;
       }
       parseStack.Pop();
         }
         Object[] args = new Object[1]; args[0] = nodeCount;
         Object retObj = null;
         if (ValueType != null
       && ValueType != typeof(Array)
       && ValueType != typeof(object))
         {
       retObj = CreateArrayInstance(ValueType, args);
         }
         else
         {
       if (useType == null)
         retObj = CreateArrayInstance(typeof(object[]), args);
       else
         retObj = CreateArrayInstance(useType, args);
         }
         for (int j=0; j < elements.Length; j++)
         {
       ((Array)retObj).SetValue(elements[j], j);
//.........这里部分代码省略.........
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:101,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例12: ParseBoolean

   Object ParseBoolean(
 XmlNode node, 
 Type ValueType,
 ParseStack parseStack,
 MappingAction mappingAction)
   {
       if (ValueType != null && ValueType != typeof(Object)
       && ValueType != typeof(System.Boolean)
       #if !FX1_0
       && ValueType != typeof(bool?)
       #endif
       && ValueType != typeof(XmlRpcBoolean))
         {
       throw new XmlRpcTypeMismatchException(parseStack.ParseType
         + " contains boolean value where "
         + XmlRpcServiceInfo.GetXmlRpcTypeString(ValueType)
         + " expected " + StackDump(parseStack));
         }
         bool retVal;
         parseStack.Push("boolean");
         try
         {
       string s = node.FirstChild.Value;
       if (s == "1")
       {
         retVal = true;
       }
       else if (s == "0")
       {
         retVal = false;
       }
       else
       {
         throw new XmlRpcInvalidXmlRpcException(
       "reponse contains invalid boolean value "
       + StackDump(parseStack));
       }
         }
         finally
         {
       parseStack.Pop();
         }
         if (ValueType == typeof(XmlRpcBoolean))
       return new XmlRpcBoolean(retVal);
         else
       return retVal;
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:47,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例13: BuildArrayXml

   void BuildArrayXml(
 XmlTextWriter xtw, 
 Array ary, 
 int CurRank, 
 int[] indices,
 MappingAction mappingAction,
 ArrayList nestedObjs)
   {
       xtw.WriteStartElement("", "array", "");
         xtw.WriteStartElement("", "data", "");
         if (CurRank < (ary.Rank-1))
         {
       for (int i=0; i<ary.GetLength(CurRank); i++)
       {
         indices[CurRank] = i;
         xtw.WriteStartElement("", "value", "");
         BuildArrayXml(xtw, ary, CurRank+1, indices, mappingAction, nestedObjs);
         xtw.WriteEndElement();
       }
         }
         else
         {
       for (int i=0; i<ary.GetLength(CurRank); i++)
       {
         indices[CurRank] = i;
         Serialize(xtw, ary.GetValue(indices), mappingAction, nestedObjs);
       }
         }
         xtw.WriteEndElement();
         xtw.WriteEndElement();
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:31,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例14: Serialize

   //#if (DEBUG)
   //#endif
   public void Serialize(
 XmlTextWriter xtw, 
 Object o,
 MappingAction mappingAction)
   {
       Serialize(xtw, o, mappingAction, new ArrayList(16));
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:9,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs

示例15: StructMappingAction

   MappingAction StructMappingAction(
 Type type,
 MappingAction currentAction)
   {
       // if struct member has mapping action attribute, override the current
         // mapping action else just return the current action
         if (type == null)
       return currentAction;
         Attribute attr = Attribute.GetCustomAttribute(type,
       typeof(XmlRpcMissingMappingAttribute));
         if (attr != null)
       return ((XmlRpcMissingMappingAttribute)attr).Action;
         return currentAction;
   }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:14,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs


注:本文中的MappingAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。