public void ExampleImport() { using (var stream = File.OpenRead(@"protobuf/example.import")) { FileDescriptorSet descriptorSet = FileDescriptorSet.Parser.ParseFrom(stream); Google.Protobuf.Collections.RepeatedField <FileDescriptorProto> descriptorsProto = descriptorSet.File; FileDescriptorProto a = descriptorsProto[0]; FileDescriptorProto b = descriptorsProto[1]; FileDescriptorProto bb = descriptorsProto[2]; FileDescriptorProto c = descriptorsProto[3]; FileDescriptorProto cc = descriptorsProto[4]; Assert.That(b.Dependency.Count, Is.EqualTo(1)); Assert.That(b.Dependency[0], Contains.Substring("A.proto")); Assert.That(b.PublicDependency.Count, Is.EqualTo(0)); Assert.That(bb.Dependency.Count, Is.EqualTo(1)); Assert.That(bb.Dependency[0], Contains.Substring("B.proto")); Assert.That(bb.PublicDependency.Count, Is.EqualTo(0)); Assert.That(c.Dependency.Count, Is.EqualTo(1)); Assert.That(c.Dependency[0], Contains.Substring("A.proto")); Assert.That(c.PublicDependency.Count, Is.EqualTo(1)); Assert.That(cc.Dependency.Count, Is.EqualTo(1)); Assert.That(cc.Dependency[0], Contains.Substring("C.proto")); Assert.That(cc.PublicDependency.Count, Is.EqualTo(1)); } }
public void ParseOutput(Google.Protobuf.Collections.RepeatedField <Stat> source, out ulong up, out ulong down) { up = 0; down = 0; try { foreach (var stat in source) { var name = stat.Name; var value = stat.Value; var nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var type = ""; name = name.Trim(); name = nStr[1]; type = nStr[3]; if (name == Global.InboundProxyTagName) { if (type == "uplink") { up = (ulong)value; } else if (type == "downlink") { down = (ulong)value; } } } } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); } }
public void Test1() { using (var stream = File.OpenRead(@"mymodel")) { FileDescriptorSet descriptorSet = FileDescriptorSet.Parser.ParseFrom(stream); Google.Protobuf.Collections.RepeatedField <FileDescriptorProto> descriptorsProto = descriptorSet.File; FileDescriptorProto info = descriptorsProto[0]; var service = info.Service[0]; Console.WriteLine("---------------"); Console.WriteLine("| <<Service>> |"); Console.WriteLine($"| {service.Name} |"); Console.WriteLine("---------------"); foreach (MethodDescriptorProto method in service.Method) { Console.WriteLine($"| + {method.OutputType} {method.Name}({method.InputType}) |"); } Console.WriteLine("---------------"); foreach (DescriptorProto message in info.MessageType) { Console.WriteLine("---------------"); Console.WriteLine($"| {message.Name} |"); Console.WriteLine("---------------"); foreach (var field in message.Field) { Console.WriteLine($"| + {field.TypeName} {field.Name} |"); } Console.WriteLine("---------------"); } } }
private void ParseOutput(Google.Protobuf.Collections.RepeatedField <Stat> source, out ulong up, out ulong down) { up = 0; down = 0; try { foreach (Stat stat in source) { string name = stat.Name; long value = stat.Value; string[] nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string type = ""; name = name.Trim(); name = nStr[1]; type = nStr[3]; if (name == Global.agentTag) { if (type == "uplink") { up = (ulong)value; } else if (type == "downlink") { down = (ulong)value; } } } } catch (Exception ex) { //Utils.SaveLog(ex.Message, ex); } }
public override async Task GetCurrentConditionStream(CurrentConditionsRequest request, IServerStreamWriter <CurrentConditionsReply> responseStream, ServerCallContext context) { while (!context.CancellationToken.IsCancellationRequested) { _logger.LogWarning("Background task is running"); var client = new HttpClient(); var response = await client.GetAsync("https://core-weather-api.azurewebsites.net/api/v1/current-conditions"); var retVal = await response.Content.ReadAsStringAsync(); // New Serializer!!!! var jsonSerializerOptions = new JsonSerializerOptions(); jsonSerializerOptions.PropertyNameCaseInsensitive = true; var conditions = JsonSerializer.Deserialize <IEnumerable <CurrentCondition> >(retVal, jsonSerializerOptions); var currentConditions = new Google.Protobuf.Collections.RepeatedField <CurrentCondition>(); currentConditions.AddRange(conditions); var currentConditionsReply = new CurrentConditionsReply(); currentConditionsReply.CurrentConditions.AddRange(currentConditions); await responseStream.WriteAsync(currentConditionsReply); await Task.Delay(TimeSpan.FromSeconds(2)); } }
public override async Task <CurrentConditionsReply> GetCurrentConditions(CurrentConditionsRequest request, ServerCallContext context) { _logger.LogWarning("Get current conditions called"); var client = new HttpClient(); var response = await client.GetAsync("https://core-weather-api.azurewebsites.net/api/v1/current-conditions"); var retVal = await response.Content.ReadAsStringAsync(); // New Serializer!!!! var jsonSerializerOptions = new JsonSerializerOptions(); jsonSerializerOptions.PropertyNameCaseInsensitive = true; var conditions = JsonSerializer.Deserialize <IEnumerable <CurrentCondition> >(retVal, jsonSerializerOptions); var currentConditions = new Google.Protobuf.Collections.RepeatedField <CurrentCondition>(); currentConditions.AddRange(conditions); var currentConditionsReply = new CurrentConditionsReply(); currentConditionsReply.CurrentConditions.AddRange(currentConditions); return(currentConditionsReply); }
private void Test() { using (var stream = File.OpenRead(@"C:\Users\Agando\Desktop\protoc-3.9.1-win64\bin\grpcserverschema")) { FileDescriptorSet descriptorSet = FileDescriptorSet.Parser.ParseFrom(stream); Google.Protobuf.Collections.RepeatedField <FileDescriptorProto> descriptorsProto = descriptorSet.File; } }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *__ret = ILIntepreter.Minus(__esp, 0); var result_of_this_method = new Google.Protobuf.Collections.RepeatedField <Google.Protobuf.Adapt_IMessage.Adaptor>(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary> /// 将list转成RepeatedField集合 /// </summary> /// <typeparam name="T">转换的集合中的数据类型</typeparam> /// <param name="list">要转换的集合</param> /// <returns></returns> public static Google.Protobuf.Collections.RepeatedField <T> ListToRepeatedField <T>(List <T> list) { Google.Protobuf.Collections.RepeatedField <T> repeatedfieldList = new Google.Protobuf.Collections.RepeatedField <T>(); foreach (var item in list) { repeatedfieldList.Add(item); } return(repeatedfieldList); }
private static VectorCapture[] FromTransport(Google.Protobuf.Collections.RepeatedField <Transport.VectorCapture> transportCapture) { var vectorCapture = new VectorCapture[transportCapture.Count]; for (int i = 0; i < transportCapture.Count; i++) { vectorCapture[i] = new VectorCapture(transportCapture[i].Time, new Vector3(transportCapture[i].X, transportCapture[i].Y, transportCapture[i].Z)); } return(vectorCapture); }
private static CustomEventCapture[] FromTransport(Google.Protobuf.Collections.RepeatedField <Transport.CustomEventCapture> transportCapture) { var curstomCapture = new CustomEventCapture[transportCapture.Count]; for (int i = 0; i < transportCapture.Count; i++) { curstomCapture[i] = new CustomEventCapture(transportCapture[i].Time, transportCapture[i].Name, transportCapture[i].Contents); } return(curstomCapture); }
private static UnityLifeCycleEventCapture[] FromTransport(Google.Protobuf.Collections.RepeatedField <Transport.LifeCycleEventCapture> transportCapture) { var curstomCapture = new UnityLifeCycleEventCapture[transportCapture.Count]; for (int i = 0; i < transportCapture.Count; i++) { curstomCapture[i] = new UnityLifeCycleEventCapture(transportCapture[i].Time, (UnityLifeCycleEvent)((int)transportCapture[i].Type)); } return(curstomCapture); }
public GeometryDecoder(PbfFeature feature, PbfLayer layer) { data = feature.Geometry; index = 0; extent = layer.Extent; scale = 1.0f / (extent - 1); x = 0; y = 0; command = CommandType.MoveTo; repeat = 0; }
public GeometryDecoder(PbfFeature feature, PbfLayer layer) { Data = feature.Geometry; Position = 0; Extent = layer.Extent; Scale = 1.0f / (Extent - 1); X = 0; Y = 0; Command = CommandType.MoveTo; Repeat = 0; }
public static Google.Protobuf.Collections.RepeatedField <EntityAnnotation> GetMergedLines(string[] lines, List <EntityAnnotation> rawText) { var mergedArray = new Google.Protobuf.Collections.RepeatedField <EntityAnnotation>(); var linesList = lines.ToList(); while (linesList.Count != 1) { var l = linesList.Last(); linesList.RemoveAt(linesList.Count - 1); if (String.IsNullOrEmpty(l)) { continue; } var ll = l; var status = true; EntityAnnotation mergedElement = new EntityAnnotation(); while (true) { var wElement = rawText.Last(); rawText.RemoveAt(rawText.Count - 1); var w = wElement.Description; var index = l.IndexOf(w); if (index >= 0) { // check if the word is inside l = l.Substring(index + w.Length); if (status) { status = false; // set starting coordinates mergedElement = wElement; } if (String.IsNullOrEmpty(l)) { // set ending coordinates mergedElement.Description = ll; mergedElement.BoundingPoly.Vertices[1] = wElement.BoundingPoly.Vertices[1]; mergedElement.BoundingPoly.Vertices[2] = wElement.BoundingPoly.Vertices[2]; mergedArray.Add(mergedElement); break; } } } } return(mergedArray); }
static StackObject *Clear_4(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.Collections.RepeatedField <System.Single> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <System.Single>) typeof(Google.Protobuf.Collections.RepeatedField <System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Clear(); return(__ret); }
private List <string[]> ExtractNouns(Google.Protobuf.Collections.RepeatedField <Token> syntaxSenstiment) { List <string[]> keywords = new List <string[]>(); foreach (var token in syntaxSenstiment) { if (token.PartOfSpeech.Tag == PartOfSpeech.Types.Tag.Noun) { keywords.Add(new string[] { "KW", token.Lemma }); } } return(keywords); }
static StackObject *Clone_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.Collections.RepeatedField <System.Single> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <System.Single>) typeof(Google.Protobuf.Collections.RepeatedField <System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Clone(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
private static long GetNextDefender(Google.Protobuf.Collections.RepeatedField <BattleAction> battleActions) { foreach (var element in battleActions) { if (element.BattleResults != null) { if (element.BattleResults.NextDefenderPokemonId != -1) { return(element.BattleResults.NextDefenderPokemonId); } } } return(-1L); }
static StackObject *get_Count_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.Collections.RepeatedField <System.Single> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <System.Single>) typeof(Google.Protobuf.Collections.RepeatedField <System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Count; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
/// <summary> /// Shifts the list by 1 in a cirular fashion. /// </summary> /// <param name="oldList">List to shift</param> /// <returns>Shifted List</returns> public static Google.Protobuf.Collections.RepeatedField <string> Shift(this Google.Protobuf.Collections.RepeatedField <string> oldList) { Google.Protobuf.Collections.RepeatedField <string> newList = new Google.Protobuf.Collections.RepeatedField <string>(); for (int i = 0; i < oldList.Count; i++) { if (i < oldList.Count - 1) { newList.Add(oldList[i + 1]); } else { newList.Add(oldList[0]); } } return(newList); }
public override Task <AuthorizationPolicy> GetPolicyAsync(string policyName) { var policy = new AuthorizationPolicyBuilder(); policy.RequireAssertion(async ctx => { if (ctx.User?.Identity?.IsAuthenticated == true) { var userId = ctx.User?.Claims.FirstOrDefault(e => e.Type == "sub")?.Value; if (!string.IsNullOrEmpty(userId)) { Google.Protobuf.Collections.RepeatedField <string> permissions = null; permissions = await memoryCache.GetOrCreateAsync($"{userId}", async cache => { cache.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5); try { //ctx.AbsoluteExpirationRelativeToNow = IdentityServerCenterConnectServiceCollectionExtensions.UserPermissionCacheTimeSpan; var result = (await userClient.GetUserPermissonsAsync( new UserGrpcService.UserIdReq { UserId = userId })).Items; return(result); } catch (RpcException ex) { logger.LogError($"Grpc获取用户权限失败:{ex.Message}"); } return(null); }); return(permissions.Any(e => e == policyName)); } } return(false); }); return(Task.FromResult(policy.Build())); //如果在ConfigService AddAuthorization //获取回落政策 //https://docs.microsoft.com/zh-cn/aspnet/core/security/authorization/iauthorizationpolicyprovider?view=aspnetcore-3.1 //return this.GetFallbackPolicyAsync(); }
void DealMessage(SyncProto proto) { Google.Protobuf.Collections.RepeatedField <MsgEntry> messages = proto.SyncMsg.MsgEntry; //Debug.Log("deal message"); if (messages == null) { return; } for (int i = 0; i < messages.Count; i++) { MsgEntry msgEntry = messages[i]; if (msgEntry.ShowId == showObject.ShowId) { ChangeCubeColor((ColorType)((int)msgEntry.Vec[0])); } } }
static StackObject *get_Item_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int32 @index = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.Collections.RepeatedField <System.String> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <System.String>) typeof(Google.Protobuf.Collections.RepeatedField <System.String>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method[index]; return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
private List <string[]> ExtractNounsWithAdj(Google.Protobuf.Collections.RepeatedField <Token> syntaxSenstiment) { List <string[]> keywords = new List <string[]>(); string lemma = string.Empty; string templemma = string.Empty; for (int i = 0; i < syntaxSenstiment.Count; i++) { switch (syntaxSenstiment[i].PartOfSpeech.Tag) { case PartOfSpeech.Types.Tag.Noun: if (templemma != string.Empty) { lemma += templemma + syntaxSenstiment[i].Lemma; templemma = string.Empty; } else { if (lemma != string.Empty) { lemma += " "; } lemma += syntaxSenstiment[i].Lemma; } break; case PartOfSpeech.Types.Tag.Adj: templemma += syntaxSenstiment[i].Lemma + " "; break; default: if (lemma != string.Empty) { keywords.Add(new string[] { "KW", lemma }); lemma = string.Empty; templemma = string.Empty; } break; } } return(keywords); }
static StackObject *Add_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.IEnumerable <System.Single> @values = (System.Collections.Generic.IEnumerable <System.Single>) typeof(System.Collections.Generic.IEnumerable <System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.Collections.RepeatedField <System.Single> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <System.Single>) typeof(Google.Protobuf.Collections.RepeatedField <System.Single>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@values); return(__ret); }
public async Task <DummiesPage> GetDummiesAsync(DummiesPageRequest request, ServerCallContext context) { var correlationId = request.CorrelationId; var filter = new Commons.Data.FilterParams(request.Filter); var paging = new Commons.Data.PagingParams(request.Paging.Skip, request.Paging.Take, request.Paging.Total); var page = await _controller.GetPageByFilterAsync(correlationId, filter, paging); var data = new Google.Protobuf.Collections.RepeatedField <ProtoDummy>(); var response = new DummiesPage { Total = page.Total ?? 0 }; response.Data.AddRange(page.Data.Select(x => ConvertToPublic(x))); return(response); }
private void MakeTuturial() { var state = Client.Player.PlayerResponse.PlayerData.TutorialState; if (state == null) { state = new Google.Protobuf.Collections.RepeatedField <POGOProtos.Enums.TutorialState>(); } if (!state.Contains(POGOProtos.Enums.TutorialState.LegalScreen)) { var res = Client.Misc.AceptLegalScreen().Result; if (res.Result != EncounterTutorialCompleteResponse.Types.Result.Success) { return; } } Client.OnMakeTutorial(); }
static StackObject *Add_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ETModel.Card @item = (ETModel.Card) typeof(ETModel.Card).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.Collections.RepeatedField <ETModel.Card> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <ETModel.Card>) typeof(Google.Protobuf.Collections.RepeatedField <ETModel.Card>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@item); return(__ret); }
static StackObject *Add_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Com.Test.Item.one_item @item = (Com.Test.Item.one_item) typeof(Com.Test.Item.one_item).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.Collections.RepeatedField <Com.Test.Item.one_item> instance_of_this_method = (Google.Protobuf.Collections.RepeatedField <Com.Test.Item.one_item>) typeof(Google.Protobuf.Collections.RepeatedField <Com.Test.Item.one_item>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@item); return(__ret); }