} //Disconnect protected override object Invoke(MethodInfo targetMethod, object[] args) { if ((!context.client.Connected) || writer == null || reader == null) { if ((!context.client.Connected)) { context.client.Connect(context.hostname, context.port); } stream = context.client.GetStream(); reader = new(stream); writer = new(stream); writer.AutoFlush = true; } //if var methodSchema = new MethodSchema(targetMethod.ToString(), args, dynamicInterfaceImplementationUniqueId); string requestLine = Utility.ObjectToString(context.serializer, methodSchema); writer.WriteLine(requestLine); string responseLine = reader.ReadLine(); if (responseLine == DefinitionSet.NullIndicator) { return(null); } else if (responseLine == DefinitionSet.InterfaceMethodNotFoundIndicator) { throw new MethodNotFoundException(methodSchema.MethodName); } if (responseLine != null && responseLine.Length > 0 && char.IsDigit(responseLine[0])) //IDynamic UniqueID { var uniqueId = UniqueId.Parse(responseLine); if (!context.dynamicProxyDictionary.TryGetValue(uniqueId, out object response)) { var instantiatedMethod = context.dispathProxyCreator.MakeGenericMethod(new System.Type[] { targetMethod.ReturnType, typeof(ClientProxy) }); var dynamicProxy = instantiatedMethod.Invoke(null, null); ((IClientInfrastructure)dynamicProxy).Context = this.context; ((IClientInfrastructure)dynamicProxy).DynamicInterfaceImplementationUniqueId = uniqueId; context.dynamicProxyDictionary.Add(uniqueId, dynamicProxy); return(dynamicProxy); } else { return(response); } } //if IDynamic DataContractSerializer returnSerializer = new(targetMethod.ReturnType); return(Utility.StringToObject(returnSerializer, responseLine)); } //Invoke
public void Load() { _profiles.Clear(); using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0}", Tableprofiles), _db)) { using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var id = SQLiteID.Parse(reader["id"].ToString()); var name = reader["name"].ToString(); var inlineComments = bool.Parse(reader["inline_comments"].ToString()); var interspersedComments = bool.Parse(reader["interspersed_comments"].ToString()); var extensions = GetprofileExtensions(id); var commentIndicators = GetCommentIndicators(id); var preprocessors = GetPreprocessors(id); var profile = new LanguageProfile { ID = id, Name = name, Extensions = extensions, CommentIndicators = commentIndicators, Preprocessors = preprocessors, AllowInlineComments = inlineComments, AllowInterspersedComments = interspersedComments }; _profiles.Add(profile); } } } _profiles.Sort((p1, p2) => string.CompareOrdinal(p1.Name, p2.Name)); }