/// <summary> /// /// </summary> /// <param name="server"></param> /// <param name="serverInstance"></param> public ServerContext(Game game, string gameId, int port, IServerInstance serverInstance) { this.game = game; this.serverInstance = serverInstance; var netConfig = new NetPeerConfiguration(gameId); netConfig.Port = port; netConfig.MaximumConnections = 32; netConfig.UnreliableSizeBehaviour = NetUnreliableSizeBehaviour.NormalFragmentation; if (Debugger.IsAttached) { netConfig.ConnectionTimeout = float.MaxValue; Log.Message("SV: Debugger is attached: ConnectionTimeout = {0} sec", netConfig.ConnectionTimeout); } netConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval); netConfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest); netConfig.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); netConfig.EnableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated); notifications = new Queue <string>(); netServer = new NetServer(netConfig); netServer.Start(); }
public void GetCatalogsByInstanceId(int id, out FetDatasetIdentify[] dsIds, out FetClassIdentify[] fetclassIds) { dsIds = null; fetclassIds = null; IServerInstance instance = GetServerInstanceById(id); if (instance == null) { throw new Exception(string.Format(HttpCommands.cstErrorInstanceIsNotExisted, id)); } try { ICatalogProvider prd = instance.CatalogProvider; if (prd == null) { throw new Exception(string.Format(HttpCommands.cstErrorCatalogProviderNotExistdOfInstance, id)); } dsIds = prd.GetFetDatasetIdentify(); fetclassIds = prd.GetFetClassIdentify(); } catch (Exception ex) { throw new Exception(string.Format(HttpCommands.cstErrorCatalogProviderNotExistdOfInstance + "," + ex.Message, id)); } }
protected override Dictionary <string, object> UpdateObject <T>(IServerInstance instance, T @new, T old) { var command = instance.Connection.CreateCommand(); var update = "UPDATE " + base.Table <T>() + " SET "; var count = 0; var changedPairs = CompareAndChange <T>(@new, old); if (changedPairs.Count == 0) { return(null); } foreach (var changedPair in changedPairs) { string paramName = string.Empty; paramName = "@" + changedPair.Key; if (changedPairs.Count - 1 == count) { update += changedPair.Key + "=@" + changedPair.Key; } else { update += changedPair.Key + "=@" + changedPair.Key + ","; } count++; IDbDataParameter parameter = command.CreateParameter(); parameter.ParameterName = paramName; parameter.Value = changedPair.Value; command.Parameters.Add(parameter); //command.Parameters.AddWithValue("@" + changedPair.Key, changedPair.Value); } string where = ""; // = " WHERE " + Key + "=@Key"; IDbDataParameter whereParam = command.CreateParameter(); where = " WHERE " + Key <T>() + "=@Key"; whereParam.ParameterName = "@Key"; whereParam.Value = @new.GetType().GetProperty(Key <T>()).GetValue(@new); command.CommandText = update + where; command.Parameters.Add(whereParam); command.ExecuteNonQuery(); return(changedPairs); }
public UpdateProviderLocal(IServerInstance serverInstance, UpdateProviderLocalConfiguration specificConfiguration, ILogger <UpdateProviderLocal> logger, IConfiguration configuration) { _serverInstance = serverInstance; _specificConfiguration = specificConfiguration; _logger = logger; _configuration = configuration; }
public Feature[] ReadFeatures(int instanceId, string fetclassId, Envelope evp) { IServerInstance instance = GetServerInstanceById(instanceId); if (instance == null) { throw new Exception(string.Format(HttpCommands.cstErrorInstanceIsNotExisted, instanceId)); } using (IFeaturesReaderService reader = instance.GetFeaturesReaderService(fetclassId)) { return(reader.Read(evp)); } }
public FetClassProperty GetFetClassProperty(int instanceId, string fetclassId) { IServerInstance instance = GetServerInstanceById(instanceId); if (instance == null) { throw new Exception(string.Format(HttpCommands.cstErrorInstanceIsNotExisted, instanceId)); } ICatalogProvider prd = instance.CatalogProvider; if (prd == null) { throw new Exception(string.Format(HttpCommands.cstErrorCatalogProviderNotExistdOfInstance, fetclassId)); } return(prd.GetFetClassProperty(fetclassId)); }
public void Arrange() { var serverMock = new Mock <IServerInstance>(); serverMock.Setup(s => s.GetServerInstance()).Returns("New Server For Tests"); _server = serverMock.Object; var serverComponentMock = new Mock <ServerComponent>(_server) { CallBase = true }; serverComponentMock.Setup(s => s.Execute(It.IsAny <int>())); _serverComponent = serverComponentMock.Object; }
/* * <VectorServerInstances> * <Instance name="北京1:5000万基础矢量服务" descrption="" args =""/> * <Instance name="世界1:5000万基础矢量服务" descrption="" args =""/> * </VectorServerInstances> */ public static IServerInstance[] Parse(string cnfgfile) { XDocument doc = XDocument.Load(cnfgfile); XElement root = doc.Element("VectorServerInstances"); var eles = root.Elements("Instance"); if (eles == null) { return(null); } List <IServerInstance> defs = new List <IServerInstance>(); foreach (XElement ele in eles) { int id = int.Parse(ele.Attribute("id").Value); string name = ele.Attribute("name").Value; string desc = ele.Attribute("description").Value; string args = ele.Attribute("args").Value; InstanceIdentify idobj = new InstanceIdentify(id, name, desc); IServerInstance def = ServerInstanceFactory.GetServerInstance(idobj, args); defs.Add(def); } return(defs.Count > 0 ? defs.ToArray() : null); }
public override void bootLoader(IServerInstance ist) { }
/// <summary> /// Questo è il primo modulo che viene caricato /// Diversamente da Wildfly lo standalone.xml come refernce al primo modulo /// caricato. Questo significa che , se è standalone faccio partire un modulo diverso da quello /// per il dominio. /// </summary> /// <param name="ist"></param> public abstract void bootLoader(IServerInstance ist);
public override void bootLoader(IServerInstance ist) { // Implementare in questo punto throw new NotImplementedException(); }
protected override void InsertObject <T>(IServerInstance instance, T obj) { var command = instance.Connection.CreateCommand(); command.CommandText = "INSERT INTO " + Table <T>() + " "; string columns = "(", values = " VALUES ("; var infos = obj.GetType().GetProperties(); for (var i = 0; i < infos.Length; i++) { IEnumerable <Identity> fields = infos[i].GetCustomAttributes(false).OfType <Identity>(); bool ignore = fields.Any(f => f.IgnoreField); if (ignore) { continue; } var o = infos[i].GetValue(obj); if (o == null) { continue; } if (o is DateTime && (DateTime)o == DateTime.MinValue) { continue; } string paramName = "?"; if (i == infos.Length - 1) { columns += infos[i].Name + ")"; values += "?)"; } else { columns += infos[i].Name + ","; values += "?,"; } IDbDataParameter parameter = command.CreateParameter(); parameter.ParameterName = paramName; parameter.Value = o; command.Parameters.Add(parameter); } columns = ReplaceTrailingComma(columns); values = ReplaceTrailingComma(values); command.CommandText += columns + values; command.ExecuteNonQuery(); }
public ServerComponent(IServerInstance server) { _server = server; }
public override void bootLoader(IServerInstance ist){ }
public PsqlDbContext(IServerInstance instance) { _instance = instance; }
private static void CheckExtensions(IServerInstance server) { Console.WriteLine(server.LoadHulkExtension()); Console.WriteLine(server.LoadWidowExtension()); }
public IExtensionsBase GetWidowExtension(IServerInstance server) { return(new WidowExtension(server)); }
protected virtual void CreateMappings <T>(T item, object linkProperty, object context, string andQuery, object value, string fieldTo, PropertyInfo info, IServerInstance instance) { if (linkProperty.GetType().Name.Contains("List")) { Type argument = linkProperty.GetType().GetGenericArguments()[0]; object objReturned = null; object[] parameters; Type[] types = null; if (andQuery == null) { if (value is int) { types = new[] { typeof(int), typeof(string) }; } else { types = new[] { typeof(string), typeof(string) }; } parameters = new[] { value, fieldTo }; } else { if (value is int) { types = new[] { typeof(int), typeof(string), typeof(string) }; } else { types = new[] { typeof(string), typeof(string), typeof(string) }; } parameters = new[] { value, fieldTo, andQuery }; } if (value is int) { objReturned = context.GetType().GetMethod("GetAll", types).MakeGenericMethod(argument) .Invoke(context, parameters); } if (value is string) { var genericMethod = context.GetType() .GetMethod("GetAll", types).MakeGenericMethod(argument); objReturned = genericMethod .Invoke(context, parameters); } info.SetValue(item, objReturned); } else { object objReturned = null; if (value is int) { objReturned = context.GetType() .GetMethod("GetById", new[] { typeof(int) }).MakeGenericMethod(linkProperty.GetType()) .Invoke(context, new[] { value }); } if (value is string) { objReturned = context.GetType() .GetMethod("GetById", new[] { typeof(string) }).MakeGenericMethod(linkProperty.GetType()) .Invoke(context, new[] { value }); } info.SetValue(item, objReturned); } }
public WidowExtension(IServerInstance server) : base(server, "Widow") { }
public OleDbContext(IServerInstance instance) { _instance = instance; }
/// <summary> /// Inserts a object to a database /// </summary> /// <param name="instance"></param> /// <param name="obj"></param> protected abstract void InsertObject <T>(IServerInstance instance, T obj);
Dictionary <string, object> UpdateObject <T>(IServerInstance instance, T @new, T old);
public HulkExtension(IServerInstance server) : base(server, "Hulk") { }
public IExtensionsBase GetHulkExtension(IServerInstance server) { return(new HulkExtension(server)); }
IExtensionsBase IExtensionsFactory.GetExtension <T>(IServerInstance server) { return(Activator.CreateInstance(typeof(T), server) as IExtensionsBase); }
public ExtensionsBase(IServerInstance server, string extensionName) { _server = server; _extenstionName = extensionName; }