public WoopsaMethod GetMethod(string name, WoopsaValueType returnType, WoopsaMethodArgumentInfo[] argumentInfos) { WoopsaMethod result = Methods.ByNameOrNull(name); if (result != null) { if (result.ReturnType != returnType) { throw new Exception(string.Format( "A method with then name {0} exists, but with the return type {1} instead of {2}", name, result.ReturnType, returnType)); } else if (result.ArgumentInfos.IsSame(argumentInfos)) { throw new Exception(string.Format( "A method with then name {0} exists, but with different arguments", name)); } else { return(result); } } else { return(base.CreateMethod(name, argumentInfos, returnType)); } }
internal void Add(WoopsaMethod item) { lock (Lock) { if (_methods.ByNameOrNull(item.Name) != null) { throw new WoopsaException("Tried to add a method with duplicate name '" + item.Name + "' to WoopsaObject '" + Name + "'"); } _methods.Add(item); } }
public WoopsaSubscriptionService(WoopsaServer server, WoopsaContainer container) : base(container, WoopsaSubscriptionServiceConst.WoopsaServiceSubscriptionName) { _server = server; _subscriptionServiceImplementation = new WoopsaSubscriptionServiceImplementation(container, true); _subscriptionServiceImplementation.BeforeWoopsaModelAccess += (sender, e) => { server.ExecuteBeforeWoopsaModelAccess(); }; _subscriptionServiceImplementation.AfterWoopsaModelAccess += (sender, e) => { server.ExecuteAfterWoopsaModelAccess(); }; _subscriptionServiceImplementation.CanWatch += OnCanReconnectSubscriptionToNewObject; MethodCreateSubscriptionChannel = new WoopsaMethod( this, WoopsaSubscriptionServiceConst.WoopsaCreateSubscriptionChannel, WoopsaValueType.Integer, new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaNotificationQueueSize, WoopsaValueType.Integer) }, arguments => _subscriptionServiceImplementation.CreateSubscriptionChannel(arguments[0].ToInt32()) ); MethodRegisterSubscription = new WoopsaMethod( this, WoopsaSubscriptionServiceConst.WoopsaRegisterSubscription, WoopsaValueType.Integer, new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer), new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaPropertyLink, WoopsaValueType.WoopsaLink), new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaMonitorInterval, WoopsaValueType.TimeSpan), new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaPublishInterval, WoopsaValueType.TimeSpan) }, arguments => { return(_subscriptionServiceImplementation.RegisterSubscription( arguments[0].ToInt32(), arguments[1].DecodeWoopsaLocalLink(), arguments[2].ToTimeSpan(), arguments[3].ToTimeSpan())); }); MethodUnregisterSubscription = new WoopsaMethod( this, WoopsaSubscriptionServiceConst.WoopsaUnregisterSubscription, WoopsaValueType.Logical, new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer), new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionId, WoopsaValueType.Integer) }, arguments => { return(_subscriptionServiceImplementation.UnregisterSubscription( arguments[0].ToInt32(), arguments[1].ToInt32())); }); MethodWaitNotification = new WoopsaMethod( this, WoopsaSubscriptionServiceConst.WoopsaWaitNotification, WoopsaValueType.JsonData, new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaSubscriptionChannel, WoopsaValueType.Integer), new WoopsaMethodArgumentInfo(WoopsaSubscriptionServiceConst.WoopsaLastNotificationId, WoopsaValueType.Integer) }, arguments => { using (var accessFreeSection = _server.EnterModelAccessFreeSection()) return(new WoopsaValue(_subscriptionServiceImplementation.WaitNotification( arguments[0].ToInt32(), arguments[1].ToInt32()))); }); }
internal void Remove(WoopsaMethod item) { lock (Lock) _methods.Remove(item); }