本文整理汇总了C#中Topic.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# Topic.Subscribe方法的具体用法?C# Topic.Subscribe怎么用?C# Topic.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic.Subscribe方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start() {
using(var sr=new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("X13.Periphery.gpio.xst"))) {
Topic.Import(sr, null);
}
_gpio=Topic.root.Get("/dev/Gpio");
_gpio.Get<string>("_declarer", _gpio).value="Gpio";
_gpio.Subscribe("+", GpioChanged);
_poolTimer=new Timer(Pool, null, 500, 50);
}
示例2: Main
static void Main(string[] args)
{
var daemon = new ThreadPoolDaemon();
var topic = new Topic<string>();
topic.Subscribe(daemon, (line) => Console.WriteLine(line));
topic.Publish("Hello World !");
topic.Publish("Press Any Key ...");
Console.ReadKey();
}
示例3: TopicViewProp
public TopicViewProp(Topic item) {
obj=item;
obj.Subscribe("+", obj_changed);
propsColl=new PropertyDescriptorCollection(null);
foreach(PropertyDescriptor pr in TypeDescriptor.GetProperties(this.obj)) {
if(obj.valueType!=null || pr.Category!="Content") {
propsColl.Add(pr);
}
}
foreach(Topic tp in obj.children) {
if(tp.name=="_declarer" || tp.name=="_location" || tp.valueType==null) {
continue;
}
PropertyDescriptor np=new DVarPropertyDescriptor(tp);
propsColl.Add(np);
}
}
示例4: Main
static void Main(string[] args)
{
if (args.Length >= 1) _processNo = int.Parse(args[0]);
if (args.Length >= 2) _messagesPerProcess = int.Parse(args[1]);
_start = DateTime.UtcNow;
_countDown = _processNo;
for (int i = 0; i < _processNo; i++)
{
Topic<int> topic = new Topic<int>();
var daemon = new ThreadPoolDaemon();
topic.Subscribe(daemon, (msg) => Increment(topic, msg));
topic.Publish(0);
}
Console.ReadLine();
}
示例5: Parse
private void Parse(string rp, string json) {
if(rp.StartsWith(_remoteBase)) {
if(rp.Length==_remoteBase.Length) {
rp=name;
} else {
rp=name+rp.Substring(_remoteBase.Length);
}
} else {
return;
}
Topic cur;
if(!string.IsNullOrEmpty(json) && json!="null") { // Publish
if(!_var.Exist(rp, out cur) || cur.valueType==null) {
Type vt=X13.WOUM.ExConverter.Json2Type(json);
cur=Topic.GetP(_var.path+"/"+rp, vt, _var);
}
if(_val==null) {
_val=_var.Get(name);
_val.Subscribe("#", _local_changed);
}
cur.saved=false;
if(cur.valueType!=null) {
cur.FromJson(json, _val);
}
} else if(_var.Exist(rp, out cur)) { // Remove
cur.Remove(_val);
}
}
示例6: SetOwner
public void SetOwner(Topic owner) {
if(_owner!=null) {
_owner.Unsubscribe("+", STVarChanged);
}
_owner=owner;
if(_owner!=null) {
addr=int.Parse(owner.name.Substring(2));
if(_owner.parent!=null && _owner.parent.valueType==typeof(MsDevice)) {
_dev=(_owner.parent as DVar<MsDevice>).value;
}
_decl=_owner.Get<string>("_declarer", _owner);
_owner.Subscribe("+", STVarChanged);
if(_state!=0xB0) {
Reset();
}
} else {
_decl=null;
_state=0xB0;
_to.Change(-1, -1);
}
}
示例7: SetOwner
public void SetOwner(Topic owner) {
if(_owner!=null) {
if(Topic.brokerMode) {
_owner.Unsubscribe("+", STVarChanged);
}
}
if(_dev!=null) {
_dev.Pool+=_dev_Pool;
}
_owner=owner;
if(_owner!=null) {
name=owner.name;
if(Topic.brokerMode) {
if(_owner.parent!=null && _owner.parent.valueType==typeof(MsDevice)) {
_dev=(_owner.parent as DVar<MsDevice>).value;
}
_owner.Get<string>("_declarer", _owner).value="TWI";
_owner.Subscribe("+", STVarChanged);
if(_dev!=null) {
_dev.Pool+=_dev_Pool;
Reset();
}
}
}
}
示例8: SetOwner
public void SetOwner(Topic owner) {
if(!object.ReferenceEquals(owner, _owner)) {
if(_owner!=null) {
_owner.Unsubscribe("#", ChildChaged);
}
_owner=owner;
if(_owner!=null) {
_tPresent=_owner.Get<bool>("_present");
_tPresent.saved=false;
_owner.Get<string>("_declarer", _owner).value=_decl;
PSetOwner();
_owner.Subscribe("#", ChildChaged);
} else if(_gate!=null) {
_gate.DelDevice(this);
var dev=Topic.root.Get("/dev/1Wire").children.Select(z => z.GetValue() as OneWireBase).FirstOrDefault(z => z!=null && z!=this && this.rom.SequenceEqual(z.rom));
if(dev!=null) {
dev.gate=_gate;
}
_gate=null;
}
}
}
示例9: PiVar
public PiVar(Topic src) {
owner = src;
_cont=new List<PlcItem>();
layer=0;
owner.Subscribe(owner_changed, SubRec.SubMask.Once, true);
}