Пример #1
0
 public RpcHeader RequestEcho(FullType type)
 {
     var packetId = Interlocked.Increment(ref globalPacketId);
     return w.Request(() => {
     w.Write(type);
     }, length => new RpcHeader((int)MethodId.Echo, (uint)packetId, length));
 }
        private static ITypeDefinitionNode CreateTypes(FullType type)
        {
            switch (type.Kind)
            {
            case TypeKind.Enum:
                return(CreateEnumType(type));

            case TypeKind.Input_Object:
                return(CreateInputObject(type));

            case TypeKind.Interface:
                return(CreateInterface(type));

            case TypeKind.Object:
                return(CreateObject(type));

            case TypeKind.Scalar:
                return(CreateScalar(type));

            case TypeKind.Union:
                return(CreateUnion(type));

            default:
                throw new NotSupportedException(
                          StitchingResources.Type_NotSupported);
            }
        }
Пример #3
0
 public ChangeMethodReturnTypeVisitor(MigrationContext context, Method method, FullType returnType)
     : base(context)
 {
     _context    = context;
     _method     = method;
     _returnType = returnType;
 }
Пример #4
0
            public FullType ReadFullType()
            {
                var x = new FullType();

                x.Boollean      = ReadBoolean();
                x.Byte          = ReadByte();
                x.Int16         = ReadInt16();
                x.Int32         = ReadInt32();
                x.Int64         = ReadInt64();
                x.UInt16        = ReadUInt16();
                x.UInt32        = ReadUInt32();
                x.UInt64        = ReadUInt64();
                x.Single        = ReadSingle();
                x.Double        = ReadDouble();
                x.Stirng        = ReadString();
                x.BoolleanArray = ReadBooleanArray();
                x.ByteArray     = ReadByteArray();
                x.Int16Array    = ReadInt16Array();
                x.Int32Array    = ReadInt32Array();
                x.Int64Array    = ReadInt64Array();
                x.UInt16Array   = ReadUInt16Array();
                x.UInt32Array   = ReadUInt32Array();
                x.UInt64Array   = ReadUInt64Array();
                x.SingleArray   = ReadSingleArray();
                x.DoubleArray   = ReadDoubleArray();
                x.StirngArray   = ReadStringArray();
                return(x);
            }
Пример #5
0
        private bool TokenIsType(SyntaxToken token, FullType type)
        {
            var name = token.WithoutTrivia().ToString();

            return(name == type.ClassName ||
                   name == Type);
        }
Пример #6
0
            public FullType[] ReadFullTypeArray()
            {
                var count = Read7BitEncodedInt();
                var xs    = new FullType[count];

                for (int i = 0; i < count; ++i)
                {
                    var x = new FullType();
                    x.Boollean      = ReadBoolean();
                    x.Byte          = ReadByte();
                    x.Int16         = ReadInt16();
                    x.Int32         = ReadInt32();
                    x.Int64         = ReadInt64();
                    x.UInt16        = ReadUInt16();
                    x.UInt32        = ReadUInt32();
                    x.UInt64        = ReadUInt64();
                    x.Single        = ReadSingle();
                    x.Double        = ReadDouble();
                    x.Stirng        = ReadString();
                    x.BoolleanArray = ReadBooleanArray();
                    x.ByteArray     = ReadByteArray();
                    x.Int16Array    = ReadInt16Array();
                    x.Int32Array    = ReadInt32Array();
                    x.Int64Array    = ReadInt64Array();
                    x.UInt16Array   = ReadUInt16Array();
                    x.UInt32Array   = ReadUInt32Array();
                    x.UInt64Array   = ReadUInt64Array();
                    x.SingleArray   = ReadSingleArray();
                    x.DoubleArray   = ReadDoubleArray();
                    x.StirngArray   = ReadStringArray();
                    xs[i]           = x;
                }
                return(xs);
            }
Пример #7
0
 public void Write(FullType x)
 {
     Write(x.Boollean);
     Write(x.Byte);
     Write(x.Int16);
     Write(x.Int32);
     Write(x.Int64);
     Write(x.UInt16);
     Write(x.UInt32);
     Write(x.UInt64);
     Write(x.Single);
     Write(x.Double);
     Write(x.Stirng);
     Write(x.BoolleanArray);
     Write(x.ByteArray);
     Write(x.Int16Array);
     Write(x.Int32Array);
     Write(x.Int64Array);
     Write(x.UInt16Array);
     Write(x.UInt32Array);
     Write(x.UInt64Array);
     Write(x.SingleArray);
     Write(x.DoubleArray);
     Write(x.StirngArray);
 }
Пример #8
0
        private static async Task <SchemaFeatures> GetSchemaFeaturesAsync(
            HttpClient httpClient,
            HttpQueryClient queryClient)
        {
            var features = new SchemaFeatures();

            var request = new HttpQueryRequest
            {
                Query = GetIntrospectionQuery(_phase1)
            };

            string json = await queryClient.FetchStringAsync(
                request, httpClient)
                          .ConfigureAwait(false);

            IntrospectionResult result =
                JsonConvert.DeserializeObject <IntrospectionResult>(json);

            FullType directive = result.Data.Schema.Types.First(t =>
                                                                t.Name.Equals(_directiveName, StringComparison.Ordinal));

            features.HasRepeatableDirectives = directive.Fields.Any(t =>
                                                                    t.Name.Equals(_isRepeatable, StringComparison.Ordinal));
            features.HasDirectiveLocations = directive.Fields.Any(t =>
                                                                  t.Name.Equals(_locations, StringComparison.Ordinal));

            FullType schema = result.Data.Schema.Types.First(t =>
                                                             t.Name.Equals(_schemaName, StringComparison.Ordinal));

            features.HasSubscriptionSupport = schema.Fields.Any(t =>
                                                                t.Name.Equals(_subscriptionType, StringComparison.Ordinal));

            return(features);
        }
Пример #9
0
            public RpcHeader RequestEcho(FullType type)
            {
                var packetId = Interlocked.Increment(ref globalPacketId);

                return(w.Request(() => {
                    w.Write(type);
                }, length => new RpcHeader((int)MethodId.Echo, (uint)packetId, length)));
            }
Пример #10
0
        private string ConstructFullClassName(FullType type)
        {
            if (type == (FullType)null)
            {
                return(null);
            }

            return(type.Namespace + "." + type.ClassName);
        }
Пример #11
0
 public ChangeMemberTypeVisitor(
     MigrationContext context,
     FullType type,
     string memberName,
     FullType returnType)
 {
     _context    = context;
     _type       = type;
     _memberName = memberName;
     _returnType = returnType;
 }
Пример #12
0
 public ReplaceClassVisitor(
     MigrationContext context,
     FullType type,
     FullType newType,
     IEnumerable <Argument> constructorArguments)
 {
     _context = context;
     _type    = type;
     _newType = newType;
     _constructorArguments = constructorArguments;
 }
 private static EnumTypeDefinitionNode CreateEnumType(FullType type)
 {
     return(new EnumTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>(),
                CreateEnumValues(type.EnumValues)
            ));
 }
Пример #14
0
 public RenameMemberVisitor(
     MigrationContext context,
     string type,
     string memberName,
     string newName)
 {
     _context    = context;
     _type       = type;
     _memberName = memberName;
     _newName    = newName;
 }
 private static ScalarTypeDefinitionNode CreateScalar(
     FullType type)
 {
     return(new ScalarTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>()
            ));
 }
 private static UnionTypeDefinitionNode CreateUnion(
     FullType type)
 {
     return(new UnionTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>(),
                CreateNamedTypeRefs(type.PossibleTypes)
            ));
 }
 private static InputObjectTypeDefinitionNode CreateInputObject(
     FullType type)
 {
     return(new InputObjectTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>(),
                CreateInputVals(type.InputFields)
            ));
 }
 private static InterfaceTypeDefinitionNode CreateInterface(
     FullType type)
 {
     return(new InterfaceTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>(),
                CreateFields(type.Fields)
            ));
 }
 private static ObjectTypeDefinitionNode CreateObject(
     FullType type)
 {
     return(new ObjectTypeDefinitionNode
            (
                null,
                new NameNode(type.Name),
                CreateDescription(type.Description),
                Array.Empty <DirectiveNode>(),
                CreateNamedTypeRefs(type.Interfaces),
                CreateFields(type.Fields)
            ));
 }
Пример #20
0
            public Action <Writer> Dispatch(RpcHeader header)
            {
#if DEBUG
                assert(header.Length, "RpcBody " + (MethodId)header.MethodId);
#endif

                switch ((MethodId)header.MethodId)
                {
                case MethodId.Add:
                    return(_ => OnAdd(r.ReadInt32()));


                case MethodId.Echo:
                    return(_ => OnEcho(r.ReadFullType()));


                case MethodId.Exchange:
                    return(_ => OnExchange(r.ReadItemArray()));


                case MethodId.Get:
                    return(_ => OnGet(r.ReadItem()));



                case MethodId.Change:

                    Item[] consume = r.ReadItemArray();


                    return(w => w.ResponseChange(OnChange(consume), header));



                case MethodId.Ping:

                    FullType type = r.ReadFullType();


                    return(w => w.ResponsePing(OnPing(type), header));



                default:
                    return(null);
                }
            }
Пример #21
0
 public void PrepareTree()
 {
     if (!(Value is Exception || Value is System.Collections.IList ||
           Value == null ||
           Value.GetType().IsSimpleType()))
     {
         GetSubMembers();
     }
     if (ChildPI?.Count() > 0 || (Value is System.Collections.IList list && list.Count > 0))
     {
         HasChildren = true;
         if (Value is System.Collections.IList list2)
         {
             FullType = FullType.Replace("[]", "") + "[" + list2.Count + "]";
         }
     }
 }
Пример #22
0
            public IEnumerator <uint> Parse(Func <MemoryStream> get, BinaryPackerWriterEx w)
            {
                while (true)
                {
                    yield return(RpcHeader.HeaderLength);

                    var r      = new BinaryPackerReaderEx(get());
                    var header = new RpcHeader(r.ReadUInt32());

                    yield return(header.Length);

                    switch ((MethodId)header.MethodId)
                    {
                    case MethodId.Add:
                        OnAdd(r.ReadInt32());
                        break;

                    case MethodId.Echo:
                        OnEcho(r.ReadFullType());
                        break;

                    case MethodId.Exchange:
                        OnExchange(r.ReadItemArray());
                        break;

                    case MethodId.Get:
                        OnGet(r.ReadItem());
                        break;

                    case MethodId.Change:
                        Item[] consume = r.ReadItemArray();
                        w.Write(OnChange(consume));
                        break;

                    case MethodId.Ping:
                        FullType type = r.ReadFullType();
                        w.Write(OnPing(type));
                        break;

                    // invalid case
                    default:
                        throw new InvalidDataException("Invalid methodId = " + header.MethodId);
                    }
                }
            }
Пример #23
0
        public override Type[] GetGenericArguments()
        {
            if (_genericArguments == null)
            {
                var erasedArguments  = RuntimeType.GetGenericArguments();
                var fullArguments    = FullType.GetGenericArguments();
                var genericArguments = new Type[erasedArguments.Length];
                for (int i = 0; i < erasedArguments.Length; i++)
                {
                    var full   = fullArguments[i];
                    var erased = erasedArguments[i];
                    if (full is ErasedWrapperType || full == erased)
                    {
                        genericArguments[i] = full;
                        continue;
                    }

                    genericArguments[i] = new ErasedWrapperType(erased, (InterpretedType)full);
                }
                _genericArguments = genericArguments;
            }

            return(_genericArguments);
        }
Пример #24
0
 public FullType ReadFullType()
 {
     var x = new FullType();
     x.Boollean = ReadBoolean();
     x.Byte = ReadByte();
     x.Int16 = ReadInt16();
     x.Int32 = ReadInt32();
     x.Int64 = ReadInt64();
     x.UInt16 = ReadUInt16();
     x.UInt32 = ReadUInt32();
     x.UInt64 = ReadUInt64();
     x.Single = ReadSingle();
     x.Double = ReadDouble();
     x.Stirng = ReadString();
     x.BoolleanArray = ReadBooleanArray();
     x.ByteArray = ReadByteArray();
     x.Int16Array = ReadInt16Array();
     x.Int32Array = ReadInt32Array();
     x.Int64Array = ReadInt64Array();
     x.UInt16Array = ReadUInt16Array();
     x.UInt32Array = ReadUInt32Array();
     x.UInt64Array = ReadUInt64Array();
     x.SingleArray = ReadSingleArray();
     x.DoubleArray = ReadDoubleArray();
     x.StirngArray = ReadStringArray();
     return x;
 }
 public ChangeMemberTypeMigration(FullType type, string memberName, FullType returnType)
 {
     _type       = type;
     _memberName = memberName;
     _returnType = returnType;
 }
Пример #26
0
 public void Write(FullType[] xs)
 {
     Write7BitEncodedInt(xs.Length);
     foreach(var x in xs)
     {
     Write(x);
     }
 }
 public ReplaceClassMigration(string type, string newType, IEnumerable <Argument> constructorArgument)
 {
     _type                = type;
     _newType             = newType;
     _constructorArgument = constructorArgument;
 }
 public RenameMemberMigration(FullType type, string memberName, string newMemberName)
 {
     _type          = type;
     _memberName    = memberName;
     _newMemberName = newMemberName;
 }
Пример #29
0
            public FullType ReadFullType()
            {
                var isNull = ReadByte() == 0;

                if (isNull)
                {
                    return(null);
                }

                var x = new FullType();

                x.Boollean = ReadBoolean();

                x.Byte = ReadByte();

                x.Int16 = ReadInt16();

                x.Int32 = ReadInt32();

                x.Int64 = ReadInt64();

                x.UInt16 = ReadUInt16();

                x.UInt32 = ReadUInt32();

                x.UInt64 = ReadUInt64();

                x.Single = ReadSingle();

                x.Double = ReadDouble();

                x.Stirng = ReadString();

                x.EnumValue = ReadEnumType();

                x.Item = ReadItem();

                x.BoolleanArray = ReadBooleanArray();

                x.ByteArray = ReadByteArray();

                x.Int16Array = ReadInt16Array();

                x.Int32Array = ReadInt32Array();

                x.Int64Array = ReadInt64Array();

                x.UInt16Array = ReadUInt16Array();

                x.UInt32Array = ReadUInt32Array();

                x.UInt64Array = ReadUInt64Array();

                x.SingleArray = ReadSingleArray();

                x.DoubleArray = ReadDoubleArray();

                x.StirngArray = ReadStringArray();

                x.EnumValueArray = ReadEnumTypeArray();

                x.ItemArray = ReadItemArray();

                return(x);
            }
Пример #30
0
 public void ResponseEcho(FullType x, RpcHeader header)
 {
     w.Response(() => w.Write(x), header);
 }
Пример #31
0
            public void Write(FullType x)
            {
                if (x != null)
                {
                    Write((Byte)1);

                    Write(x.Boollean);

                    Write(x.Byte);

                    Write(x.Int16);

                    Write(x.Int32);

                    Write(x.Int64);

                    Write(x.UInt16);

                    Write(x.UInt32);

                    Write(x.UInt64);

                    Write(x.Single);

                    Write(x.Double);

                    Write(x.Stirng);

                    Write(x.EnumValue);

                    Write(x.Item);

                    Write(x.BoolleanArray);

                    Write(x.ByteArray);

                    Write(x.Int16Array);

                    Write(x.Int32Array);

                    Write(x.Int64Array);

                    Write(x.UInt16Array);

                    Write(x.UInt32Array);

                    Write(x.UInt64Array);

                    Write(x.SingleArray);

                    Write(x.DoubleArray);

                    Write(x.StirngArray);

                    Write(x.EnumValueArray);

                    Write(x.ItemArray);
                }
                else
                {
                    Write((Byte)0);
                }
            }
Пример #32
0
 public ChangeMethodReturnTypeMigration(Method method, FullType returnType)
 {
     _method     = method;
     _returnType = returnType;
 }
Пример #33
0
 public FullType[] ReadFullTypeArray()
 {
     var count = Read7BitEncodedInt();
     var xs = new FullType[count];
     for(int i=0; i<count; ++i)
     {
     var x = new FullType();
     x.Boollean = ReadBoolean();
     x.Byte = ReadByte();
     x.Int16 = ReadInt16();
     x.Int32 = ReadInt32();
     x.Int64 = ReadInt64();
     x.UInt16 = ReadUInt16();
     x.UInt32 = ReadUInt32();
     x.UInt64 = ReadUInt64();
     x.Single = ReadSingle();
     x.Double = ReadDouble();
     x.Stirng = ReadString();
     x.BoolleanArray = ReadBooleanArray();
     x.ByteArray = ReadByteArray();
     x.Int16Array = ReadInt16Array();
     x.Int32Array = ReadInt32Array();
     x.Int64Array = ReadInt64Array();
     x.UInt16Array = ReadUInt16Array();
     x.UInt32Array = ReadUInt32Array();
     x.UInt64Array = ReadUInt64Array();
     x.SingleArray = ReadSingleArray();
     x.DoubleArray = ReadDoubleArray();
     x.StirngArray = ReadStringArray();
     xs[i] = x;
     }
     return xs;
 }
Пример #34
0
 public void Write(FullType x)
 {
     Write(x.Boollean);
     Write(x.Byte);
     Write(x.Int16);
     Write(x.Int32);
     Write(x.Int64);
     Write(x.UInt16);
     Write(x.UInt32);
     Write(x.UInt64);
     Write(x.Single);
     Write(x.Double);
     Write(x.Stirng);
     Write(x.BoolleanArray);
     Write(x.ByteArray);
     Write(x.Int16Array);
     Write(x.Int32Array);
     Write(x.Int64Array);
     Write(x.UInt16Array);
     Write(x.UInt32Array);
     Write(x.UInt64Array);
     Write(x.SingleArray);
     Write(x.DoubleArray);
     Write(x.StirngArray);
 }
Пример #35
0
 public RenameInterfaceMigration(FullType type, string newName)
 {
     _type    = type;
     _newName = newName;
 }
Пример #36
0
 public void Write(FullType[] xs)
 {
     if(xs != null)
     {
     Write7BitEncodedInt(xs.Length);
     foreach(var x in xs)
     {
         Write(x);
     }
     }
     else
     {
     Write7BitEncodedInt(0);
     }
 }
Пример #37
0
            public FullType ReadFullType()
            {
                var isNull = ReadByte() == 0;
                if(isNull)
                {
                return null;
                }

                var x = new FullType();

                x.Boollean = ReadBoolean();

                x.Byte = ReadByte();

                x.Int16 = ReadInt16();

                x.Int32 = ReadInt32();

                x.Int64 = ReadInt64();

                x.UInt16 = ReadUInt16();

                x.UInt32 = ReadUInt32();

                x.UInt64 = ReadUInt64();

                x.Single = ReadSingle();

                x.Double = ReadDouble();

                x.Stirng = ReadString();

                x.EnumValue = ReadEnumType();

                x.Item = ReadItem();

                x.BoolleanArray = ReadBooleanArray();

                x.ByteArray = ReadByteArray();

                x.Int16Array = ReadInt16Array();

                x.Int32Array = ReadInt32Array();

                x.Int64Array = ReadInt64Array();

                x.UInt16Array = ReadUInt16Array();

                x.UInt32Array = ReadUInt32Array();

                x.UInt64Array = ReadUInt64Array();

                x.SingleArray = ReadSingleArray();

                x.DoubleArray = ReadDoubleArray();

                x.StirngArray = ReadStringArray();

                x.EnumValueArray = ReadEnumTypeArray();

                x.ItemArray = ReadItemArray();

                return x;
            }
Пример #38
0
 public void ResponsePing(FullType x, RpcHeader header)
 {
     w.Response(() => w.Write(x), header);
 }
Пример #39
0
            public void Write(FullType x)
            {
                if(x != null)
                {
                Write((Byte)1);

                Write(x.Boollean);

                Write(x.Byte);

                Write(x.Int16);

                Write(x.Int32);

                Write(x.Int64);

                Write(x.UInt16);

                Write(x.UInt32);

                Write(x.UInt64);

                Write(x.Single);

                Write(x.Double);

                Write(x.Stirng);

                Write(x.EnumValue);

                Write(x.Item);

                Write(x.BoolleanArray);

                Write(x.ByteArray);

                Write(x.Int16Array);

                Write(x.Int32Array);

                Write(x.Int64Array);

                Write(x.UInt16Array);

                Write(x.UInt32Array);

                Write(x.UInt64Array);

                Write(x.SingleArray);

                Write(x.DoubleArray);

                Write(x.StirngArray);

                Write(x.EnumValueArray);

                Write(x.ItemArray);

                }
                else
                {
                Write((Byte)0);
                }
            }