Пример #1
0
        public PipelineOutputConfig Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            PipelineOutputConfig pipelineOutputConfig = new PipelineOutputConfig();

            pipelineOutputConfig.Permissions = 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("Bucket", targetDepth))
                    {
                        pipelineOutputConfig.Bucket = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

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

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


            return(pipelineOutputConfig);
        }
 public static PermissionUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new PermissionUnmarshaller();
     }
     return(instance);
 }
        public PipelineOutputConfig Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            PipelineOutputConfig pipelineOutputConfig = new PipelineOutputConfig();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Bucket", targetDepth))
                {
                    pipelineOutputConfig.Bucket = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

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

                if (context.TestExpression("Permissions", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Permission, PermissionUnmarshaller>(
                        PermissionUnmarshaller.GetInstance());
                    pipelineOutputConfig.Permissions = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(pipelineOutputConfig);
        }