当前位置: 首页>>代码示例>>C#>>正文


C# IDisposable类代码示例

本文整理汇总了C#中IDisposable的典型用法代码示例。如果您正苦于以下问题:C# IDisposable类的具体用法?C# IDisposable怎么用?C# IDisposable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IDisposable类属于命名空间,在下文中一共展示了IDisposable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

 public void Add(IDisposable component)
 {
     if (component != null)
     {
         this.components.Add(component);
     }
 }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:7,代码来源:CompositeDisposableObject.cs

示例2: ItemAutoSubscription

 /// <summary>
 ///   Initializes a new instance of the <see cref = "ItemAutoSubscription" /> class.
 /// </summary>
 /// <param name = "item">
 ///   The subscribed item.
 /// </param>
 /// <param name = "itemPosition">
 ///   The item position.
 /// </param>
 /// <param name = "itemRegion">
 ///   The item Region.
 /// </param>
 /// <param name = "subscription">
 ///   The subscription.
 /// </param>
 public ItemAutoSubscription(Item item, Vector itemPosition, Region itemRegion, IDisposable subscription)
 {
     this.ItemPosition = itemPosition;
     this.item = item;
     this.subscription = subscription;
     this.WorldRegion = itemRegion;
 }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:22,代码来源:ItemAutoSubscription.cs

示例3: SetVideoCodecToken

		/// <summary>
		/// sets the codec token to be used for video compression
		/// </summary>
		public void SetVideoCodecToken(IDisposable token)
		{
			if (token is CodecToken)
				currVideoCodecToken = (CodecToken)token;
			else
				throw new ArgumentException("AviWriter only takes its own Codec Tokens!");
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:10,代码来源:AviWriter.cs

示例4: Configure

        private void Configure(AzureServiceBusOwinServiceConfiguration config, Action<IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var options = new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory = new AzureServiceBusOwinServerFactory(config);
            var services = ServicesFactory.Create();
            var engine = services.GetService<IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup = startup
            };
            _started = engine.Start(context);
            _next = testServerFactory.Invoke;
        }
开发者ID:pmhsfelix,项目名称:ndc-london-13-web-api,代码行数:25,代码来源:AzureServiceBusOwinServer.cs

示例5: LightningQueuesChannel

 public LightningQueuesChannel(Uri address, string queueName, Queue queueManager)
 {
     Address = address;
     _queueName = queueName;
     _queueManager = queueManager;
     _disposable = Disposable.Empty;
 }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:7,代码来源:LightningQueuesChannel.cs

示例6: Open

        public static void Open(params string[] hostUrls)
        {
            try
            {
                if (_CloseOWin == null)
                {
                    // Start OWIN host
                    StartOptions so = new StartOptions();
                    foreach (string s in hostUrls)
                    {
                        so.Urls.Add(s);
                    }
                    _CloseOWin = WebApp.Start<SNStartup>(so);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException is System.Net.HttpListenerException)
                {
                    throw new Exception("监听IP有错误");
                }

                if (_CloseOWin != null)
                {
                    _CloseOWin.Dispose();//必须
                    _CloseOWin = null;//必须
                }

                throw;
            }
        }
开发者ID:fengxingshi,项目名称:CZJC,代码行数:31,代码来源:SNOwin.cs

示例7: NodeViewModel

        public NodeViewModel(Node node, Vector location, IControlTypesResolver controlTypesResolver)
        {
            Node = node;
            Title = node.Title;
            Location = new CanvasPoint(location);
            ControlTypesResolver = controlTypesResolver;

            foreach (var pin in node.InputPins)
            {
                AddInputPin(pin);
            }

            foreach (var pin in node.OutputPins)
            {
                AddOutputPin(pin);
            }

            node.Processed += OnNodeProcessed;
            node.PinsChanged += OnNodePinsChanged;

            _disposable = Disposable.Create(() =>
            {
                node.PinsChanged -= OnNodePinsChanged;
                node.Processed -= OnNodeProcessed;
            });
        }
开发者ID:misupov,项目名称:Turbina,代码行数:26,代码来源:NodeViewModel.cs

示例8: MDRefactoringScript

		public MDRefactoringScript (MDRefactoringContext context, CSharpFormattingOptions formattingOptions) : base(context.TextEditor.Document, formattingOptions, context.TextEditor.CreateNRefactoryTextEditorOptions ())
		{
			this.context = context;
			undoGroup  = this.context.TextEditor.OpenUndoGroup ();
			this.startVersion = this.context.TextEditor.Version;

		}
开发者ID:sturmrutsturm,项目名称:monodevelop,代码行数:7,代码来源:MDRefactoringScript.cs

示例9: Dispose

        public void Dispose()
        {
            if(_storeSubscription == null)
                return;

            _storeSubscription.Dispose();
            _storeSubscription = null;

            _pluginChannel.Do(x => x.Value.Dispose());
            _pluginChannel.Clear();
            _pluginChannel = null;

            _pluginServer.Do(x => x.Value.Dispose());
            _pluginServer.Clear();
            _pluginServer = null;

            _pluginGlobal.Do(x => x.Value.Dispose());
            _pluginGlobal.Clear();
            _pluginGlobal = null;

            _channel.Do(x => x.Value.Dispose());
            _channel.Clear();
            _channel = null;

            _server.Do(x => x.Value.Dispose());
            _server.Clear();
            _server = null;

            _global.Dispose();
            _global = null;
        }
开发者ID:Gohla,项目名称:Veda,代码行数:31,代码来源:StorageManager.cs

示例10: VirtualListVewModel

        public VirtualListVewModel(SynchronizationContext bindingContext, DataService service)
        {
            _virtualRequest = new BehaviorSubject<VirtualRequest>(new VirtualRequest(0,10));

            Items = new BindingList<Poco>();

            var sharedDataSource = service
                .DataStream
                .Do(x => Trace.WriteLine($"Service -> {x}"))
                .ToObservableChangeSet()
                .Publish();

            var binding = sharedDataSource
                          .Virtualise(_virtualRequest)
                          .ObserveOn(bindingContext)
                          .Bind(Items)
                          .Subscribe();
            
            //the problem was because Virtualise should fire a noticiation if count changes, but it does not [BUG]
            //Therefore take the total count from the underlying data NB: Count is DD.Count() not Observable.Count()
            Count = sharedDataSource.Count().DistinctUntilChanged();

            Count.Subscribe(x => Trace.WriteLine($"Count = {x}"));

            var connection = sharedDataSource.Connect();
            _disposables = new CompositeDisposable(binding, connection);
        }
开发者ID:RolandPheasant,项目名称:Test-Dynamic-Data,代码行数:27,代码来源:VirtualListVewModel.cs

示例11: Connect

 public void Connect(IEventStream stream)
 {
     subscription = stream.Of<IEventPattern<IDevice, ISensed>>().Subscribe(sensed =>
     {
         var type = topicRegistry.Find(sensed.EventArgs.Topic);
         switch (type)
         {
             case TopicType.Boolean:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToBoolean(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.Number:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToNumber(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.String:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToString(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.Void:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Unit.Default, clock.Now));
                 break;
             case TopicType.Unknown:
             default:
                 // TODO: throw? Report?
                 break;
         }
     });
 }
开发者ID:kzu,项目名称:Sensorium,代码行数:26,代码来源:SensedToImpulse.cs

示例12: BeginTransaction

		public bool BeginTransaction ()
		{
			if (inTransaction)
				throw new InvalidOperationException ("Already in a transaction");
			
			transactionLock = LockWrite ();
			try {
				updatingLock = new FileStream (UpdateDatabaseLockFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
			} catch (IOException) {
				// The database is already being updated. Can't do anything for now.
				return false;
			} finally {
				transactionLock.Dispose ();
			}

			// Delete .new files that could have been left by an aborted database update
			
			transactionLock = LockRead ();
			CleanDirectory (rootDirectory);
			
			inTransaction = true;
			foldersToUpdate = new Hashtable ();
			deletedFiles = new Hashtable ();
			deletedDirs = new Hashtable ();
			return true;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:26,代码来源:FileDatabase.cs

示例13: AggregationViewModel

        public AggregationViewModel()
        {
            var sourceList = new SourceList<AggregationItem>();

            sourceList.AddRange(Enumerable.Range(1, 15).Select(i => new AggregationItem(i)));

            //Load items to display to user and allow them to include items or not
         
            var listLoader = sourceList.Connect()
                .Sort(SortExpressionComparer<AggregationItem>.Ascending(vm => vm.Number))
                .ObserveOnDispatcher()
                .Bind(out _items)
                .Subscribe();

            // share the connection because we are doing multiple aggregations
            var aggregatable = sourceList.Connect()
                .FilterOnProperty(vm => vm.IncludeInTotal, vm => vm.IncludeInTotal)
                .Publish();

            //Do a custom aggregation (ToCollection() produces a readonly collection of underlying data)
            var sumOfOddNumbers = aggregatable.ToCollection()
                .Select(collection => collection.Where(i => i.Number%2 == 1).Select(ai => ai.Number).Sum())
                .Subscribe(sum => SumOfOddNumbers = sum);
            
            _cleanUp = new CompositeDisposable(sourceList, 
                listLoader,
                aggregatable.Count().Subscribe(count => Count = count),
                aggregatable.Sum(ai => ai.Number).Subscribe(sum => Sum = sum),
                aggregatable.Avg(ai => ai.Number).Subscribe(average => Avg = Math.Round(average,2)),
                aggregatable.Minimum(ai => ai.Number).Subscribe(max => Max = max),
                aggregatable.Maximum(ai => ai.Number).Subscribe(min => Min = min),
                aggregatable.StdDev(ai => ai.Number).Subscribe(std => StdDev = Math.Round(std, 2)),
                sumOfOddNumbers,
                aggregatable.Connect());
        }
开发者ID:RolandPheasant,项目名称:DynamicData.Samplz,代码行数:35,代码来源:AggregationViewModel.cs

示例14: SPOEmulationContext

        /// <summary>
        /// Initializes a new instance of the <see cref="SPOEmulationContext"/> class.
        /// </summary>
        /// <param name="isolationLevel">The level.</param>
        /// <param name="connectionInformation">The connection informations for the target web.</param>
        public SPOEmulationContext(IsolationLevel isolationLevel, ConnectionInformation connectionInformation)
        {
            this._isolationLevel = isolationLevel;

            switch (isolationLevel)
            {
                case IsolationLevel.Fake:
                    // create shim context
                    _shimsContext = ShimsContext.Create();

                    // initialize all simulated types
                    _clientContext = InitializeSimulatedAPI(connectionInformation.Url);
                    break;
                case IsolationLevel.Integration:
                    // create shim context
                    _shimsContext = ShimsContext.Create();
                    Connect(connectionInformation);
                    break;
                case IsolationLevel.None:
                    Connect(connectionInformation);
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
开发者ID:mehrosu,项目名称:SPOEmulators,代码行数:30,代码来源:SPOEmulationContext.cs

示例15: Start

        // global instances that keep controller and windows service alive

        public void Start(QueueMessageManager manager = null)
        {
            if (manager == null)
                manager = new QueueMessageManagerSql();

            LogManager.Current.LogInfo("Start called");

            var config = QueueMessageManagerConfiguration.Current;

            Controller = new QueueController()
            {
                ConnectionString = config.ConnectionString,
                QueueName = config.QueueName,
                WaitInterval = config.WaitInterval,
                ThreadCount = config.ControllerThreads                
            };
            

            LogManager.Current.LogInfo("Controller created.");
            
            // asynchronously start the SignalR hub
            SignalR = WebApplication.Start<SignalRStartup>("http://*:8080/");

            // *** Spin up n Number of threads to process requests
            Controller.StartProcessingAsync();

            LogManager.Current.LogInfo(String.Format("QueueManager Controller Started with {0} threads.",
                                       Controller.ThreadCount));            

            // Set static instances so that these 'services' stick around
            GlobalService.Controller = Controller;
            GlobalService.Service = this;
        }
开发者ID:RickStrahl,项目名称:Westwind.QueueMessageManager,代码行数:35,代码来源:QueueService.cs


注:本文中的IDisposable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。