public VasilyDapper(string key, int?timeout = null) { Timeout = timeout; ConnectionMapper mapper = VasilyCache.ConnectionCache[key]; Connection = (IDbConnection)Activator.CreateInstance(mapper.ConnectionType, mapper.ConnectionString); }
/// <summary> /// 注册SqlConnection /// </summary> /// <typeparam name="T">SqlConnection类型</typeparam> /// <param name="key">获取实例的hashKey</param> /// <param name="connectionString">链接字符串</param> public static void AddConnection <T>(string key, string connectionString) { ConnectionMapper mapper = new ConnectionMapper(); mapper.ConnectionType = typeof(T); mapper.ConnectionString = connectionString; VasilyCache.ConnectionCache[key] = mapper; }
public ManifestCaptureGraphInstance(NodeTemplate singleNodeGraph) { node = singleNodeGraph; instance = node.CreateInstance(); var connectionMapper = new ConnectionMapper(instance, this); node.Inputs(connectionMapper, instance); node.Outputs(connectionMapper, instance); }
/// <summary> /// 通过key获取IDbConnection /// </summary> /// <param name="key">KEY</param> /// <returns></returns> public static IDbConnection GetConnection(string key) { if (VasilyCache.ConnectionCache.ContainsKey(key)) { ConnectionMapper mapper = VasilyCache.ConnectionCache[key]; return((IDbConnection)Activator.CreateInstance(mapper.ConnectionType, mapper.ConnectionString)); } else { return(null); } }
public Worker(string filePath) { this.filePath = filePath; _parser = new Parser(); _analogMapper = new AnalogMapper(); _connectionMapper = new ConnectionMapper(); _legacyNameMapper = new LegacyNameMapper(); _messageMapper = new MessageMapper(); _multistateMapper = new MultistateMapper(); _rateMapper = new RateMapper(); _remConnJoinMapper = new RemConnJoinMapper(); _remoteMapper = new RemoteMapper(); _stationMapper = new StationMapper(); _statusMapper = new StatusMapper(); _templateMapper = new CGLTemplateMapper(); _CGLMapper = new CGLMapper(); }
public override OutputMap[] Outputs(ConnectionMapper graph) => null;
public override InputMap[] Inputs(ConnectionMapper graph) => new[] { graph.Connect(ref Template.Repetitions, ref Repetitions), };
public override OutputMap[] Outputs(ConnectionMapper connections) => null;
public override InputMap[] Inputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Value, ref Value), };
public override OutputMap[] Outputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Output, ref Output) };
public override InputMap[] Inputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Character, ref Character), };
public override InputMap[] Inputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Building, ref Building) };
public static NodeInformation Construct(Type nodeType) { var nodeInformation = new NodeInformation(); var nodeTemplate = (NodeTemplate)Activator.CreateInstance(nodeType); var metadataInstance = (NodeInstanceBase)nodeTemplate.CreateInstance(); var instanceType = metadataInstance.GetType(); var singleNodeGraph = new ManifestCaptureGraphInstance(nodeTemplate); int inputId = 0; int outputId = 0; var inputSocketFields = new List <FieldInfo>(); var outputSocketFields = new List <FieldInfo>(); var fieldInfos = new Dictionary <string, FieldInformation>(); foreach (var field in nodeType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if (field.FieldType == typeof(OutputSocket)) { field.SetValue(nodeTemplate, new OutputSocket(outputId)); outputId++; outputSocketFields.Add(field); } else { if (field.FieldType == typeof(InputSocket)) { field.SetValue(nodeTemplate, new InputSocket(inputId)); inputId++; inputSocketFields.Add(field); } fieldInfos.Add(field.Name, FieldInformation.ConstructFieldInformation(field, nodeTemplate)); } } nodeInformation.Fields = fieldInfos; var nodeProperty = instanceType.GetProperty("Template"); nodeProperty.SetValue(metadataInstance, nodeTemplate); var connectionMapper = new ConnectionMapper(metadataInstance, singleNodeGraph); var inputsArray = metadataInstance.Inputs(connectionMapper); var outputsArray = metadataInstance.Outputs(connectionMapper); if (inputsArray != null) { nodeInformation.Inputs = new Dictionary <string, SocketInformation>(inputsArray.Length); for (int i = 0; i < inputsArray.Length; i++) { var map = inputsArray[i]; var field = inputSocketFields[map.ConnectionId]; nodeInformation.Inputs.Add(field.Name, SocketInformation.Construct(field, map)); } } else { nodeInformation.Inputs = null; } if (outputsArray != null) { nodeInformation.Outputs = new Dictionary <string, SocketInformation>(outputsArray.Length); for (int i = 0; i < outputsArray.Length; i++) { var map = outputsArray[i]; var field = outputSocketFields[map.ConnectionId]; nodeInformation.Outputs.Add(field.Name, SocketInformation.Construct(field, map)); } } else { nodeInformation.Outputs = null; } return(nodeInformation); }
public override InputMap[] Inputs(ConnectionMapper connections) => null;
public override OutputMap[] Outputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Neighbours, ref Neighbours), };
public override OutputMap[] Outputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Owner, ref Owner), connections.Connect(ref Template.Building, ref Building) };
public override OutputMap[] Outputs(ConnectionMapper connections) => new[] { connections.Connect(ref Template.Players, ref Players), connections.Connect(ref Template.Building, ref Building) };