예제 #1
0
 private static void AssertContainsObject <T>(Opt <T> opt, T value) where T : class
 {
     Assert.True(opt.HasValue);
     Assert.Same(value, opt.Value);
     Assert.True(opt.TryGetValue(out T retrievedValue));
     Assert.Same(value, retrievedValue);
     Assert.Equal(new T[] { value }, opt);
 }
예제 #2
0
        public CraftFactory(string fileName)
        {
            FileName = fileName;

            Opt.Read(fileName);

            CraftFactoryImpl();
        }
예제 #3
0
 /// <summary>
 /// Filters the elements of an option to those of a specified type.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method is implemented using deferred execution; the query represented by this method
 /// is not performed until the contents of the returned option are resolved, such as by enumeration.
 /// </para>
 /// </remarks>
 /// <typeparam name="TResult">
 /// The type to which to filter the elements of <paramref name="source"/>.
 /// </typeparam>
 /// <param name="source">A source option.</param>
 /// <returns>
 /// An option having the same contents as <paramref name="source"/>, if it contains an
 /// element that is of type <typeparamref name="TResult"/> (according to the <see
 /// langword="is"/> operator); otherwise, an empty option.
 /// </returns>
 /// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
 public static IOpt <TResult> OfType <TResult>(this IOpt source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(Opt.DeferRaw(() => OfType <object, TResult>(source.ToFixed())));
 }
예제 #4
0
 internal SortedChunkedMap(Func <KeyComparer <TKey>, IMutableSeries <TKey, SortedMap <TKey, TValue> > > outerFactory,
                           Func <int, KeyComparer <TKey>, SortedMap <TKey, TValue> > innerFactory,
                           KeyComparer <TKey> comparer,
                           Opt <int> chunkMaxSize) : base(outerFactory, innerFactory, comparer, chunkMaxSize)
 {
     _chunkUpperLimit = chunkMaxSize.IsPresent && chunkMaxSize.Present > 0 ? chunkMaxSize.Present : Settings.SCMDefaultChunkLength;
     var lastKvp = LastUnchecked;
 }
예제 #5
0
 /// <summary>
 /// Returns the remaining contents of an option after skipping a specified number of elements.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method is implemented using deferred execution; the query represented by this method
 /// is not performed until the contents of the returned option are resolved, such as by enumeration.
 /// </para>
 /// <para>
 /// If <paramref name="count"/> is zero or negative, no elements are skipped. If <paramref
 /// name="count"/> is greater than or equal to the number of elements of <paramref name="source"/>, all
 /// elements are skipped.
 /// </para>
 /// </remarks>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <param name="source">A source option.</param>
 /// <param name="count">The number of elements to skip.</param>
 /// <returns>
 /// <paramref name="source"/>, if <paramref name="count"/> is less than or equal to 0;
 /// otherwise, an empty option.
 /// </returns>
 /// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
 public static IOpt <TSource> Skip <TSource>(this IOpt <TSource> source, int count)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return((count <= 0) ? source : Opt.Empty <TSource>());
 }
예제 #6
0
        public override void ReceiveResponse(Result <ReceiveMessageResponse> msg, UtcDateTime timestamp, object evaluationCtx, bool isPredefined = false)
        {
            base.ReceiveResponse(msg, timestamp, evaluationCtx, isPredefined);

            var lead = (Lead)evaluationCtx; // TODO: try to make the ReceiveResponse()::evaluationCtx parameter strongly typed, instead of object, so we do not need to cast here

            _leadIdNo = lead.IdNumber;
        }
 /// <summary>
 /// If the specified value is of the type <c>decimal</c>, gets the value.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static Opt <decimal> DecimalValueOpt(this IConvertible value)
 {
     if (value is decimal)
     {
         return(Opt.Full((decimal)value));
     }
     return(Opt.Empty <decimal>());
 }
예제 #8
0
 /// <summary>
 /// Converts this option to another option based on its contents.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method is implemented using deferred execution; the query represented by this method
 /// is not performed until the contents of the returned option are resolved, such as by enumeration.
 /// </para>
 /// <para>Compare <see cref="Match"/>, which uses immediate execution.</para>
 /// </remarks>
 /// <typeparam name="TSource">The element type of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TResult">The element type for the result of this conversion.</typeparam>
 /// <param name="source">A source option.</param>
 /// <param name="ifEmpty">A function to produce the result if this option is empty.</param>
 /// <param name="ifFull">
 /// A function to produce the result if this option is full, which accepts the contained
 /// element as a parameter.
 /// </param>
 /// <returns>
 /// An option equivalent to the result of calling <paramref name="ifEmpty"/>, if this option
 /// is empty; otherwise, an option equivalent to the result of calling <paramref name="ifFull"/>.
 /// </returns>
 /// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
 /// <exception cref="InvalidOperationException">
 /// <paramref name="ifEmpty"/> is <see langword="null"/> and this option is empty, or
 /// <paramref name="ifFull"/> is <see langword="null"/> and this option is full.
 /// </exception>
 public static IOpt <TResult> MatchOpt <TSource, TResult>(this IOpt <TSource> source, Func <Opt <TResult> > ifEmpty = null, Func <TSource, Opt <TResult> > ifFull = null)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(Opt.DeferRaw(() => source.Match(ifEmpty, ifFull)));
 }
예제 #9
0
        public static void AssertDefaultTrains(this Opt testSubject, TrainType trainType, TrainAlgo trainAlgo)
        {
            AssertDefaults(testSubject);
            testSubject.Mode.Should().Be((int)OptMode.Train);

            testSubject.Type.Should().Be(trainType.GetDescription());
            testSubject.Algo.Should().Be(trainAlgo.GetDescription());
        }
예제 #10
0
 /// <summary>
 /// Returns an option that contains the first element of a sequence.
 /// </summary>
 /// <remarks>
 /// <para>This method is an option-returning counterpart to <see cref="Enumerable.FirstOrDefault{TSource}(IEnumerable{TSource})"/>.</para>
 /// <para>
 /// This method is implemented using deferred execution; the query represented by this method
 /// is not performed until the contents of the returned option are resolved, such as by enumeration.
 /// </para>
 /// </remarks>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <param name="source">A source sequence.</param>
 /// <returns>
 /// An option containing the first element of <paramref name="source"/>, or an empty option
 /// if <paramref name="source"/> is empty.
 /// </returns>
 /// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
 public static IOpt <TSource> WhereFirst <TSource>(this IEnumerable <TSource> source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(Opt.DeferRaw(() => source.WhereFirstImmediate()));
 }
예제 #11
0
 private static void AssertContainsValue <T>(Opt <T> opt, T value) where T : struct
 {
     Assert.True(opt.HasValue);
     Assert.Equal(value, opt.Value);
     Assert.True(opt.TryGetValue(out T retrievedValue));
     Assert.Equal(value, retrievedValue);
     Assert.Equal(new T[] { value }, opt);
 }
예제 #12
0
        private static object _DoOperation(Func <Expression, Expression, BinaryExpression> exp, List <Opt> cache, object a, object b)
        {
            if (a != null && b != null)
            {
                Type type  = a.GetType();
                Type type2 = b.GetType();
                try
                {
                    if (type != typeof(string) && type2 != typeof(string))
                    {
                        Opt opt = BloxMathsUtil.FindOpt(cache, type, type2);
                        if (opt == null)
                        {
                            ParameterExpression parameterExpression  = Expression.Parameter(type, "a");
                            ParameterExpression parameterExpression2 = Expression.Parameter(type2, "b");
                            Delegate            @delegate            = null;
                            try
                            {
                                @delegate = Expression.Lambda(exp(parameterExpression, parameterExpression2), parameterExpression, parameterExpression2).Compile();
                            }
                            catch (InvalidOperationException)
                            {
                                if (type != type2)
                                {
                                    Expression arg  = parameterExpression;
                                    Expression arg2 = Expression.Convert(parameterExpression2, type);
                                    @delegate = Expression.Lambda(exp(arg, arg2), parameterExpression, parameterExpression2).Compile();
                                    goto end_IL_00a4;
                                }
                                throw;
                                end_IL_00a4 :;
                            }
                            opt = new Opt
                            {
                                ta   = type,
                                tb   = type2,
                                comm = @delegate
                            };
                            cache.Add(opt);
                        }
                        if (opt != null)
                        {
                            return(opt.comm.DynamicInvoke(a, b));
                        }
                        goto end_IL_001f;
                    }
                    return(a.ToString() + b.ToString());

                    end_IL_001f :;
                }
                catch
                {
                    throw new Exception(string.Format("The operation can't be completed with [{0}] and [{1}].", type, type2));
                }
                return(null);
            }
            throw new Exception("The operation can't be completed since one or both values are null.");
        }
예제 #13
0
 private static Opt <TSource> FlattenFixedOpt <TSource>(Opt <Opt <TSource> > fixedOpt1)
 {
     if (fixedOpt1.HasValue)
     {
         var fixedOpt0 = fixedOpt1.ValueOrDefault;
         return(fixedOpt0);
     }
     return(Opt.Empty <TSource>());
 }
예제 #14
0
        public void RT_Opt_RefType_False()
        {
            var opt = new Opt <string>();

            opt.HasValue.Should().BeFalse();
            var hasValue = opt ? true : false;

            hasValue.Should().BeFalse();
        }
예제 #15
0
        /// <summary>
        /// Pattern matching do resultado, possibilita obter o valor.
        /// </summary>
        /// <typeparam name="TResult">Tipo do valor atual</typeparam>
        /// <typeparam name="TNew">Tipo do valor de retorno</typeparam>
        /// <param name="source">Task atual</param>
        /// <param name="some">Função a ser executada se houver valor</param>
        /// <param name="none">Função a ser executada se não houver valor</param>
        /// <returns>Task[TNew]</returns>
        public static async Task <TNew> Match <TResult, TNew>(
            this Task <TResult> source,
            Func <TResult, TNew> some,
            Func <None, TNew> none)
        {
            Opt <TResult> opt = await source;

            return(opt.Match(some, none));
        }
예제 #16
0
파일: OptTests.cs 프로젝트: bragil/funsharp
        public void Deve_Retornar_Valor_Via_GetValueOrElse()
        {
            TesteClass teste = new TesteClass()
            {
                Id = 20
            };
            Opt <TesteClass> opt = teste;

            var retorno = opt.GetValueOrElse(default);
예제 #17
0
        public void RT_Opt_ValueType_False()
        {
            var opt = new Opt <int>();

            opt.HasValue.Should().BeFalse();
            var hasValue = opt ? true : false;

            hasValue.Should().BeFalse();
        }
예제 #18
0
 internal CountedOpt(int sourceCount, T value = default(T))
 {
     if (sourceCount < 0)
     {
         throw new ArgumentOutOfRangeException("sourceCount");
     }
     this.sourceCount = sourceCount;
     this.valueOpt    = Opt.Create(sourceCount == 1, value);
 }
예제 #19
0
 public MappingProfile()
 {
     Mapper.CreateMap <Customer, CustomerDto>();
     Mapper.CreateMap <CustomerDto, Customer>().ForMember(m => m.Id, Opt => Opt.Ignore());
     Mapper.CreateMap <Movie, MovieDto>();
     Mapper.CreateMap <MovieDto, Movie>().ForMember(m => m.Id, Opt => Opt.Ignore());
     Mapper.CreateMap <MembershipType, MembershipTypeDto>();
     Mapper.CreateMap <Genre, GenreDto>();
 }
예제 #20
0
        public void RT_Opt_NullableValueType_Value()
        {
            int?i   = 42;
            var opt = new Opt <int?>(i);
            var val = from j in opt select j;

            // no way to unwrap a Nullable<T> :-(
            val.HasValue.Should().BeTrue();
        }
예제 #21
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            string conStr = configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <TIMGDbContext>(Opt => Opt.UseSqlServer(conStr));
            services.AddTransient <ITIMGDb, TIMGDB>();
            services.AddCors();
            services.AddMvc();
        }
예제 #22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFrameworkNpgsql().AddDbContext <HeroApiContext>(Opt
                                                                              => Opt.UseNpgsql(Configuration.GetConnectionString("HeroApiConnection")));

            services.AddTransient <IHeroesService, HeroService>();

            services.AddCors();
            services.AddMvc();
        }
예제 #23
0
파일: TryToOpt.cs 프로젝트: psmay/Hgk.Zero
        /// <summary>
        /// Calls the specified try function with the specified parameters and returns an option containing the result.
        /// </summary>
        /// <typeparam name="T1">The type of <paramref name="arg1"/>.</typeparam>
        /// <typeparam name="T2">The type of <paramref name="arg2"/>.</typeparam>
        /// <typeparam name="T3">The type of <paramref name="arg3"/>.</typeparam>
        /// <typeparam name="T4">The type of <paramref name="arg4"/>.</typeparam>
        /// <typeparam name="T5">The type of <paramref name="arg5"/>.</typeparam>
        /// <typeparam name="T6">The type of <paramref name="arg6"/>.</typeparam>
        /// <typeparam name="T7">The type of <paramref name="arg7"/>.</typeparam>
        /// <param name="tryFunction">The try function to call.</param>
        /// <param name="arg1">The first parameter to be passed to the try function.</param>
        /// <param name="arg2">The second parameter to be passed to the try function.</param>
        /// <param name="arg3">The third parameter to be passed to the try function.</param>
        /// <param name="arg4">The fourth parameter to be passed to the try function.</param>
        /// <param name="arg5">The fifth parameter to be passed to the try function.</param>
        /// <param name="arg6">The sixth parameter to be passed to the try function.</param>
        /// <param name="arg7">The seventh parameter to be passed to the try function.</param>
        /// <returns>
        /// An option containing the result parameter produced by calling <paramref name="tryFunction"/>,
        /// if the operation completed successfully; otherwise, an empty option.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="tryFunction"/> is <see langword="null"/>.
        /// </exception>
        public static Opt <TResult> Call <T1, T2, T3, T4, T5, T6, T7>(TryFunction <T1, T2, T3, T4, T5, T6, T7, TResult> tryFunction, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            if (tryFunction == null)
            {
                throw new ArgumentNullException(nameof(tryFunction));
            }
            bool hasValue = tryFunction(arg1, arg2, arg3, arg4, arg5, arg6, arg7, out TResult result);

            return(Opt.Create(hasValue, result));
        }
예제 #24
0
파일: TryToOpt.cs 프로젝트: psmay/Hgk.Zero
        /// <summary>
        /// Calls the specified try function with the specified parameters and returns an option containing the result.
        /// </summary>
        /// <typeparam name="T1">The type of <paramref name="arg1"/>.</typeparam>
        /// <typeparam name="T2">The type of <paramref name="arg2"/>.</typeparam>
        /// <typeparam name="T3">The type of <paramref name="arg3"/>.</typeparam>
        /// <typeparam name="T4">The type of <paramref name="arg4"/>.</typeparam>
        /// <typeparam name="T5">The type of <paramref name="arg5"/>.</typeparam>
        /// <typeparam name="T6">The type of <paramref name="arg6"/>.</typeparam>
        /// <typeparam name="T7">The type of <paramref name="arg7"/>.</typeparam>
        /// <typeparam name="T8">The type of <paramref name="arg8"/>.</typeparam>
        /// <typeparam name="T9">The type of <paramref name="arg9"/>.</typeparam>
        /// <typeparam name="T10">The type of <paramref name="arg10"/>.</typeparam>
        /// <typeparam name="T11">The type of <paramref name="arg11"/>.</typeparam>
        /// <typeparam name="T12">The type of <paramref name="arg12"/>.</typeparam>
        /// <typeparam name="T13">The type of <paramref name="arg13"/>.</typeparam>
        /// <typeparam name="T14">The type of <paramref name="arg14"/>.</typeparam>
        /// <typeparam name="T15">The type of <paramref name="arg15"/>.</typeparam>
        /// <typeparam name="T16">The type of <paramref name="arg16"/>.</typeparam>
        /// <param name="tryFunction">The try function to call.</param>
        /// <param name="arg1">The first parameter to be passed to the try function.</param>
        /// <param name="arg2">The second parameter to be passed to the try function.</param>
        /// <param name="arg3">The third parameter to be passed to the try function.</param>
        /// <param name="arg4">The fourth parameter to be passed to the try function.</param>
        /// <param name="arg5">The fifth parameter to be passed to the try function.</param>
        /// <param name="arg6">The sixth parameter to be passed to the try function.</param>
        /// <param name="arg7">The seventh parameter to be passed to the try function.</param>
        /// <param name="arg8">The eighth parameter to be passed to the try function.</param>
        /// <param name="arg9">The ninth parameter to be passed to the try function.</param>
        /// <param name="arg10">The tenth parameter to be passed to the try function.</param>
        /// <param name="arg11">The eleventh parameter to be passed to the try function.</param>
        /// <param name="arg12">The twelfth parameter to be passed to the try function.</param>
        /// <param name="arg13">The thirteenth parameter to be passed to the try function.</param>
        /// <param name="arg14">The fourteenth parameter to be passed to the try function.</param>
        /// <param name="arg15">The fifteenth parameter to be passed to the try function.</param>
        /// <param name="arg16">The sixteenth parameter to be passed to the try function.</param>
        /// <returns>
        /// An option containing the result parameter produced by calling <paramref name="tryFunction"/>,
        /// if the operation completed successfully; otherwise, an empty option.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="tryFunction"/> is <see langword="null"/>.
        /// </exception>
        public static Opt <TResult> Call <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(TryFunction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> tryFunction, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            if (tryFunction == null)
            {
                throw new ArgumentNullException(nameof(tryFunction));
            }
            bool hasValue = tryFunction(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, out TResult result);

            return(Opt.Create(hasValue, result));
        }
예제 #25
0
파일: TryToOpt.cs 프로젝트: psmay/Hgk.Zero
        /// <summary>
        /// Calls the specified try function with the specified parameter and returns an option containing the result.
        /// </summary>
        /// <typeparam name="T1">The type of <paramref name="arg1"/>.</typeparam>
        /// <param name="tryFunction">The try function to call.</param>
        /// <param name="arg1">The first parameter to be passed to the try function.</param>
        /// <returns>
        /// An option containing the result parameter produced by calling <paramref name="tryFunction"/>,
        /// if the operation completed successfully; otherwise, an empty option.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="tryFunction"/> is <see langword="null"/>.
        /// </exception>
        public static Opt <TResult> Call <T1>(TryFunction <T1, TResult> tryFunction, T1 arg1)
        {
            if (tryFunction == null)
            {
                throw new ArgumentNullException(nameof(tryFunction));
            }
            bool hasValue = tryFunction(arg1, out TResult result);

            return(Opt.Create(hasValue, result));
        }
예제 #26
0
파일: Eq.cs 프로젝트: nilnul/_nilnul_._LIB_
        public int GetHashCode(Opt <T> obj)
        {
            if (obj.val is nilnul._opt.One <T> )
            {
                return(_oneEq.GetHashCode(obj as nilnul._opt.One <T>));
            }

            return(0);
            //throw new NotImplementedException();
        }
예제 #27
0
파일: OptTests.cs 프로젝트: paiden/BeeSharp
        public void Transpose_ShouldReturnCorrectResults(Opt <Res <int> > x, Res <Opt <int> > expected)
        {
            // Arrange

            // Act
            var r = x.Transpose();

            // Assert
            r.Should().Be(expected);
        }
예제 #28
0
        public ActionResult <string> Config()
        {
            var opt = new Opt {
                x = PropertyAccessMode.Field, y = 6
            };

            config.GetSection("test").Bind(opt);

            return(opt.ToString());
        }
예제 #29
0
파일: OptTests.cs 프로젝트: paiden/BeeSharp
        public void Map_GivenNone_ShouldReturnNone()
        {
            // Arrange
            var o = None();

            // Act
            var r = o.Map(i => $"{i}{OpValue}");

            // Assert
            r.Should().Be(Opt.None <string>());
        }
예제 #30
0
파일: OptTests.cs 프로젝트: paiden/BeeSharp
        public void MapOpt_GivenSome_ShouldReturnSomeMapped()
        {
            // Arrange
            var o = Some();

            // Act
            var r = o.Map(i => Opt.Some($"{i}{OpValue}"));

            // Assert
            r.Unwrap().Should().Be($"{DefSome}{OpValue}");
        }
예제 #31
0
	public bool PlayWorld(char N1, char N2, Map Map1, Opt Opt1, Opt Opt1b, 
						  Map Map2, Opt Opt2, Opt Opt2b, byte Player)
	{
		int i, j, k, x, y;
		
		void MoveScreen()
		{
			int Scroll;
			int N1, N2;
			int i, j, OldX, NewX, Page;
			Random random = new Random();
			int randomNumber;
			Page = CurrentPage;
			Scroll = XView - LastXView[Page];
			if (!EarthQuake)
				SetView(XView, YView);
			else
			{
				EarthQuakeCounter++;
				if (EarthQuakeCounter > 0)
					EarthQuake = false;
				int Rand1 = randomNumber.Next(0, 2);
				int Rand2 = randomNumber.Next(0, 2);
				SetView (XView, YView + Rand1 - Rand2;				
			}
			if (Scroll < 0)
				StartEnemies ((XView / W) - StartEnemiesAt, 1);
			else if (Scroll > 0)
				StartEnemies((XView / W) + NH + StartEnemiesAt(), -1);
			
			// Need to find out what else is in "Options"
			i = Options.Horizon;
			Options.Horizon = i + GetYOffset() - YBASE;
			DrawBackGr(false);
			Options.Horizon = i;
			
			if (Scroll > 0)
				for (int j = LastXView[Page]; j < XView; j++)
				{
					i = j - W - W;
					if (i >= 0)
						PutPixel(i, 0, 0);
					i = W - j % W - 1;
					Redraw (j / W + NH + 1, i);
				}
				
				if (Scroll < 0)
					for (int j = LastXView[Page]; j > XView; j--);
					{
						i = W - j % W - 1;
						Redraw(j / W - 1, i);
					}
		}
        public EmailSubscriptionsOperationStatus SynchroniseSubscriptions(EmailSubscriptions subscriptions)
        {
            var operationStatus = new EmailSubscriptionsOperationStatus();
            try
            {
                MCApi api = new MCApi(_apiKey, false);
                var subscribeOptions =
                    new Opt<List.SubscribeOptions>(
                        new List.SubscribeOptions
                        {
                            SendWelcome = true,
                            UpdateExisting = true,
                            DoubleOptIn = (subscriptions.Subscriptions.Count() != 0),
                            //retain double optin for new subscribers
                            ReplaceInterests = true
                        });

                var groupings = new List<List.Grouping>()
                {
                    new List.Grouping("Signed Up As", subscriptions.Subscriptions.ToArray()),
                };

                var merges =
                    new Opt<List.Merges>(
                        new List.Merges
                        {
                            {"FNAME", subscriptions.ForeName},
                            {"LNAME", subscriptions.LastName},
                            {"GROUPINGS", groupings}
                        });

                operationStatus.Status = api.ListSubscribe(_listId, subscriptions.Email, merges, subscribeOptions);
                operationStatus.SubscriptionStatus = true;
            }
            catch (Exception e)
            {
                operationStatus = OperationStatusExceptionHelper<EmailSubscriptionsOperationStatus>
                    .CreateFromException("An error has occurred while syncing the email subscriptions", e);
                operationStatus.SubscriptionStatus = false;

            }
            return operationStatus;
        }