ServiceContract(SessionMode = SessionMode.Allowed)] public interface IMyService { [OperationContract] void Init(StreamMetaData metaData); [OperationContract] StreamMetaData GetMetaData(); }
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,ConcurrencyMode = ConcurrencyMode.Multiple)] public class MyService : IMyService { private StreamMetaData _streamMetaData; private StreamMetaData StreamMetaData { get { return this._streamMetaData; } set { this._streamMetaData= value; } } public void Init(StreamMetaData metaData) { if (metaData == null) throw new ArgumentNullException("metaData"); try { this.StreamMetaData = metaData; } catch (Exception ex) { throw ex; } } public StreamMetaData GetMetaData() { return this.StreamMetaData; } }
MyServiceNetTcp.MyServiceClient client= new MyServiceNetTcp.MyServiceClient (); client.Open(); //metaData is an instance of StreamMetaData initialised somewhere in the code client.Init(metaData); var currentMetaData = client.GetMetaData(); //Returns null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)