/// <summary> /// Adds an extension represented by an Extension instance. /// </summary> /// <param name="extension">The extension representation.</param> /// <returns>The builder class, for the fluent API.</returns> public IContextBuilder AddExtension(Extension extension) { foreach (var item in extension) { _extensions.Add(item.Key, item.Value); } return(this); }
/// <summary> /// Initializes an instance of an actor. /// </summary> public override async Task InitializeInstance() { this.xmppCredentials = await this.GetInstanceCredentials(); this.sniffer = this.Model.GetSniffer(this.userName); if (this.sniffer is null) { this.client = new XmppClient(this.xmppCredentials, "en", typeof(XmppActor).GetTypeInfo().Assembly); } else { this.client = new XmppClient(this.xmppCredentials, "en", typeof(XmppActor).GetTypeInfo().Assembly, this.sniffer); } this.client.OnStateChanged += this.Client_OnStateChanged; this.client.OnChatMessage += Client_OnChatMessage; this.client.OnConnectionError += Client_OnConnectionError; this.client.OnError += Client_OnError; this.client.OnErrorMessage += Client_OnErrorMessage; this.client.OnGroupChatMessage += Client_OnGroupChatMessage; this.client.OnHeadlineMessage += Client_OnHeadlineMessage; this.client.OnNormalMessage += Client_OnNormalMessage; this.client.OnPresence += Client_OnPresence; this.client.OnPresenceSubscribe += Client_OnPresenceSubscribe; this.client.OnRosterItemAdded += Client_OnRosterItemAdded; this.client.OnRosterItemRemoved += Client_OnRosterItemRemoved; this.client.OnRosterItemUpdated += Client_OnRosterItemUpdated; this.client.CustomPresenceXml += Client_CustomPresenceXml; if (this.Parent is IActor ParentActor) { foreach (ISimulationNode Node in ParentActor.Children) { if (Node is HandlerNode HandlerNode) { HandlerNode.RegisterHandlers(this, this.client); } if (Node is Extensions.IXmppExtension Extension) { await Extension.Add(this, Client); } } } this.connected = new TaskCompletionSource <bool>(); if (this.alwaysConnected) { this.client.Connect(this.domain); if (this.xmppCredentials.AllowRegistration && !(await this.connected.Task)) { throw new Exception("Unable to create account for " + this.userName + "@" + this.domain); } } }
private void AddChildEpcs(EpcisEvent evt) { var childQuantity = new XElement("childQuantityList", XmlEventFormatter.FormatEpcQuantity(evt, EpcType.ChildQuantity)); Root.Add(new XElement("childEPCs", XmlEventFormatter.FormatEpcList(evt, EpcType.ChildEpc))); if (childQuantity.HasElements) { Extension.Add(childQuantity); } }
public void TestAdd_2and3is5() { Assert.Equal(11, extension.Add(8, 3)); }
/// <summary> /// Adds an extension represented by an IRI and json content. /// </summary> /// <param name="extension">The IRI of the extension</param> /// <param name="jsonContent">The json representation of the extension value</param> /// <returns>The builder class, for the fluent API.</returns> public IActivityBuilder AddExtension(Uri extension, string jsonContent) { _extensions.Add(extension, jsonContent); return(this); }
/// <summary> /// Initializes an instance of an actor. /// </summary> public override async Task InitializeInstance() { this.xmppCredentials = await this.GetInstanceCredentials(); this.sniffer = this.Model.GetSniffer(this.userName); if (this.sniffer is null) { this.client = new XmppClient(this.xmppCredentials, "en", typeof(XmppActor).GetTypeInfo().Assembly); } else { this.client = new XmppClient(this.xmppCredentials, "en", typeof(XmppActor).GetTypeInfo().Assembly, this.sniffer); } this.client.OnStateChanged += this.Client_OnStateChanged; this.client.OnChatMessage += Client_OnChatMessage; this.client.OnConnectionError += Client_OnConnectionError; this.client.OnError += Client_OnError; this.client.OnErrorMessage += Client_OnErrorMessage; this.client.OnGroupChatMessage += Client_OnGroupChatMessage; this.client.OnHeadlineMessage += Client_OnHeadlineMessage; this.client.OnNormalMessage += Client_OnNormalMessage; this.client.OnPresence += Client_OnPresence; this.client.OnPresenceSubscribe += Client_OnPresenceSubscribe; this.client.OnRosterItemAdded += Client_OnRosterItemAdded; this.client.OnRosterItemRemoved += Client_OnRosterItemRemoved; this.client.OnRosterItemUpdated += Client_OnRosterItemUpdated; this.client.CustomPresenceXml += Client_CustomPresenceXml; string InstanceIndexSuffix = this.InstanceIndex.ToString(); int c = this.N.ToString().Length; int Nr0 = c - InstanceIndexSuffix.Length; if (Nr0 > 0) { InstanceIndexSuffix = new string('0', Nr0) + InstanceIndexSuffix; } if (this.Parent is IActor ParentActor) { foreach (ISimulationNode Node in ParentActor.Children) { if (Node is HandlerNode HandlerNode) { HandlerNode.RegisterHandlers(this, this.client); } if (Node is Extensions.IXmppExtension Extension) { object ExtensionObj = await Extension.Add(this, Client); if (!string.IsNullOrEmpty(Extension.Id)) { this.Model.Variables[Extension.Id + InstanceIndexSuffix] = ExtensionObj; } } } } if (this.alwaysConnected) { this.client.Connect(this.domain); if (this.xmppCredentials.AllowRegistration) { switch (await this.client.WaitStateAsync(30000, XmppState.Connected, XmppState.Error, XmppState.Offline)) { case 0: // Connected break; case 1: // Error case 2: // Offline default: throw new Exception("Unable to create account for " + this.userName + "@" + this.domain); } } } }
public static void Main(string[] args) { Personne p1 = new Personne(); Personne p2 = new Personne("Jean", "Louis"); Personne p3 = new Personne() { Nom = "El", Prenom = "Jean" }; Personne p4 = p2.Clone() as Personne; //Personne p4 = (Personne) p2.Clone(); //Console.WriteLine(p1); Console.WriteLine(p2); Console.WriteLine(p4); p2.Nom = "Cronier"; p4.Prenom = "Antoine"; Console.WriteLine(p2); Console.WriteLine(p4); //Console.WriteLine(p3); Jeu <CardGame> jeu = new Bataille(); // A proscrire je ne connais pas le type réel => Jeu<CardGame> //var jeu = new Bataille(); jeu.play(); // new sur abstract impossible. //Jeu jeu1 = new Jeu(); // var ici est possible car membre de droite connu var jeux = new List <Jeu <CardGame> >(); jeux.Add(jeu); jeux.Add(new Bataille()); foreach (var item in jeux) { item.play(); // Attention ne pas modifier les valeurs d'item dans le foreach } for (int i = 0; i < jeux.Count; i++) { jeux.ElementAt(i).play(); } Console.WriteLine(Extension.Add(10, 12)); int a = 10; Console.WriteLine(a.Add(12)); String b = "aizpepoazipe"; Console.WriteLine(b.Add("11111")); Func <String> func1 = new Func <string>(() => { return("func1"); }); Console.WriteLine(func1.Invoke()); Func <int, int, String> func2 = new Func <int, int, String>((i, j) => { return("produit i et j => " + (i * j)); }); Console.WriteLine(func2.Invoke(10, 12)); func2 = func2Test; Console.WriteLine(func2.Invoke(10, 12)); Action a1 = new Action(() => { Console.WriteLine("in a1"); Console.WriteLine(func2.Invoke(10, 12)); }); a1.Invoke(); Task.Factory.StartNew(() => { for (int i = 0; i < 10000; i++) { Console.WriteLine(i); } }); jeux.Where(x => x.Name.Equals("bataille")); Console.ReadKey(); }