private static DataTable GetDatabases(IMyMetaTestContext criteria, IMyMetaPlugin plugin)
        {
            if (_databases == null)
            {
                _databases = plugin.Databases;
                if (criteria.DefaultDatabaseOnly)
                {
                    List<DataRow> rowsToDelete = new List<DataRow>();
                    string defaultDb = plugin.DefaultDatabase;
                    if (!string.IsNullOrEmpty(defaultDb))
                    {
                        defaultDb = defaultDb.Trim();
                        foreach (DataRow dbRow in _databases.Rows)
                        {
                            string dbname = dbRow["CATALOG_NAME"].ToString();
                            if (dbname != defaultDb) rowsToDelete.Add(dbRow);
                        }
                    }
                    if (rowsToDelete.Count != (_databases.Rows.Count - 1))
                    {
                        rowsToDelete.Clear();
                        for (int i = 1; i < _databases.Rows.Count; i++) rowsToDelete.Add(_databases.Rows[i]);
                    }

                    foreach (DataRow dbRow in rowsToDelete) _databases.Rows.Remove(dbRow);
                }
            }
            return _databases;
        }
Example #2
1
        public static string[] Split(string str, char[] separators, int maxComponents, StringSplitOptions options)
        {
            ContractUtils.RequiresNotNull(str, "str");
            #if SILVERLIGHT || WP75
            if (separators == null) return SplitOnWhiteSpace(str, maxComponents, options);

            bool keep_empty = (options & StringSplitOptions.RemoveEmptyEntries) != StringSplitOptions.RemoveEmptyEntries;

            List<string> result = new List<string>(maxComponents == Int32.MaxValue ? 1 : maxComponents + 1);

            int i = 0;
            int next;
            while (maxComponents > 1 && i < str.Length && (next = str.IndexOfAny(separators, i)) != -1) {

                if (next > i || keep_empty) {
                    result.Add(str.Substring(i, next - i));
                    maxComponents--;
                }

                i = next + 1;
            }

            if (i < str.Length || keep_empty) {
                result.Add(str.Substring(i));
            }

            return result.ToArray();
            #else
            return str.Split(separators, maxComponents, options);
            #endif
        }
        /// <summary>
        /// Does setup of AutoCAD IO. 
        /// This method will need to be invoked once before any other methods of this
        /// utility class can be invoked.
        /// </summary>
        /// <param name="autocadioclientid">AutoCAD IO Client ID - can be obtained from developer.autodesk.com</param>
        /// <param name="autocadioclientsecret">AutoCAD IO Client Secret - can be obtained from developer.autodesk.com</param>
        public static void SetupAutoCADIOContainer(String autocadioclientid, String autocadioclientsecret)
        {
            try
            {
                String clientId = autocadioclientid;
                String clientSecret = autocadioclientsecret;

                Uri uri = new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/");
                container = new AIO.Operations.Container(uri);
                container.Format.UseJson();

                using (var client = new HttpClient())
                {
                    var values = new List<KeyValuePair<string, string>>();
                    values.Add(new KeyValuePair<string, string>("client_id", clientId));
                    values.Add(new KeyValuePair<string, string>("client_secret", clientSecret));
                    values.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
                    var requestContent = new FormUrlEncodedContent(values);
                    var response = client.PostAsync("https://developer.api.autodesk.com/authentication/v1/authenticate", requestContent).Result;
                    var responseContent = response.Content.ReadAsStringAsync().Result;
                    var resValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseContent);
                    _accessToken = resValues["token_type"] + " " + resValues["access_token"];
                    if (!string.IsNullOrEmpty(_accessToken))
                    {
                        container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", _accessToken);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(String.Format("Error while connecting to https://developer.api.autodesk.com/autocad.io/v2/", ex.Message));
                container = null;
                throw;
            }
        }
        /// <summary>
        /// Füllt die Seite mit Inhalt auf, der bei der Navigation übergeben wird. Gespeicherte Zustände werden ebenfalls
        /// bereitgestellt, wenn eine Seite aus einer vorherigen Sitzung neu erstellt wird.
        /// </summary>
        /// <param name="navigationParameter">Der Parameterwert, der an
        /// <see cref="Frame.Navigate(Type, Object)"/> übergeben wurde, als diese Seite ursprünglich angefordert wurde.
        /// </param>
        /// <param name="pageState">Ein Wörterbuch des Zustands, der von dieser Seite während einer früheren Sitzung
        /// beibehalten wurde. Beim ersten Aufrufen einer Seite ist dieser Wert NULL.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Zulassen, dass das anfänglich anzuzeigende Element vom gespeicherten Seitenzustand überschrieben wird
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            ChampionsViewModel championsViewModel = (ChampionsViewModel)App.Current.Resources["championsViewModel"];
            if (championsViewModel != null)
            {
                if (!championsViewModel.Loaded) await championsViewModel.LoadDataAsync();
                this.DefaultViewModel["Items"] = championsViewModel.Champions.OrderBy(c => c.displayName).ToList();
                Champion champion = championsViewModel.Champions.First<Champion>(c => c.id == (int)navigationParameter);
                this.flipView.SelectedItem = champion;

                List<ChampionItemDetailPageView> views = new List<ChampionItemDetailPageView>();
                ChampionItemDetailPageView lore = new ChampionItemDetailPageView("Lore");
                ChampionItemDetailPageView overview = new ChampionItemDetailPageView("Overview");
                ChampionItemDetailPageView tips = new ChampionItemDetailPageView("Tips");

                views.Add(overview);
                views.Add(lore);
                views.Add(tips);

                this.DefaultViewModel["Views"] = views;
            }
        }
Example #5
0
        private void CreateModel()
        {
            int steps = (int)(1 / 0.05);
            double side = 100;

            // Generate the vertices
            Points = new List<Point3D>();
            for (int i = 0; i <= steps; i++)
            {
                double t = (double)i / steps;
                double x = side * Math.Cos(t * 2 * Math.PI);
                double y = side * Math.Sin(t * 2 * Math.PI);

                Points.Add(new Point3D(x, y, -side));
            }

            Points.Add(new Point3D(0, 0, -side));
            Points.Add(new Point3D(0, 0, side));

            // Generate the faces
            Faces = new List<int[]>();
            for (int i = 0; i < steps; i++)
            {
                int[] face = { i, i + 1, Points.Count-1};
                int[] sectorBottom = { i, i+1, Points.Count - 2};
                Faces.Add(face);
                Faces.Add(sectorBottom);
            }

            FacePoints = 3;
        }
Example #6
0
        /// <summary>
        ///  ��ѯʵ��
        /// </summary>
        /// <param name="id">ModelId ���</param>
        /// <returns>ModelCategory</returns>
        public IList<ModelCategory> CategoryAll(out string resultMsg, Int32 ParentCateg = 0,string IsNav = null)
        {
            resultMsg = string.Empty;
            IList<ModelCategory> list = new List<ModelCategory>();
            try
            {
                //�洢��������
                string sql = "usp_category_select_all";

                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "@ParentCateg", ParameterValue = ParentCateg, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });
                parm.Add(new DBParameter() { ParameterName = "@IsNav", ParameterValue = IsNav, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });

                //��ѯִ��
                using (IDataReader dr = DBHelper.ExecuteReader(sql, true, parm))
                {
                    list = GetModel(dr);
                }
            }
            catch (Exception ex)
            {
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return list;
        }
Example #7
0
 public override List<Type> getWeaknesses()
 {
     List<Type> weak = new List<Type>();
     weak.Add(new Electric());
     weak.Add(new Grass());
     return weak;
 }
Example #8
0
        static void Main(string[] args)
        {
            List<int> list = new List<int>
            {
                3,2,
            }; // 3, 2

            list.Add(5); // 3, 2, 5
            list.Add(6); // 3, 2, 5, 6
            list.Remove(5); // 3, 2, 6

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(3);// 3
            queue.Enqueue(8);// 3, 8
            queue.Dequeue(); // 8

            Stack<int> stack = new Stack<int>();
            stack.Push(2); // 2
            stack.Push(7); // 7, 2
            stack.Push(8); // 8, 7, 2
            stack.Pop();   // 7, 2

            foreach (var i in stack)
            {
                Console.WriteLine(i);
            }

            LinkedList<int> linkedList = new LinkedList<int>();
            linkedList.AddFirst(9); // 9
            linkedList.AddAfter(linkedList.Find(9), 5); // 9, 5
            linkedList.Remove(9); // 5

            Console.Read();
        }
        public IMediaType GetMediaType(string acceptHeader)
        {
            if (string.IsNullOrEmpty(acceptHeader)) return mediaTypes.Default;

            var types = acceptHeader.Split(',');
            var acceptedMediaType = new List<QualifiedMediaType>();

            foreach (var type in types)
            {
                var parsedFormat = ParseFormat(type);

                if (IsDefaultFormat(parsedFormat.Format))
                {
                    acceptedMediaType.Add(new QualifiedMediaType(mediaTypes.Default, parsedFormat.Qualifier));
                }
                else
                {
                    var mediaType = mediaTypes.Find(parsedFormat.Format);
                    if (mediaType != null) acceptedMediaType.Add(new QualifiedMediaType(mediaType, parsedFormat.Qualifier));
                }
            }

            if (acceptedMediaType.Count == 0) throw new AcceptHeaderNotSupportedException();
            return MostQualifiedMediaType(acceptedMediaType);
        }
        private byte[] GetLengthBytes()
        {
            var payloadLengthBytes = new List<byte>(9);

            if (PayloadLength > ushort.MaxValue)
            {
                payloadLengthBytes.Add(127);
                byte[] lengthBytes = BitConverter.GetBytes(PayloadLength);
                if (BitConverter.IsLittleEndian)
                    Array.Reverse(lengthBytes);
                payloadLengthBytes.AddRange(lengthBytes);
            }
            else if (PayloadLength > 125)
            {
                payloadLengthBytes.Add(126);
                byte[] lengthBytes = BitConverter.GetBytes((UInt16) PayloadLength);
                if (BitConverter.IsLittleEndian)
                    Array.Reverse(lengthBytes);
                payloadLengthBytes.AddRange(lengthBytes);
            }
            else
            {
                payloadLengthBytes.Add((byte) PayloadLength);
            }

            payloadLengthBytes[0] += (byte) (IsMasked ? 128 : 0);

            return payloadLengthBytes.ToArray();
        }
Example #11
0
 public BookCollection()
 {
     books = new List<Book>();
     books.Add(new Book { Id = 1, Name = "Война и мир", Author = "Л. Толстой", Price = 220 });
     books.Add(new Book { Id = 2, Name = "Отцы и дети", Author = "И. Тургенев", Price = 180 });
     books.Add(new Book { Id = 3, Name = "Чайка", Author = "А. Чехов", Price = 150 });
 }
Example #12
0
        public override List<SqlParameter> CreateInsertParameters(IModel obj, ref SqlParameter returnValue)
        {
            FinanceBusinessInvoice inv_financebusinessinvoice_ref = (FinanceBusinessInvoice)obj;

            List<SqlParameter> paras = new List<SqlParameter>();
            returnValue.Direction = ParameterDirection.Output;
            returnValue.SqlDbType = SqlDbType.Int;
            returnValue.ParameterName = "@RefId";
            returnValue.Size = 4;
            paras.Add(returnValue);

            SqlParameter businessinvoiceidpara = new SqlParameter("@BusinessInvoiceId", SqlDbType.Int, 4);
            businessinvoiceidpara.Value = inv_financebusinessinvoice_ref.BusinessInvoiceId;
            paras.Add(businessinvoiceidpara);

            SqlParameter financeinvoiceidpara = new SqlParameter("@FinanceInvoiceId", SqlDbType.Int, 4);
            financeinvoiceidpara.Value = inv_financebusinessinvoice_ref.FinanceInvoiceId;
            paras.Add(financeinvoiceidpara);

            SqlParameter balapara = new SqlParameter("@Bala", SqlDbType.Decimal, 9);
            balapara.Value = inv_financebusinessinvoice_ref.Bala;
            paras.Add(balapara);

            return paras;
        }
Example #13
0
 public override Template Visit(GlobalBlock block)
 {
     Template template = new Template("<list; separator=\"\n\">");
     List<Template> list = new List<Template>();
     bool last = false;
     AstNode last_node = null;
     foreach (var node in block.List)
     {
         bool current = node is FuncDef || node is Class || node is Enum || node is Import || node is GlobalUsing || node is Namespace;
         if ((last || current) && !(last_node is Import && node is Import))
         {
             Template tp = new Template("\n<node>");
             tp.Add("node", node.Accept(this));
             list.Add(tp);
         }
         else
         {
             list.Add(node.Accept(this));
         }
         last = current;
         last_node = node;
     }
     template.Add("list", list);
     return template;
 }
        public dynamic Process(NancyModule nancyModule, AuthenticateCallbackData model)
        {
            Response response = nancyModule.Response.AsRedirect("~/");

            if (nancyModule.IsAuthenticated())
            {
                response = nancyModule.Response.AsRedirect("~/account/#identityProviders");
            }

            if (model.Exception != null)
            {
                nancyModule.Request.AddAlertMessage("error", model.Exception.Message);
            }
            else
            {
                UserInformation information = model.AuthenticatedClient.UserInformation;
                var claims = new List<Claim>();
                claims.Add(new Claim(ClaimTypes.NameIdentifier, information.Id));
                claims.Add(new Claim(ClaimTypes.AuthenticationMethod, model.AuthenticatedClient.ProviderName));

                if (!String.IsNullOrEmpty(information.UserName))
                {
                    claims.Add(new Claim(ClaimTypes.Name, information.UserName));
                }

                if (!String.IsNullOrEmpty(information.Email))
                {
                    claims.Add(new Claim(ClaimTypes.Email, information.Email));
                }

                nancyModule.SignIn(claims);
            }

            return response;
        }
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            int count = 0;
            if (vessel != null) {
                foreach (Part p in vessel.Parts) {
                    if (p.partInfo.name.Equals (partName)) {
                        ++count;
                    }
                }
            }
            if(maxPartCount == -1) {
                if (vessel == null) {
                    values.Add (new Value ("Part", partCount + "x " + partName));
                } else {
                    values.Add (new Value ("Part", partCount + "x " + partName, "" + count, count >= partCount));
                }
            } else {
                if (vessel == null) {
                    values.Add (new Value ("max part", maxPartCount + "x " + partName));
                } else {
                    values.Add (new Value ("max part", maxPartCount + "x " + partName, "" + count, count <= maxPartCount));
                }
            }

            return values;
        }
		/// <summary>
		/// The to attributes.
		/// </summary>
		/// <param name="label">
		/// The label.
		/// </param>
		/// <param name="icon">
		/// The icon.
		/// </param>
		/// <param name="id">
		/// The id.
		/// </param>
		/// <param name="cssClass">
		/// The CSS class.
		/// </param>
		/// <returns>
		/// The <see cref="HtmlAttribute"/>.
		/// </returns>
		private static HtmlAttribute[] ToAttributes(string label, string icon, string id, string cssClass)
		{
			var attributes = new List<HtmlAttribute>();

			if (!string.IsNullOrEmpty(id))
			{
				attributes.Add(new HtmlAttribute(HtmlTextWriterAttribute.Id, id));
			}

			if (!string.IsNullOrEmpty(cssClass))
			{
				attributes.Add(new HtmlAttribute(HtmlTextWriterAttribute.Class, cssClass));
			}

			if (!string.IsNullOrEmpty(label))
			{
				attributes.Add(new HtmlAttribute("label", label));
			}

			if (!string.IsNullOrEmpty(icon))
			{
				attributes.Add(new HtmlAttribute("icon", icon));
			}

			return attributes.ToArray();
		}
Example #17
0
        //---------------------------------------------------------------------
        public List<EbVector3> navigate(EbVector3 from_world, EbVector3 to_world, uint max_step)
        {
            EbVector2 from_grid = _world2gird(from_world);
            EbVector2 to_grid = _world2gird(to_world);

            List<EbVector3> route_points = new List<EbVector3>();
            if (_isInGrid(from_grid) && _isInGrid(to_grid))
            {
                if (mPixelNav.search((int)from_grid.x, (int)from_grid.y, (int)to_grid.x, (int)to_grid.y, max_step))
                {
                    for (int i = 1; i < mPixelNav.Route.Count - 1; ++i)
                    {
                        route_points.Add(_grid2world(mPixelNav.Route[i]));
                    }
                    route_points.Add(to_world);
                }
                else
                {
                    for (int i = 1; i < mPixelNav.Route.Count; ++i)
                    {
                        route_points.Add(_grid2world(mPixelNav.Route[i]));
                    }
                }
            }

            return route_points;
        }
 public ICollection<Event> GetEvents(string name, int year)
 {
     List<Event> eventer = new List<Event>();
     var ev1 = new Event()
     {
         Id = 1,
         Date = new DateTime(2015, 4, 14),
         Name = "Folkeparken"
     };
     var ev2 = new Event()
     {
         Id = 1,
         Date = new DateTime(2015, 5, 11),
         Name = "Krokenmila"
     };
     var ev3 = new Event()
     {
         Id = 1,
         Date = new DateTime(2015, 6, 8),
         Name = "Folkeparken"
     };
     eventer.Add(ev1);
     eventer.Add(ev2);
     eventer.Add(ev3);
     return eventer;
 }
    void Test_diclist()
    {
        Dictionary <string, List<string>> myDic
            = new Dictionary<string, List<string>> ();
        string keystr;

        // command 1
        keystr = "hello";
        var res1ls = new List<string> ();
        res1ls.Add ("hello, Mike");
        res1ls.Add ("tadano shikabane no youda");
        res1ls.Add ("This number is not currently registered");
        myDic.Add (keystr, res1ls);

        // command 2
        keystr = "Ca va bien?";
        var res2ls = new List<string> ();
        res2ls.Add ("Merci, beaucoup");
        res2ls.Add ("honjitsu wa sentenn nari");
        res2ls.Add ("Je nous peut pas parler Francaise.");
        myDic.Add (keystr, res2ls);

        //		displayAllElementWithKey (ref myDic, /* searchKey=*/"hello");
        for (int loop=0; loop<10; loop++) {
            findElementWithKey (ref myDic, /* searchKey=*/"hello");
        }
    }
Example #20
0
        public Athlete()
        {
            BikeCadenceRanges = new List<ICadenceRange>(5);
            BikePowerEnergyRanges = new List<IEnergySystemRange>(6);
            BikeHeartRateEnergyRanges = new List<IEnergySystemRange>(6);
            // Can externally define these ranges later.
            BikeCadenceRanges.Add(new CadenceRange(0, 40, WorkoutCadenceFocus.None));
            BikeCadenceRanges.Add(new CadenceRange(40, 65, WorkoutCadenceFocus.Grinding));
            BikeCadenceRanges.Add(new CadenceRange(65, 80, WorkoutCadenceFocus.Climbing));
            BikeCadenceRanges.Add(new CadenceRange(80, 100, WorkoutCadenceFocus.Normal));
            BikeCadenceRanges.Add(new CadenceRange(100, 250, WorkoutCadenceFocus.Spinning));

            BikePowerEnergyRanges.Add(new EnergySystemRange(0, 55, WorkoutEnergySystemFocus.Zone1));
            BikePowerEnergyRanges.Add(new EnergySystemRange(55, 75, WorkoutEnergySystemFocus.Zone2));
            BikePowerEnergyRanges.Add(new EnergySystemRange(75, 90, WorkoutEnergySystemFocus.Zone3));
            BikePowerEnergyRanges.Add(new EnergySystemRange(90, 105, WorkoutEnergySystemFocus.Zone4));
            BikePowerEnergyRanges.Add(new EnergySystemRange(105, 120, WorkoutEnergySystemFocus.Zone5));
            BikePowerEnergyRanges.Add(new EnergySystemRange(120, 10000, WorkoutEnergySystemFocus.Zone6));

            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(0, 81, WorkoutEnergySystemFocus.Zone1));
            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(81, 89, WorkoutEnergySystemFocus.Zone2));
            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(90, 94, WorkoutEnergySystemFocus.Zone3));
            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(94, 103, WorkoutEnergySystemFocus.Zone4));
            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(103, 105, WorkoutEnergySystemFocus.Zone5));
            BikeHeartRateEnergyRanges.Add(new EnergySystemRange(105, 10000, WorkoutEnergySystemFocus.Zone6));

            // Run Pace
            //        Zone 1 Slower than 129% of FTP
            //Zone 2 114% to 129% of FTP
            //Zone 3 106% to 113% of FTP
            //Zone 4 99% to 105% of FTP
            //Zone 5a 97% to 100% of FTP
            //Zone 5b 90% to 96% of FTP
            //Zone 5c Faster than 90% of FTP
        }
                private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
                {
                    var path = new List<int>();
                    var root = _tree.GetRoot();

                    while (node != root)
                    {
                        for (; node.Parent != null; node = node.Parent)
                        {
                            var index = GetChildIndex(node);
                            path.Add(index);
                        }

                        // if we were part of structure trivia, continue searching until we get to the true root
                        if (node.IsStructuredTrivia)
                        {
                            var trivia = node.ParentTrivia;
                            var triviaIndex = GetTriviaIndex(trivia);
                            path.Add(triviaIndex);
                            var tokenIndex = GetChildIndex(trivia.Token);
                            path.Add(tokenIndex);
                            node = trivia.Token.Parent;
                            continue;
                        }
                        else if (node != root)
                        {
                            throw new InvalidOperationException(CSharpWorkspaceResources.Node_does_not_descend_from_root);
                        }
                    }

                    path.Reverse();
                    return path.ToImmutableArray();
                }
Example #22
0
	public static List<CallbackResult> Get(ClientInfo clientInfo)
	{
		lock (CallbackResultItems)
		{
			var result = new List<CallbackResult>();
			if (clientInfo.IsDisconnecting)
			{
				var callbackResult = new CallbackResult()
				{
					CallbackResultType = CallbackResultType.Disconnecting
				};
				result.Add(callbackResult);
				return result;
			}
			foreach (var callbackResultItem in CallbackResultItems)
			{
				if (callbackResultItem.Index > clientInfo.CallbackIndex)
				{
					if (!(callbackResultItem.CallbackResult.GKProgressCallback != null && callbackResultItem.CallbackResult.GKProgressCallback.IsCanceled))
						result.Add(callbackResultItem.CallbackResult);
				}
			}
			clientInfo.CallbackIndex = Index;
			return result;
		}
	}
        public static List<LimitData> BuildStaticUclLimit(ChartBase dataContext, bool calculatedCLs)
        {
            var list = new List<LimitData>();

            if (calculatedCLs)
            {
                var category = 1;
                for (var i = 0; i < dataContext.DataSource.Count; i++)
                {
                    list.Add(new LimitData(category, dataContext.UCL));
                    category++;
                }                
            }
            else
            {
                var category = 1;
                for (var i = 0; i < dataContext.DataSource.Count; i++)
                {
                    list.Add(new LimitData(category, dataContext.ParentPanel.CustomUCL));
                    category++;
                }
            }

            return list;
        }
Example #24
0
    static List<int> MakeMegre(List<int> left, List<int> right)
    {
        List<int> result = new List<int>();

        while (left.Count > 0 || right.Count > 0)
        {
            if (left.Count > 0 && right.Count > 0)
            {
                if (left[0] <= right[0])
                {
                    result.Add(left[0]);
                    left.RemoveAt(0);
                }
                else
                {
                    result.Add(right[0]);
                    right.RemoveAt(0);
                }
            }
            else if (left.Count > 0)
            {
                result.Add(left[0]);
                left.RemoveAt(0);
            }
            else if (right.Count > 0)
            {
                result.Add(right[0]);
                right.RemoveAt(0);
            }

            return result;
        }
    }
 public DiscountingBasisSwapEngine(Handle<YieldTermStructure> discountCurve1 , 
                              Handle<YieldTermStructure> discountCurve2) 
 {
    discountCurve_ = new List<Handle<YieldTermStructure>>();
    discountCurve_.Add(discountCurve1);
    discountCurve_.Add(discountCurve2);
 }
        private string[] SanitizeArgs(string[] args)
        {
            var commands = new List<string>();
            var enumerator = args.GetEnumerator();
            StringBuilder builder = null;
            while (enumerator.MoveNext())
            {
                var arg = enumerator.Current as string;
                if (arg.StartsWith(_token))
                {
                    if (builder != null) commands.Add(builder.ToString());
                    builder = new StringBuilder();
                    builder.Append(arg);
                }
                else
                {
                    builder.Append($" {arg}");
                }
            }


            commands.Add(builder.ToString());

            return commands.ToArray();
        }
Example #27
0
        public static string[] GetInfo(string filename)
        {
            List<string> fileinfo = new List<string>();

            TagLib.File tagFile = TagLib.File.Create(filename);
            string artiest = tagFile.Tag.FirstPerformer;
            string titel = tagFile.Tag.Title;

            if (artiest == null || artiest == "")
            {
                // Controleer of de artiest staat aangegeven bij de titel
                if (titel == null || titel == "")
                {
                    titel = System.IO.Path.GetFileNameWithoutExtension(filename);
                }

                if (titel != null && titel != "")
                {
                    // Controleer of de titel gesplits kan worden
                    string[] title = titel.Split(new char[] {'-'});
                    if (title.Length > 1)
                    {
                        artiest = title[0].Trim();
                        titel = title[1].Trim();
                    }
                }
            }

            fileinfo.Add(artiest);
            fileinfo.Add(titel);
            fileinfo.Add(tagFile.Properties.Duration.TotalSeconds.ToString());

            return fileinfo.ToArray();
        }
Example #28
0
        public static List<OptionSetItem> GetOptionSetValues(string entityLogicalName, string attributeLogicalName, bool? allowEmpty)
        {
            if (allowEmpty == null) allowEmpty = false;
            string cacheKey = entityLogicalName + "." + attributeLogicalName + "." + allowEmpty.ToString();

            if (_optionsCache.ContainsKey(cacheKey))
                return _optionsCache[cacheKey];
            else
            {
                AttributeMetadata attribute = LoadAttributeMetadata(entityLogicalName, attributeLogicalName);
                PicklistAttributeMetadata pickList = (PicklistAttributeMetadata)attribute;
                List<OptionSetItem> opts = new List<OptionSetItem>();
                if (allowEmpty.Value)
                    opts.Add(new OptionSetItem());

                foreach (OptionMetadata o in pickList.OptionSet.Options)
                {
                    OptionSetItem a = new OptionSetItem();
                    a.Name = o.Label.UserLocalizedLabel.Label;
                    a.Value = o.Value.Value;
                    opts.Add(a);
                }

                return opts;
            }
        }
Example #29
0
        /// <summary>
        /// Returns a list of visual branches which are around the given commit.
        /// </summary>
        /// <param name="commit"></param>
        /// <param name="repo"></param>
        /// <returns></returns>
        public static List<Branch> GetBranchesAroundCommit(Commit commit, ObservableCollection<Branch> branches)
        {
            List<Branch> list = new List<Branch>();

            // Loop through all branches and determine if they are around the specified commit.
            foreach (Branch branch in branches)
            {
                // Tip has to be found and in case multiple branches share the tree, get rid of the others -- messes up visual position counting.
                if (branch.Tip == null || list.Any(b => branch.Tip.Branches.Contains(b)) || list.Any(b => b.Tip.Branches.Contains(branch)))
                    continue;

                // The branch's tip must be newer/same than the commit.
                if (branch.Tip.Date >= commit.Date) // TODO: && first commit-ever must be older? We might not need to do that... ... ?
                {
                    list.Add(branch);
                }
                else
                {
                    // If there's a branch with a tip commit older than commit.Date, then it's around this commit if they don't share a single branch.
                    bool foundThisBranch = branch.Tip.Branches.Any(b => commit.Branches.Contains(b));

                    if (foundThisBranch == false)
                        list.Add(branch);
                }
            }

            return list;
        }
Example #30
0
        public override IList<ErrorInfo> Validate()
        {
            var errorList = new List<ErrorInfo>();

            if(Date == DateTime.MaxValue || Date == DateTime.MinValue)
                errorList.Add(new ErrorInfo("Date","EmployeeCost_InvalidDate"));

            if (Details == null || Details.Count == 0)
            {
                errorList.Add(new ErrorInfo("Details", "EmployeeCost_RequireDetails"));
            }
            else
            {
                if (Details.GroupBy(d => d.EmployeeId).Any(g => g.Count() > 1))
                    errorList.Add(new ErrorInfo("Details", "EmployeeCost_DuplicateEmployee"));

                for (var i = 0; i < Details.Count; i++)
                {
                    var detailErrors = Details[i].Validate();
                    if (detailErrors != null && detailErrors.Count > 0)
                    {
                        errorList.AddRange(detailErrors.Select(detailError => new ErrorInfo("Details[" + i + "]." + detailError.PropertyName, detailError.Message)));
                    }
                }
            }

            return errorList;
        }