System.Collections.Concurrent.ConcurrentBag.Add(System.Type)

Here are the examples of the csharp api class System.Collections.Concurrent.ConcurrentBag.Add(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

1. Example

Project: MessageShark
Source File: CustomBinary.Setup.cs
internal static void RegisterBufferedType<T>() {
            BufferedTypes.Add(typeof(T));
        }

2. Example

Project: MessageShark
Source File: CustomBinary.Setup.cs
internal static void RegisterReader<T>(Func<byte[], Type, T> func) {
            if (!func.Method.IsPublic) throw new InvalidOperationException("func.Method must be a public method!");
            var type = typeof(T);
            PrimitiveReaderMethods[type] = func.Method;
            PrimitiveReadersWithTypes.Add(type);
        }

3. Example

Project: RedDog
Source File: FluentMessageRegistration.cs
public IFluentMessageRegistration<TMessage> With<TMessageType>()
            where TMessageType : TMessage
        {
            _messageTypes.Add(typeof(TMessageType));
            return this;
        }

4. Example

Project: spring-net
Source File: SpringMvcDependencyResolver.cs
public object GetService(Type serviceType)
        {
            object service = null;

           /n ..... /n //View Source file for more details /n }

5. Example

Project: revenj
Source File: NotifyHub.cs
public bool Register(string connectionId, Action<string[]> onChanged)
			{
				ConcurrentDictionary<string, IDisposable> dict;
				if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
				{
					dict = new ConcurrentDictionary<string, IDisposable>();
					if (!Listeners.TryAdd(typeof(TDomainObject), dict))
						return false;
				}
				var name = typeof(TDomainObject).FullName;
				var listener = ChangeNotification.Track<TDomainObject>().Subscribe(kv => onChanged(kv.Key));
				if (!dict.TryAdd(connectionId, listener))
					listener.Dispose();
				else
				{
					ConcurrentBag<Type> bag;
					if (!Connections.TryGetValue(connectionId, out bag))
					{
						bag = new ConcurrentBag<Type>();
						Connections.TryAdd(connectionId, bag);
					}
					bag.Add(typeof(TDomainObject));
				}
				return true;
			}

6. Example

Project: revenj
Source File: NotifyHub.cs
public bool Register(string connectionId, Action<string[]> onChanged)
			{
				ConcurrentDictionary<string, IDisposable> dict;
				if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
				{
					dict = new ConcurrentDictionary<string, IDisposable>();
					if (!Listeners.TryAdd(typeof(TDomainObject), dict))
						return false;
				}
				var name = typeof(TDomainObject).FullName;
				var listener = ChangeNotification.Track<TDomainObject>().Subscribe(kv => onChanged(kv.Key));
				if (!dict.TryAdd(connectionId, listener))
					listener.Dispose();
				else
				{
					ConcurrentBag<Type> bag;
					if (!Connections.TryGetValue(connectionId, out bag))
					{
						bag = new ConcurrentBag<Type>();
						Connections.TryAdd(connectionId, bag);
					}
					bag.Add(typeof(TDomainObject));
				}
				return true;
			}

7. Example

Project: revenj
Source File: NotifyHub.cs
public bool Register(string connectionId, Type type, string specificationJson, Action<string> onMatched)
			{
				Func<TDomainObject, bool> isMatched;
				try
				{
					ISpecification<TDomainObject> specification = (ISpecification<TDomainObject>)Newtonsoft.Json.JsonConvert.DeserializeObject(specificationJson, type);
					isMatched = specification.IsSatisfied.Compile();
				}
				catch { return false; }
				ConcurrentDictionary<string, IDisposable> dict;
				if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
				{
					dict = new ConcurrentDictionary<string, IDisposable>();
					if (!Listeners.TryAdd(typeof(TDomainObject), dict))
						return false;
				}
				var name = typeof(TDomainObject).FullName;
				var listener = ChangeNotification.Track<TDomainObject>().Subscribe(kv =>
					{
						foreach (var v in kv.Value.Value)
							if (isMatched(v))
								onMatched(v.URI);
					});
				if (!dict.TryAdd(connectionId, listener))
					listener.Dispose();
				else
				{
					ConcurrentBag<Type> bag;
					if (!Connections.TryGetValue(connectionId, out bag))
					{
						bag = new ConcurrentBag<Type>();
						Connections.TryAdd(connectionId, bag);
					}
					bag.Add(typeof(TDomainObject));
				}
				return true;
			}

8. Example

Project: revenj
Source File: NotifyHub.cs
public bool Register(string connectionId, Type type, string specificationJson, Action<string> onMatched)
			{
				Func<TDomainObject, bool> isMatched;
				try
				{
					ISpecification<TDomainObject> specification = (ISpecification<TDomainObject>)Newtonsoft.Json.JsonConvert.DeserializeObject(specificationJson, type);
					isMatched = specification.IsSatisfied.Compile();
				}
				catch { return false; }
				ConcurrentDictionary<string, IDisposable> dict;
				if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
				{
					dict = new ConcurrentDictionary<string, IDisposable>();
					if (!Listeners.TryAdd(typeof(TDomainObject), dict))
						return false;
				}
				var name = typeof(TDomainObject).FullName;
				var listener = ChangeNotification.Track<TDomainObject>().Subscribe(kv =>
					{
						foreach (var v in kv.Value.Value)
							if (isMatched(v))
								onMatched(v.URI);
					});
				if (!dict.TryAdd(connectionId, listener))
					listener.Dispose();
				else
				{
					ConcurrentBag<Type> bag;
					if (!Connections.TryGetValue(connectionId, out bag))
					{
						bag = new ConcurrentBag<Type>();
						Connections.TryAdd(connectionId, bag);
					}
					bag.Add(typeof(TDomainObject));
				}
				return true;
			}