Example #1
0
 public static KeyValueUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new KeyValueUnmarshaller();
     }
     return(instance);
 }
        public HadoopJarStepConfig Unmarshall(XmlUnmarshallerContext context)
        {
            HadoopJarStepConfig hadoopJarStepConfig = new HadoopJarStepConfig();
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Properties/member", targetDepth))
                    {
                        hadoopJarStepConfig.Properties.Add(KeyValueUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("Jar", targetDepth))
                    {
                        hadoopJarStepConfig.Jar = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("MainClass", targetDepth))
                    {
                        hadoopJarStepConfig.MainClass = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Args/member", targetDepth))
                    {
                        hadoopJarStepConfig.Args.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return(hadoopJarStepConfig);
                }
            }



            return(hadoopJarStepConfig);
        }
        public HadoopJarStepConfig Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            HadoopJarStepConfig hadoopJarStepConfig = new HadoopJarStepConfig();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Properties", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <KeyValue, KeyValueUnmarshaller>(
                        KeyValueUnmarshaller.GetInstance());
                    hadoopJarStepConfig.Properties = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("Jar", targetDepth))
                {
                    hadoopJarStepConfig.Jar = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("MainClass", targetDepth))
                {
                    hadoopJarStepConfig.MainClass = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Args", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <String, StringUnmarshaller>(
                        StringUnmarshaller.GetInstance());
                    hadoopJarStepConfig.Args = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(hadoopJarStepConfig);
        }
        public HadoopJarStepConfig Unmarshall(JsonUnmarshallerContext context)
        {
            HadoopJarStepConfig hadoopJarStepConfig = new HadoopJarStepConfig();

            hadoopJarStepConfig.Properties = null;
            hadoopJarStepConfig.Args       = null;

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

                    if (context.TestExpression("Properties", targetDepth))
                    {
                        hadoopJarStepConfig.Properties = new List <KeyValue>();
                        KeyValueUnmarshaller unmarshaller = KeyValueUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                hadoopJarStepConfig.Properties.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("Jar", targetDepth))
                    {
                        hadoopJarStepConfig.Jar = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("MainClass", targetDepth))
                    {
                        hadoopJarStepConfig.MainClass = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Args", targetDepth))
                    {
                        hadoopJarStepConfig.Args = new List <String>();
                        StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                hadoopJarStepConfig.Args.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(hadoopJarStepConfig);
                }
            }


            return(hadoopJarStepConfig);
        }
        public HadoopStepConfig Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            HadoopStepConfig hadoopStepConfig = new HadoopStepConfig();



            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Jar", targetDepth))
                {
                    context.Read();
                    hadoopStepConfig.Jar = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Properties", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        hadoopStepConfig.Properties = null;
                        continue;
                    }
                    hadoopStepConfig.Properties = new Dictionary <String, String>();
                    KeyValueUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller> unmarshaller = new KeyValueUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.GetInstance(), StringUnmarshaller.GetInstance());
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart || token == JsonToken.ObjectStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd || token == JsonToken.ObjectEnd)
                        {
                            break;
                        }
                        KeyValuePair <string, string> kvp = unmarshaller.Unmarshall(context);
                        hadoopStepConfig.Properties.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.TestExpression("MainClass", targetDepth))
                {
                    context.Read();
                    hadoopStepConfig.MainClass = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Args", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        hadoopStepConfig.Args = null;
                        continue;
                    }
                    hadoopStepConfig.Args = new List <String>();
                    StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        hadoopStepConfig.Args.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return(hadoopStepConfig);
                }
            }


            return(hadoopStepConfig);
        }
        public Application Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            Application application = new Application();



            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Name", targetDepth))
                {
                    context.Read();
                    application.Name = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Version", targetDepth))
                {
                    context.Read();
                    application.Version = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Args", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        application.Args = null;
                        continue;
                    }
                    application.Args = new List <String>();
                    StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        application.Args.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.TestExpression("AdditionalInfo", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        application.AdditionalInfo = null;
                        continue;
                    }
                    application.AdditionalInfo = new Dictionary <String, String>();
                    KeyValueUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller> unmarshaller = new KeyValueUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.GetInstance(), StringUnmarshaller.GetInstance());
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart || token == JsonToken.ObjectStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd || token == JsonToken.ObjectEnd)
                        {
                            break;
                        }
                        KeyValuePair <string, string> kvp = unmarshaller.Unmarshall(context);
                        application.AdditionalInfo.Add(kvp.Key, kvp.Value);
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return(application);
                }
            }


            return(application);
        }