public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service = new TaxaService(User);

            progress.ProgressStart(String.Format("Preparing Darwin Core records for {0} specimens...", _idSet.Count));

            DataMatrix result = null;
            var idSet = new LinkedList<int>(_idSet);
            int chunkSize = 2000;
            var helper = new DarwinCoreReportHelper();
            var chunk = new List<int>();
            var count = 0;
            while (idSet.Count > 0) {
                chunk.Add(idSet.First.Value);
                idSet.RemoveFirst();
                count++;
                if (chunk.Count >= chunkSize || idSet.Count == 0) {

                    var percentComplete = ((double) count / (double) _idSet.Count) * 100;

                    progress.ProgressMessage(String.Format("Preparing Darwin Core records {0} of {1}", count, _idSet.Count), percentComplete);
                    var where = "tblMaterial.intMaterialID in (" + chunk.Join(",") + ")";
                    var dataChunk = helper.RunDwcQuery(service, where);
                    if (result == null) {
                        result = dataChunk;
                    } else {
                        result.AppendMatrix(dataChunk);
                    }
                    chunk = new List<int>();
                }
            }
            progress.ProgressEnd(String.Format("{0} Darwin Core records retrieved.", count));

            return result;
        }
        public static void JoinEx1()
        {
            Person magnus = new Person { Name = "Hedlund, Magnus" };
            Person terry = new Person { Name = "Adams, Terry" };
            Person charlotte = new Person { Name = "Weiss, Charlotte" };

            Pet barley = new Pet { Name = "Barley", Owner = terry };
            Pet boots = new Pet { Name = "Boots", Owner = terry };
            Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
            Pet daisy = new Pet { Name = "Daisy", Owner = magnus };

            List<Person> people = new List<Person> { magnus, terry, charlotte };
            List<Pet> pets = new List<Pet> { barley, boots, whiskers, daisy };

            // Create a list of Person-Pet pairs where
            // each element is an anonymous type that contains a
            // Pet's name and the name of the Person that owns the Pet.
            var query =
                people.Join(pets,
                            person => person,
                            pet => pet.Owner,
                            (person1, pet1) =>
                                new { OwnerName = person1.Name, Pet = pet1.Name });

            foreach (var obj in query)
            {
                Console.WriteLine(
                    "{0} - {1}",
                    obj.OwnerName,
                    obj.Pet);
            }
        }
Example #3
0
 private void Frm_Main_Load(object sender, EventArgs e)
 {
     List<SaleBill> bills = new List<SaleBill>//创建销售单列表
 {
     new SaleBill("XS001","王*科",Convert.ToDateTime("2010-1-1")),
     new SaleBill("XS002","王*军",Convert.ToDateTime("2010-2-1")),
     new SaleBill("XS003","赵*东",Convert.ToDateTime("2010-3-1"))
 };
     List<SaleProduct> products = new List<SaleProduct>//创建销售商品列表
 {
     new SaleProduct("XS001","冰箱",1,2000),
     new SaleProduct("XS001","洗衣机",2,600),
     new SaleProduct("XS002","电暖风",3,50),
     new SaleProduct("XS002","吸尘器",4,200),
     new SaleProduct("XS003","手机",1,990)
 };
     //关联销售单列表和销售商品列表        
     var query= bills.Join(products,
                        b => b.SaleBillCode,
                        p => p.SaleBillCode,
                        (b, p) => new
                        {
                            销售单号 = b.SaleBillCode,
                            销售日期 = b.SaleDate,
                            销售员 = b.SaleMan,
                            商品名称 = p.ProductName,
                            数量 = p.Quantity,
                            单价 = p.Price,
                            金额 = p.Quantity * p.Price
                        });
     dataGridView1.DataSource = query.ToList();//数据绑定
 }
Example #4
0
 public static void ErrorCallNotFound(this Log log, Location location, Type funcType, List<Type> argTypes)
 {
     if (funcType is ErrorType || argTypes.Exists(x => x is ErrorType)) {
         return;
     }
     log.Error(location, "cannot call " + WrapType(funcType) + " with arguments \"(" + argTypes.Join() + ")\"");
 }
Example #5
0
 protected void grid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     if (combo.SelectedIndex == -1)
     {
         grid.DataSource = new List<HousingLog>();
     }
     else
     {
         var gid = Guid.Parse(combo.SelectedValue);
         var id = Guid.Parse(combo.SelectedValue).ToString().ToUpper();
         var list = new List<HousingLog>();
         var st = from.SelectedDate.HasValue ? from.SelectedDate.Value : DateTime.MinValue;
         var et = to.SelectedDate.HasValue ? to.SelectedDate.Value : DateTime.Today;
         if (st > et)
         {
             var tt = st;
             st = et;
             et = tt;
         }
         et = et.AddDays(1).AddMilliseconds(-1);
         var uid = Guid.Parse(Session["MemberId"].ToString());
         var root = db.Value.Housing_Member.Count(o => o.UserId == uid && o.DepartmentId == Guid.Empty) > 0;
         using (IStorageEngine engine = STSdb.FromFile(Server.MapPath(string.Format("App_Data/Housing_{0}.record.queryx", id))))
         {
             var table = engine.OpenXTablePortable<Guid, HousingLog>("Record");
             list = table.Where(o => o.Value.时间 >= st && o.Value.时间 <= et).OrderByDescending(o => o.Value.时间).Select(o => o.Value).ToList();
         }
         //if (!root)
         //{
             list = list.Join(db.Value.Housing_Member.Where(x => x.DepartmentId != Guid.Empty), o => o.用户ID, o => o.UserId, (a, b) => a).ToList();
         //}
         grid.DataSource = list;
     }
 }
Example #6
0
    static void Main()
    {
        Person Ivan = new Person{ Name = "Ivan Petrov" };
        Person Gosho = new Person{ Name = "Gosho Georgiev" };
        Person Mara = new Person{ Name = "Kaka Mara" };

        Pet barley = new Pet{ Name = "Barley", Owner = Ivan };
        Pet boots = new Pet{ Name = "Boots", Owner = Ivan };
        Pet whiskers = new Pet{ Name = "Whiskers", Owner = Mara };
        Pet daisy = new Pet{ Name = "Daisy", Owner = Gosho };

        List<Person> people = new List<Person>{ Ivan, Gosho, Mara };
        List<Pet> pets = new List<Pet>{ barley, boots, whiskers, daisy };
        var query =
        //from person in people
        //   join p in pets on person equals p.Owner
        //   select new { OwnerName = person.Name, Pet = p.Name };
        people.Join(pets, person => person,
                    pet => pet.Owner,
                    (person, pet) =>
                    new { OwnerName = person.Name, Pet = pet.Name });

        foreach (var obj in query)
        {
            Console.WriteLine("{0} - {1}",
                              obj.OwnerName,
                              obj.Pet);
        }
    }
        public PathTemplateProcessor(string path)
        {
            var segments = new List<PathSegment>();
            var searchPath = new List<string>();
            var pathSegments = path.Split(new[] { '/', '\\' });

            if (pathSegments[0] != "**")
                segments.Add(new WildcardPathSegment());

            foreach (var seg in pathSegments)
            {
                var templateSegment = TemplatePathSegment.TryParse(seg);
                PathSegment segment;
                string searchSegment;
                if (seg == "**")
                {
                    segment = new WildcardPathSegment();
                    searchSegment = "**";
                }
                else if (templateSegment != null)
                {
                    segment = templateSegment;
                    searchSegment = "*";
                }
                else
                {
                    segment = new LiteralPathSegment(seg);
                    searchSegment = seg;
                }
                segments.Add(segment);
                searchPath.Add(searchSegment);
            }
            _segments = new LinkedList<PathSegment>(segments);
            _searchString = searchPath.Join(System.IO.Path.DirectorySeparatorChar);
        }
        static void Main(string[] args)
        {
            // LINQ Using join
            string[] popularProductNames = { "A", "B" };
            var products = new List<Product>() {
                new Product() { Name = "A"},
                new Product() { Name = "A"},
                new Product() { Name = "B"},
                new Product() { Name = "C"},
            };

            // Query syntax
            var qresult = from p in products
                          join n in popularProductNames on p.Name equals n
                          select p;

            Console.WriteLine("Query syntax: {0}", string.Join(", ", qresult.Select(p => p.Name)));

            // Extension syntax
            var eresult = products.Join(popularProductNames, p => p.Name, pp => pp, (p,pp) => p);

            Console.WriteLine("Extension syntax: {0}", string.Join(", ", eresult.Select(p => p.Name)));

            Console.ReadLine();
        }
Example #9
0
 public void LoadDefaults(CachedUse use)
 {
     tid.Value = use.UserTarget;
     var catalogs = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
     if (CurrentStore.State == StoreState.食品)
     {
         catalogs.RemoveAll(o => o.ParentId == null && o.Name != use.UserTarget);
         catalog.DataSource = catalogs;
         catalog.DataBind();
         catalog.EmbeddedTree.Nodes[0].Expanded = true;
     }
     else
     {
         catalog.DataSource = catalogs;
         catalog.DataBind();
     }
     var ____a = (double?)use.Amount;
     note.Text = use.Note;
     if (use.CatalogId.HasValue && use.CatalogId.Value != Guid.Empty)
     {
         var catalogId = use.CatalogId.Value;
         var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString());
         node.Selected = true;
         node.ExpandParentNodes();
         catalog.SelectedValue = catalogId.ToString();
         var c = db.Value.StoreCatalog.Single(o => o.Id == catalogId);
         var list = new List<Guid>();
         AddChildren(list, c);
         obj.DataSource = list.Join(db.Value.StoreObject, o => o, o => o.CatalogId, (a, b) => b).OrderBy(o => o.Ordinal).ToList();
         obj.DataBind();
         if (use.ObjectId.HasValue && use.ObjectId.Value != Guid.Empty)
         {
             var oid = use.ObjectId.Value;
             var so = db.Value.StoreObject.Single(o => o.Id == oid);
             unit.Text = so.Unit;
             specification.Text = so.Specification;
             stored.Text = so.Amount.ToAmount();
             obj.SelectedIndex = obj.FindItemIndexByValue(use.ObjectId.ToString());
             amount.Value = ____a.HasValue ? ____a.Value : (double)so.Amount;
             if (so.Consumable)
             {
                 act.DataSource = new[] { "领用" };
                 act.DataBind();
             }
             else
             {
                 act.DataSource = new[] { "借用", "领用" };
                 act.DataBind();
             }
             if (!use.Type.Null())
             {
                 act.FindItemByText(use.Type).Selected = true;
             }
         }
         else
         {
             amount.Value = ____a;
         }
     }
 }
Example #10
0
    protected void InitializeHomoryPage()
    {
        var user = CurrentUser;

        //visit.ImageUrl = user.Icon;
        //visitTime.InnerText = DateTime.Now.ToString("HH:mm");
        time.Text = string.Format("{0} {1}", DateTime.Today.ToString("MM月dd日"),
            DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn")));
        board.DataSource = user.Resource.Where(o => o.State == State.启用).OrderByDescending(o => o.Rate).Take(5).ToList();
        board.DataBind();
        var favouritesSource = HomoryContext.Value.UserFavourite.Where(o => o.State == State.启用 && o.UserId == CurrentUser.Id).ToList();
        var favouritesSourceId = favouritesSource.Select(o => o.FavouriteUserId).ToList();
        favourites.DataSource = favouritesSource.Select(o => o.FavouriteUser).Take(3).ToList();
        favourites.DataBind();
        relatives.DataSource =
            HomoryContext.Value.User.Where(o => o.State < State.审核 && o.Type == UserType.教师 || o.Type == UserType.内置 || o.Type == UserType.注册).ToList().Where(o => !favouritesSourceId.Contains(o.Id)).Take(3).ToList();
        relatives.DataBind();

        var t1 = CurrentUser.GroupUser.Where(o => o.State < State.审核).ToList();
        var t2 = t1.Where(o => o.Group.Type == GroupType.教研团队 && o.State < State.审核).ToList().Select(o=>o.GroupId).ToList();
        var t3 = new List<Guid>();
        foreach (var g in t2)
        {
            t3.AddRange(HomoryContext.Value.Catalog.Where(o=>o.TopId==g).Select(o=>o.Id).ToList());
        }
        var t4 = t3.Join(HomoryContext.Value.ViewResourceX, o => o, o => o.CatalogId, (a, b) => b.Id).ToList().Distinct();
        groupRes.DataSource =
            t4.Join(HomoryContext.Value.Resource, o => o, o => o.Id, (a, b) => b)
                .OrderByDescending(o => o.Time)
                .Take(5)
                .ToList();
        groupRes.DataBind();
    }
Example #11
0
 private void HandleLine(Action<IList<string>> action, IList<string> lines)
 {
     foreach (var l in lines)
     {
         var match = ParseColumns.Match(l);
         if (match.Success)
         {
             var captures = match.Groups[2].Captures;
             var list = new List<string>(captures.Count);
             list.Add(match.Groups[1].Value);
             for (var i = 0; i < captures.Count; i++)
                 list.Add(captures[i].Value);
             try
             {
                 action(list);
             }
             catch
             {
                 try
                 {
                     action(list);
                 }
                 catch
                 {
                     if (this.Info != null)
                         this.Info.Failed.Add(list.Join("  "));
                 }
             }
         }
     }
 }
Example #12
0
    public void LoadDefaults(CachedIn @in)
    {
        tid.Value = @in.TargetId.ToString();
        var target = db.Value.StoreTarget.Single(o => o.Id == @in.TargetId);
        var catalogs = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
        if (CurrentStore.State == StoreState.食品)
        {
            catalogs.RemoveAll(o => o.ParentId == null && o.Name != target.UsageTarget);
            catalog.DataSource = catalogs;
            catalog.DataBind();
            catalog.EmbeddedTree.Nodes[0].Expanded = true;
            age.ReadOnly = true;
            age.Text = target.UsageTarget;
            place.Text = "{0}食堂".Formatted(target.UsageTarget.Substring(0, 2));
        }
        else
        {
            catalog.DataSource = catalogs;
            catalog.DataBind();
            age.ReadOnly = false;
            age.Text = string.Empty;
        }
        amount.Value = (double?)@in.Amount;
        perPrice.Value = (double?)@in.SourcePerPrice;
        fee.Value = (double?)@in.Fee;
        money.Value = (double?)@in.Money;
        if ([email protected]())
            place.Text = @in.Place;
        note.Text = @in.Note;
        time.SelectedDate = (@in.TimeNode.HasValue ? @in.TimeNode.Value : target.TimeNode).ToTime();
        if (@in.CatalogId.HasValue && @in.CatalogId.Value != Guid.Empty)
        {
            var catalogId = @in.CatalogId.Value;
            var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString());
            node.Selected = true;
            node.ExpandParentNodes();
            catalog.SelectedValue = catalogId.ToString();
            var c = db.Value.StoreCatalog.Single(o => o.Id == catalogId);
            var list = new List<Guid>();
            AddChildren(list, c);
            obj.DataSource = list.Join(db.Value.StoreObject, o => o, o => o.CatalogId, (a, b) => b).OrderBy(o => o.Ordinal).ToList();
            obj.DataBind();
            if (@in.ObjectId.HasValue && @in.ObjectId.Value != Guid.Empty)
            {
                var oid = @in.ObjectId.Value;
                var so = db.Value.StoreObject.Single(o => o.Id == oid);
                unit.Text = so.Unit;
                specification.Text = so.Specification;
                stored.Text = so.Amount.ToAmount();
                obj.SelectedIndex = obj.FindItemIndexByValue(@in.ObjectId.ToString());

                var last = so.StoreIn.OrderByDescending(o => o.AutoId).FirstOrDefault();
                if (last != null)
                {
                    perPrice.Value = (double)last.SourcePerPrice;
                }
            }
            age.Text = @in.Age;
        }
    }
        private static string GenerateWorkItemClass(WorkItem item)
        {
            var classes = new List<string> {"workitem"};
            classes.AddRange(item.Classes);

            return classes.Join(' ');
        }
Example #14
0
		public static string GetCallingArguments(IEnumerable<Expression> pArguments) {
			List<string> values = new List<string>();
			foreach (Expression expression in pArguments) {
				values.Add(expression.Value);
			}

			return values.Join(", ");
		}
		protected override long InternalExecute()
		{
			long iRows                   = 0L;
			List<string>    queryColumns = new List<string>();
			SQLiteParameter idParam      = new SQLiteParameter("@" + this._identityField, DbType.Int64);

			Dictionary<string, SQLiteParameter> parametersCache = new Dictionary<string, SQLiteParameter>
			{
				{ this._identityField.ToUpper(), idParam }
			};

			if (this.TableDefinition != null)
			{
				foreach (FieldDefinition field in this.TableDefinition.Fields.Values)
				{
					parametersCache.Add(field.Name, new SQLiteParameter("@" + field.Name, field.SqlType.ToDbType()));

					queryColumns.Add(field.Name.AsSqlClausePair());
				}

				string updateSql = queryColumns.Join(", ");

				string sql = string.Format(
					"UPDATE [{0}] SET {1} WHERE [{2}] = @{2};",
					this.TableDefinition.Name,
					updateSql,
					this._identityField
				);

				Log.DebugFormat(
					"update: Table: '{0}', Query: '{1}'",
					this.TableDefinition.Name,
					sql
				);

				foreach (ITableRow row in this._rows)
				{
					foreach (KeyValuePair<string, object> pair in row.Values)
					{
						if (parametersCache.ContainsKey(pair.Key))
						{
							parametersCache[pair.Key].Value = pair.Value;
						}
					}

					idParam.Value = row.Values[this._identityField];

					iRows = this.ExecuteNonQuery(
						sql,
						parametersCache.Values
					);
				}
			}

			this._rows.Clear();

			return iRows;
		}
        public void Join()
        {
            // Arrange
            object[] objects = { 1, 2, 3 };
            string[] strings = { "a", "b", "c" };
            var enumerable = new List<string> { "a", "b", "c" };

            // Act & Assert
            Assert.Equal("1,2,3", objects.Join(","));
            Assert.Equal("a+b+c", strings.Join("+"));
            Assert.Equal("a;b;c", enumerable.Join(";"));
        }
        public static string[] Split(this string self, string separator, int limit = 0)
        {
            if (self == "") return new string[] { };
            if (separator == null) separator = " ";

            string[] splitted;

            switch (separator)
            {
                case " ":
                    splitted = self.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    break;
                case "":
                    splitted = self.ToCharArray().ToStringArray();
                    break;
                default:
                    splitted = self.Split(new string[] { separator }, StringSplitOptions.None);
                    break;
            }

            if (limit < 0)
            {

            }
            else if (limit == 0 && splitted.Length >= 1)
            {
                var list = splitted.ToList();

                while (list.Last() == "")
                {
                    list.RemoveAt(list.Count - 1);
                }

                splitted = list.ToArray();
            }
            else
            {
                var list = splitted.ToList();
                var outOfLimitList = new List<string>();

                (list.Count - 1).To(limit - 1).Each(idx =>
                {
                    outOfLimitList.Insert(0, list[idx]);
                    list.RemoveAt(idx);
                });

                list.Add(outOfLimitList.Join(separator));

                splitted = list.ToArray();
            }

            return splitted;
        }
Example #18
0
        public static string FindPath(IRequestData dictionary)
        {
            var routeData = dictionary.ValuesFor(RequestDataSource.Route);
            var list = new List<string>();

            for (var i = 0; i < 10; i++)
            {
                routeData.Value("Part" + i, o => list.Add(o.RawValue.ToString()));
            }

            return list.Join("/");
        }
Example #19
0
        static void Main(string[] args)
        {
            List<Employee> employees = new List<Employee>()
            {
                new Employee()
                {
                    FirstName = "Luis",
                    LastName = "Felipe",
                    StateId = 1
                },
                new Employee()
                {
                    FirstName = "John",
                    LastName = "Smith",
                    StateId = 2
                },
                new Employee()
                {
                    FirstName = "Deadpool",
                    LastName = "NULL!",
                    StateId = 1
                }
            };

            List<State> states = new List<State>()
            {
                new State()
                {
                    StateId = 1,
                    StateName = "RN"
                },
                new State()
                {
                    StateId = 2,
                    StateName = "SP"
                } };

            /* The parameters of the Join method are a collection that implements IEnumerable interface, 
            the following keys of each group you want to match, then the condition match (attribute1, attribute2)
            in a lambda expression of a new created object with attributes from both matched "rows" */
            var employeeByState = employees.Join(states,
                                                 e => e.StateId,
                                                 s => s.StateId,
                                                 (e, s) => new { e.LastName, s.StateName });
            foreach (var employee in employeeByState)
            {
                Console.WriteLine(String.Format("Last Name: {0}, State Name: {1}", employee.LastName, employee.StateName));
            }
        }
Example #20
0
        private string writeForm()
        {
            var document = new XmlDocument();
            document.LoadXml(writeXml());

            var list = new List<string>();

            foreach (XmlElement element in document.DocumentElement.ChildNodes)
            {
                var data = "{0}={1}".ToFormat(element.Name, element.InnerText.UrlEncode());
                list.Add(data);
            }

            return list.Join("&");
        }
Example #21
0
        public void AssertIsValid()
        {
            var messages = new List<string>();
            if (ApplicationBase.IsEmpty())
            {
                messages.Add("ApplicationBase must be a valid folder");
            }

            if (EnvironmentClassName.IsEmpty() && AssemblyName.IsEmpty())
            {
                messages.Add("Either EnvironmentClassName or AssemblyName must be set");
            }

            if (messages.Any())
            {
                throw new EnvironmentRunnerException(messages.Join("; "));
            }
        }
Example #22
0
 public virtual string FilterString( FilterSet fs )
 {
     if( fs.Rules.Count == 0 )
         return null;
     List<string> items = new List<string>();
     foreach( IFilterRule r in fs.Rules )
     {
         if( r is FilterInfo )
         {
             items.Add( FilterString( r as FilterInfo) );
         }
         else if( r is FilterSet )
         {
             items.Add( "(" + FilterString( r as FilterSet ) + ")" );
         }
     }
     return items.Join( fs.JoinOperator == FilterJoinOperator.And ? " AND " : " OR " );
 }
    void BuildUpNameDictionary(bool createTemporaryAssemblies, List<string> preloadOrder)
    {
        var orderedResources = preloadOrder
            .Join(ModuleDefinition.Resources, p => p.ToLowerInvariant(),
            r =>
            {
                var parts = r.Name.Split('.');
                string ext, name;
                GetNameAndExt(parts, out name, out ext);
                return name;
            }, (s, r) => r)
            .Union(ModuleDefinition.Resources.OrderBy(r => r.Name))
            .Where(r => r.Name.StartsWith("costura"))
            .Select(r => r.Name);

        foreach (var resource in orderedResources)
        {
            var parts = resource.Split('.');

            string ext, name;
            GetNameAndExt(parts, out name, out ext);

            if (parts[0] == "costura")
            {
                if (createTemporaryAssemblies)
                    AddToList(preloadListField, resource);
                else
                {
                    if (ext == "pdb")
                        AddToDictionary(symbolNamesField, name, resource);
                    else
                        AddToDictionary(assemblyNamesField, name, resource);
                }
            }
            else if (parts[0] == "costura32")
            {
                AddToList(preload32ListField, resource);
            }
            else if (parts[0] == "costura64")
            {
                AddToList(preload64ListField, resource);
            }
        }
    }
        public dynamic GetNamesAndType(List<Customer> customerList,
                                        List<CustomerType> customerTypeList)
        {
            var query = customerList.Join(customerTypeList,
                c => c.CustomerTypeId,
                ct => ct.CustomerTypeId,
                (c, ct) => new
                {
                    Name = c.LastName + ", " + c.FirstName,
                    CustomerTypeName = ct.TypeName
                });

            foreach (var item in query)
            {
                Console.WriteLine(item.ToString());
            }

            return query;
        }
Example #25
0
 private static bool WriteStatus(ReferenceStatus status)
 {
   List<string> flags = new List<string>();
   if (status.IsProjectMissing)
   {
     flags.Add("Missing Project");
   }
   if (status.IsReferencedVersionMissing)
   {
     flags.Add("Missing Version");
   }
   if (status.IsHealthy)
   {
     if (status.IsOutdated)
     {
       flags.Add("Outdated");
     }
     if (!status.IsReferencedVersionInstalled)
     {
       flags.Add("NeedsUnpackage");
     }
     if (!status.IsAnyVersionInstalled)
     {
       flags.Add("NothingInstalled");
     }
     else if (status.IsOlderVersionInstalled)
     {
       flags.Add("OlderVersionInstalled");
     }
   }
   List<string> parts = new List<string>();
   parts.Add("  " + status.DependencyName);
   if (!status.ReferencedVersionTags.Empty)
   {
     parts.Add("(" + status.ReferencedVersionTags + ")");
   }
   if (flags.Count > 0)
   {
     parts.Add("(" + flags.Join(", ") + ")");
   }
   Console.WriteLine(parts.ToArray().Join(" "));
   return !status.IsHealthy;
 }
Example #26
0
        public static void Run()
        {
            Console.Out.WriteLine(1.RespondTo("ToString"));
            Console.Out.WriteLine(1.Send("ToString").GetType());

            Console.Out.WriteLine(1.RespondTo("Whoops"));
            try
            {
                Console.Out.WriteLine(1.Send("Whoops", 42, "hi there"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            var list = new List<string>();
            list.Send("Add", "hello there");
            Console.Out.WriteLine(list.Join(", "));
        }
Example #27
0
		public static string ConvertModifiers(IEnumerable<string> pModifiers, Dictionary<string , string> pReplaceable = null) {
			List<string> mods = new List<string>();
			foreach (string modifier in pModifiers) {
				string o;
				string mod = modifier;
				if (_flashModifiers.TryGetValue(modifier, out o)) {
					if (string.IsNullOrEmpty(o)) continue;
					mod = o;
				}

				if (pReplaceable != null) {
					if (pReplaceable.TryGetValue(mod, out o))
						mod = o;
				}

				mods.Add(mod);
			}

			string ret = mods.Join(" ");
			return string.IsNullOrEmpty(ret) ? string.Empty : ret + " ";
		}
Example #28
0
 public override void Execute(IList<string> parameters)
 {
     var pins = new List<string> ();
     foreach (var i in Application.Configuration.GetDevices ().Values) {
         if (i.PIN.IsEmpty ()) {
             Console.Error.WriteLine ("No PIN configured for device '{0}'--ignoring.", i.Name);
         }
         pins.Add (String.Format ("-devicepin {0}", i.PIN));
     }
     var pw = Application.Configuration.CSKPassword;
     while (pw.IsEmpty ()) {
         pw = Extensions.ReadPassword ("CSK Password (will not echo): ");
     }
     Directory.GetParent (Application.Configuration.DebugToken).Create ();
     var cmd = String.Format ("{0} -storepass \"{2}\" {1} {3}",
                              Application.GetToolPath ("blackberry-debugtokenrequest"),
                              pins.Join (" "),
                              pw,
                              Application.Configuration.DebugToken);
     Run (cmd);
 }
        static void Main(string[] args)
        {
            List<StudentSpecialty> specialties = new List<StudentSpecialty>();
            List<Student> students = new List<Student>();

            string input = Console.ReadLine();
            while (input != "Students:")
            {
                var inputArgs = input.Split();
                var specialty = new StudentSpecialty(
                    inputArgs[0].Trim() + " " + inputArgs[1].Trim(), 
                    long.Parse(inputArgs[2].Trim()));
                specialties.Add(specialty);
                input = Console.ReadLine();
            }

            input = Console.ReadLine();
            while (input != "END")
            {
                var inputArgs = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                var student = new Student(
                    inputArgs[1].Trim() + " " + inputArgs[2].Trim(), 
                    long.Parse(inputArgs[0].Trim()));
                students.Add(student);
                input = Console.ReadLine();
            }

            var result =
                students.Join(
                    specialties, 
                    student => student.Number, 
                    specialty => specialty.SpecialtyNumber, 
                    (student, specialty) => new { student.Name, student.Number, specialty.SpecialtyName })
                    .OrderBy(x => x.Name);

            foreach (var obj in result)
            {
                Console.WriteLine("{0} {1} {2}", obj.Name, obj.Number, obj.SpecialtyName);
            }
        }
        public string ToSql(NpgsqlCommand command)
        {
            var wheres = _expression
                .QueryModel
                .BodyClauses
                .OfType<WhereClause>()
                .Select(x => x.Predicate)
                .ToArray();

            if (!wheres.All(x => x is BinaryExpression || x is SubQueryExpression))
            {
                throw new NotSupportedException();
            }

            var binaryExpressions = wheres.OfType<BinaryExpression>().ToArray();
            var subQueryExpressions = wheres.OfType<SubQueryExpression>().ToArray();

            var conditions = new List<string>();
            conditions.AddRange(buildBinary(binaryExpressions, command));
            conditions.AddRange(subQueryExpressions.Select(s => buildSubQuery(s, command)));
            return conditions.Join(" AND ");
        }