public SerializationContext()
        {
            _outputTypeComment     = true;
            _outputTypeInformation = true;
            _referenceWritingType  = ReferenceOption.ErrorCircularReferences;

            _typeAliases = new TypeAliasCollection();

            // collections
            _collectionHandlers = new List <CollectionHandler>();
            _collectionHandlers.Add(new GenericCollectionHandler());
            _collectionHandlers.Add(new ArrayHandler());
            _collectionHandlers.Add(new ListHandler());
            _collectionHandlers.Add(new StackHandler());
            _collectionHandlers.Add(new GenericStackHandler());
            _collectionHandlers.Add(new CollectionConstructorHandler());

            // type handlers
            _typeHandlerFactory = new TypeDataRepository(this);
            _parameters         = new Hashtable();

            // type conversion
            _typeHandlerFactory.RegisterTypeConverter(typeof(System.Collections.BitArray), new BitArrayConverter());

            this.expressionHandlers = new ExpressionHandlerCollection(this);
        }
        public SerializationContext()
        {
            _outputTypeComment = true;
            _outputTypeInformation = true;
            _referenceWritingType = ReferenceOption.ErrorCircularReferences;

            _typeAliases = new TypeAliasCollection();

            // collections
            _collectionHandlers = new List<CollectionHandler>();
            _collectionHandlers.Add(new GenericCollectionHandler());
            _collectionHandlers.Add(new ArrayHandler());
            _collectionHandlers.Add(new ListHandler());
            _collectionHandlers.Add(new StackHandler());
            _collectionHandlers.Add(new GenericStackHandler());
            _collectionHandlers.Add(new CollectionConstructorHandler());

            // type handlers
            _typeHandlerFactory = new TypeDataRepository(this);
            _parameters = new Hashtable();

            // type conversion
            _typeHandlerFactory.RegisterTypeConverter(typeof(System.Collections.BitArray), new BitArrayConverter());

            this.expressionHandlers = new ExpressionHandlerCollection(this);
            this.defaultValues = new DefaultValueCollection();
        }
		public UIThreadSubscription(EventBase parentEvent, Action action, ThreadOption threadOption,
		                            ReferenceOption referenceOption)
			: base(parentEvent, action, threadOption, referenceOption)
		{
			if (ThreadOption != ThreadOption.UIThread && ThreadOption != ThreadOption.UIThreadPost)
			{
				throw new InvalidOperationException("Incorrect thread option");
			}
		}
		protected EventSubscription(EventBase parentEvent,
									Action action,
									ThreadOption threadOption,
									ReferenceOption referenceOption)
			: base(parentEvent, threadOption, referenceOption)
		{
			Verify.ArgumentNotNull(action, "action");
			DelegateReference = new DelegateReference(action, referenceOption);
		}
Example #5
0
		/// <summary>
		/// Subscribe to the event.
		/// </summary>
		/// <param name="action">Action to take when the event is published.</param>
		/// <param name="threadOption">Specifies which thread the action will be performed on.</param>
		/// <param name="referenceOption">Specifies whether the event subscription will hold a strong or 
		/// weak reference on the action delegate.</param>
		/// <returns>Returns an <see cref="IEventSubscription"/> object that represents the subscription.</returns>
		public IEventSubscription Subscribe(Action action, ThreadOption threadOption,
											ReferenceOption referenceOption)
		{
			Verify.ArgumentNotNull(action, "action");
			EventSubscription eventSubscription = CreateEventSubscription(action, threadOption, referenceOption);
			lock (_eventSubscriptions)
			{
				_eventSubscriptions.Add(eventSubscription);
			}
			return eventSubscription;
		}
		public BackgroundThreadSubscription(EventBase parentEvent,
											Action action,
											ThreadOption threadOption,
											ReferenceOption referenceOption)
			: base(parentEvent, action, threadOption, referenceOption)
		{
			if (ThreadOption != ThreadOption.BackgroundThread)
			{
				throw new InvalidOperationException("Invalid thread option");
			}
		}
		public DelegateReference(Delegate referencedDelegate, ReferenceOption referenceOption)
		{
			Verify.ArgumentNotNull(referencedDelegate, "referencedDelegate");
			if (referenceOption == ReferenceOption.StrongReference)
			{
				_delegate = referencedDelegate;
			}
			else
			{
				if (referencedDelegate.Target != null)
				{
					_weakReference = new WeakReference(referencedDelegate.Target);
				}
				_methodInfo = referencedDelegate.Method;
				_delegateType = referencedDelegate.GetType();
			}
		}
Example #8
0
        private string GetSqlForAction(ReferenceOption opt)
        {
            string result = "";

            switch (opt)
            {
            case ReferenceOption.Cascade:
                result = "CASCADE";
                break;

            case ReferenceOption.Restrict:
                result = "RESTRICT";
                break;

            case ReferenceOption.NoAction:
                result = "NO ACTION";
                break;

            case ReferenceOption.SetNull:
                result = "SET NULL";
                break;
            }
            return(result);
        }
Example #9
0
        private ReferenceOption GetActionForSql(string sqlAction)
        {
            ReferenceOption result = ReferenceOption.Restrict;

            switch (sqlAction.ToUpper())
            {
            case "CASCADE":
                result = ReferenceOption.Cascade;
                break;

            case "RESTRICT":
                result = ReferenceOption.Restrict;
                break;

            case "NO ACTION":
                result = ReferenceOption.NoAction;
                break;

            case "SET NULL":
                result = ReferenceOption.SetNull;
                break;
            }
            return(result);
        }
Example #10
0
 /// <summary>
 /// This will set the serializer to output in Json strict mode which will only
 /// output information compatible with the JSON standard.
 /// </summary>
 public void SetJsonStrictOptions()
 {
     _outputTypeComment = false;
     _outputTypeInformation = false;
     _referenceWritingType = ReferenceOption.ErrorCircularReferences;
 }
 /// <summary>
 /// This will set the serializer to output in Json strict mode which will only
 /// output information compatible with the JSON standard.
 /// </summary>
 public void SetJsonStrictOptions()
 {
     _outputTypeComment     = false;
     _outputTypeInformation = false;
     _referenceWritingType  = ReferenceOption.ErrorCircularReferences;
 }
Example #12
0
		/// <summary>
		/// Create the right type of event subscription for the thread option
		/// </summary>
		private EventSubscription CreateEventSubscription(Action action, ThreadOption threadOption,
																	ReferenceOption referenceOption)
		{
			switch (threadOption)
			{
				case ThreadOption.PublisherThread:
					return new PublishThreadSubscription(this, action, threadOption, referenceOption);
				case ThreadOption.UIThread:
				case ThreadOption.UIThreadPost:
					return new UIThreadSubscription(this, action, threadOption, referenceOption);
				case ThreadOption.BackgroundThread:
					return new BackgroundThreadSubscription(this, action, threadOption, referenceOption);
			}

			// this should not happen.
			throw new ArgumentException("Unknown thread option: " + threadOption);
		}
Example #13
0
 private string GetSqlForAction( ReferenceOption opt )
 {
   string result = "";
   switch (opt)
   {
     case ReferenceOption.Cascade:
       result = "CASCADE";
       break;
     case ReferenceOption.Restrict:
       result = "RESTRICT";
       break;
     case ReferenceOption.NoAction:
       result = "NO ACTION";
       break;
     case ReferenceOption.SetNull:
       result = "SET NULL";
       break;
   }
   return result;
 }
		protected EventSubscriptionBase(EventBase parentEvent, ThreadOption threadOption, ReferenceOption referenceOption)
		{
			Verify.ArgumentNotNull(parentEvent, "parentEvent", out _event);
			IsSubscribed = true;
			ThreadOption = threadOption;
		}
Example #15
0
 private string GetReferenceOptionName(ReferenceOption option) => option switch
 {