Example #1
0
    public static void Main () {
        var emptyInts = new int[0];
        var ints = new[] { 1, 2, 3, 4 };

        Console.WriteLine(emptyInts.FirstOrDefault());
        Console.WriteLine(ints.FirstOrDefault());

        Console.WriteLine(ints.First());

        Console.WriteLine(emptyInts.FirstOrDefault((i) => i > 4));
        Console.WriteLine(ints.FirstOrDefault((i) => i > 4));

        Console.WriteLine(ints.First((i) => i > 2));
    }
Example #2
0
        public EntityCodeGenerator(EntityCodeGenerationModel model, GeneratorConfig config)
        {
            var kdiff3Paths = new[]
            {
                config.KDiff3Path,
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "KDiff3\\kdiff3.exe"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "KDiff3\\kdiff3.exe"),
            };

            this.model = model;
            CodeFileHelper.Kdiff3Path = kdiff3Paths.FirstOrDefault(File.Exists);

            if (config.TFSIntegration)
                CodeFileHelper.SetupTFSIntegration(config.TFPath);

            CodeFileHelper.SetupTSCPath(config.TSCPath);

            siteWebProj = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, config.WebProjectFile));
            siteWebPath = Path.GetDirectoryName(siteWebProj);
            if (!string.IsNullOrEmpty(config.ScriptProjectFile))
            {
                scriptProject = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, config.ScriptProjectFile));
                scriptPath = Path.GetDirectoryName(scriptProject);

                if (!File.Exists(scriptProject))
                {
                    scriptProject = null;
                    scriptPath = null;
                }
            }

            this.config = config;
        }
Example #3
0
	public override bool TouchesBegan (System.Collections.Generic.IEnumerable<NGraphics.Point> points)
	{
		_startPoint = points.FirstOrDefault ();
		_startPoint.X -= _image.TranslationX;
		_startPoint.Y -= _image.TranslationY;
		return true;
	}
Example #4
0
        static void AreaSpellCheck(Player sender, ExecuteOrderEventArgs args)
        {
            var spells = new[]
            {
                new AreaSpell("enigma_black_hole", "pull_radius"),
                new AreaSpell("puck_dream_coil", "coil_radius"),
                new AreaSpell("obsidian_destroyer_sanity_eclipse", "radius"),
                new AreaSpell("faceless_void_chronosphere", "radius"),

            };
            var spell = spells.FirstOrDefault(x => x.Name == args.Ability.Name);
            if (spell != null)
            {
                var enemies =
                    ObjectMgr.GetEntities<Hero>()
                        .Where(
                            x =>
                            x.IsAlive && x.IsVisible && !x.IsIllusion && x.Team != sender.Team
                            && x.Distance2D(args.TargetPosition) - x.HullRadius
                            < args.Ability.AbilityData.First(s => s.Name == spell.Radius).Value);
                if (!enemies.Any())
                {
                    args.Process = false;
                    return;
                }
            }
            if (PowerTreadsIntCheck(args))
                args.Ability.UseAbility(args.TargetPosition, true);
        }
        public void Execute(object parameter)
        {
            _baseCommand.Execute(parameter);

            var document = _editor.Document;
            var line = document.GetLineByOffset(_editor.SelectionStart)?.PreviousLine;
            if (line == null) return;
            var text = document.GetText(line.Offset, line.Length);

            Func<Regex, Action<Match>, Action> matchDo = (pattern, action) =>
            {
                var match = pattern.Match(text);
                return match.Success ? () => action(match) : (Action)null;
            };

            var patterns = new[]
            {
                matchDo(UnorderedListPattern, m => document.Insert(_editor.SelectionStart, m.Groups[0].Value.TrimStart() + " ")),
                matchDo(UnorderedListEndPattern, m => document.Remove(line)),
                matchDo(OrderedListPattern, m =>
                {
                    var number = int.Parse(m.Groups[1].Value) + 1;
                    document.Insert(_editor.SelectionStart, number + ". ");
                    RenumberOrderedList(document, line.NextLine, number);
                }),
                matchDo(OrderedListEndPattern, m => document.Remove(line)),
                matchDo(BlockQuotePattern, m => document.Insert(_editor.SelectionStart, m.Groups[1].Value.TrimStart())),
                matchDo(BlockQuoteEndPattern, m => document.Remove(line))
            };

            patterns.FirstOrDefault(action => action != null)?.Invoke();
        }
        public Tuple<string, int> GetPropertyForControl(object control)
        {
            // NB: These are intentionally arranged in priority order from most
            // specific to least specific.
            var items = new[] {
#if !WINRT
                new { Type = typeof(RichTextBox), Property = "Document" },
#endif
                new { Type = typeof(Slider), Property = "Value" },
#if !SILVERLIGHT && !WINRT
                new { Type = typeof(Expander), Property = "IsExpanded" },
#endif 
                new { Type = typeof(ToggleButton), Property = "IsChecked" },
                new { Type = typeof(TextBox), Property = "Text" },
                new { Type = typeof(TextBlock), Property = "Text" },
                new { Type = typeof(ProgressBar), Property = "Value" },
                new { Type = typeof(ItemsControl), Property = "ItemsSource" },
                new { Type = typeof(Image), Property = "Source" },
                new { Type = typeof(ContentControl), Property = "Content" },
                new { Type = typeof(FrameworkElement), Property = "Visibility" },
            };

            var type = control.GetType();
            var kvp = items.FirstOrDefault(x => x.Type.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()));

            return kvp != null ? Tuple.Create(kvp.Property, 5) : null;
        }
        public Tuple<string, int> GetPropertyForControl(object control)
        {
            // NB: These are intentionally arranged in priority order from most
            // specific to least specific.
#if UIKIT
            var items = new[] {
                new { Type = typeof(UISlider), Property = "Value" },
                new { Type = typeof(UITextView), Property = "Text" },
                new { Type = typeof(UITextField), Property = "Text" },
                new { Type = typeof(UIButton), Property = "Title" },
                new { Type = typeof(UIImageView), Property = "Image" },
            };
#else
            var items = new[] {
                new { Type = typeof(NSSlider), Property = "DoubleValue" },
                new { Type = typeof(NSTextView), Property = "Value" },
                new { Type = typeof(NSTextField), Property = "StringValue" },
                new { Type = typeof(NSLevelIndicator), Property = "DoubleValue" },
                new { Type = typeof(NSProgressIndicator), Property = "DoubleValue" },
                new { Type = typeof(NSButton), Property = "Title" },
                new { Type = typeof(NSMenuItem), Property = "Title" },
                new { Type = typeof(NSImageView), Property = "Image" },
            };
#endif

            var type = control.GetType();
            var kvp = items.FirstOrDefault(x => x.Type.IsAssignableFrom(type));

            return kvp != null ? Tuple.Create(kvp.Property, 5) : null;
        }
Example #8
0
	private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query)
	{
		var combined = new [] {leftQuery, rightQuery};
		var any = combined.Any(bf => bf == null || ((IQuery) bf).Conditionless); 
		query = any ?  combined.FirstOrDefault(bf => bf != null && !((IQuery)bf).Conditionless) : null;
		return any;
	}
        public override int GetTargetIndex(System.Collections.Generic.List<WorldObject> availableTargets)
        {
            var target = availableTargets
                .FirstOrDefault(x => x.Owner != 0);

            return availableTargets.IndexOf(target);
        }
Example #10
0
        private static IEnumerable<XElement> GetXmlElements(System.IO.TextReader f)
        {
            //read until nex interesting element;
            var line = "";
            var interestings = new[] {"OBJECT", "LINK", "ATTR-VALUE", "ATTRIBUTE" };
            var attributeName = "";
            while ((line = f.ReadLine())!=null)
            {
                line = line.Trim();
                var nextOOI = interestings.FirstOrDefault( i => line.StartsWith("<"+i+" ") );
                if (nextOOI == null)
                    continue;
                //If it is the attribute tag, get the current atttribute name
                if (nextOOI == "ATTRIBUTE")
                {
                    attributeName = line.Split(new[] { "NAME=\"" }, 2, StringSplitOptions.RemoveEmptyEntries)[1].Split("\"".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries)[0];
                    continue;
                }
                //Read to the end of the tag
                var xml = line;
                if (!xml.Contains("/>"))
                    while (!xml.Contains("</" + nextOOI))
                        xml += f.ReadLine();
                var rv = XElement.Parse(xml);

                if (nextOOI == "ATTR-VALUE")
                {
                    rv.Add(new XAttribute("NAME", attributeName));
                }
                yield return rv;
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var angularRoutes = new[] {
                "/home"
            };

            app.Use(async (context, next) =>
            {
                if (context.Request.Path.HasValue && null != angularRoutes.FirstOrDefault(
                    (ar) => context.Request.Path.Value.StartsWith(ar, StringComparison.OrdinalIgnoreCase)))
                {
                    context.Request.Path = new PathString("/");
                }

                await next();
            });
            app.UseDefaultFiles();

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #12
0
	private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query)
	{
		var combined = new [] {leftQuery, rightQuery};
		var anyEmpty = combined.Any(q => q == null || !q.IsWritable);
		query = anyEmpty ? combined.FirstOrDefault(q => q != null && q.IsWritable) : null;
		return anyEmpty;
	}
Example #13
0
 protected override ModelMetadata CreateMetadata(System.Collections.Generic.IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
 {
     var metadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName);
     var formInputAttribute = (FormInputAttribute)attributes.FirstOrDefault(x => x is FormInputAttribute);
     if (formInputAttribute != null) {
         metadata.TemplateHint = formInputAttribute.TemplateHint;
     }
     return metadata;
 }
Example #14
0
        public static VisualStudioVersion ParseVersionString(string versionNumber)
        {
            var versions = new[] {vs2008, vs2010};

            VisualStudioVersion version = versions.FirstOrDefault(v => versionNumber.Contains(v.Year)) ??
                                          VisualStudioVersion.VS2010;

            return version;
        }
        public override Character GetTarget(System.Collections.Generic.IEnumerable<Character> targetsList)
        {
            var targetsHp = targetsList
                .Where(t => t.Team == this.Team && t != this && t.IsAlive)
                .Select(t => t.HealthPoints);

            return targetsList
                .FirstOrDefault(t => t.HealthPoints == targetsHp.Min());
        }
 private static string GetSource(IVsProject project, string source)
 {
     var directory = Directory.Exists(source) ? source : Path.GetDirectoryName(source);
     var candidates = new[]{
         Path.Combine(directory, Globals.SettingsFilename),
         Path.Combine(directory, Globals.KarmaConfigFilename)
     };
     return candidates.FirstOrDefault(f => project.HasFile(f));
 }
        public void Collide()
        {
            if (!this._movingItem1.IsExtant || !this._movingItem2.IsExtant)
                return;

            var items = new[] { this._movingItem1, this._movingItem2 };
            var shot = items.OfType<Shot>().FirstOrDefault();
            if (shot != null)
                {
                var otherItem = items.Single(item => item != shot);
                if (InteractionInvolvingShot(this._world, shot, otherItem))
                    return;
                }

            var mine = items.OfType<Mine>().FirstOrDefault();
            if (mine != null)
                {
                var otherItem = items.Single(item => item != mine);
                mine.SteppedOnBy(otherItem);
                return;
                }

            var player = items.OfType<Player>().SingleOrDefault();
            if (player != null)
                {
                var monster = items.Single(item => item != player) as Monster.Monster;
                if (monster != null)
                    {
                    int monsterEnergy = monster.InstantlyExpire();
                    player.ReduceEnergy(monsterEnergy);
                    this._world.AddBang(monster.Position, BangType.Long);
                    this._world.Game.SoundPlayer.Play(GameSound.PlayerCollidesWithMonster);
                    return;
                    }
                }

            var moveableObject = items.FirstOrDefault(item => item.Solidity == ObjectSolidity.Moveable);
            var movingObject = items.FirstOrDefault(item => item != moveableObject && (item.Capability == ObjectCapability.CanPushOthers || item.Capability == ObjectCapability.CanPushOrCauseBounceBack));
            if (moveableObject != null && movingObject != null)
                {
                if (PushOrBounceObject(moveableObject, movingObject))
                    return;
                }
        }
        private string GetIndexFileName()
        {
            var indexNames = new[] { "index.html", "index.htm", "index.txt" };

            return indexNames.FirstOrDefault(t =>
            {
                var indexPath = Path.Combine(directory, t);
                return File.Exists(indexPath);
            });
        }
Example #19
0
		public override bool TouchesMoved (System.Collections.Generic.IEnumerable<NGraphics.Point> points)
		{
			var newPoint = points.FirstOrDefault ();
			var diff = new NGraphics.Point (newPoint.X - _startPoint.X, newPoint.Y - _startPoint.Y);

			_image.TranslationX = diff.X;
			_image.TranslationY = diff.Y;

			return true;
		}
        public Version GetBaseUriVersion(System.Data.Services.Client.DataServiceQuery<biz.dfch.CS.Appclusive.Core.OdataServices.Diagnostics.Endpoint> endpoint)
        {
            Contract.Requires(null != endpoint);
            Contract.Ensures(null != Contract.Result<Version>());

            var baseUri = endpoint.FirstOrDefault(e => e.Id == 1);
            Contract.Assert(null != baseUri, "Retrieving version information FAILED.");
            
            var result = new Version(baseUri.Version);
            return result;
        }
 private static string getFlashDevelopPath()
 {
     //TODO: get from registry
     var possiblePaths = new[] {
         @"C:\Program Files\FlashDevelop\FlashDevelop.exe",
         @"C:\Program Files (x86)\FlashDevelop\FlashDevelop.exe",
         @"C:\Users\Jason\Desktop\LaunchpadDebug\src\FlashDevelop\FlashDevelop\Bin\Debug\FlashDevelop.exe"
     };
     var path = possiblePaths.FirstOrDefault (File.Exists);
     return path ?? possiblePaths[2];
 }
Example #22
0
        public static String GetExecutableLocation()
        {
            String appConfig = ConfigurationManager.AppSettings["vlc_location"] ?? "";
            var possibleLocations = new[]
            {
                appConfig + "\\vlc.exe",
                @"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",
                @"C:\Program Files\VideoLAN\VLC\vlc.exe"
            };

            return possibleLocations.FirstOrDefault(l => File.Exists(l));
        }
Example #23
0
        /// <remarks>Algorithm seen in GitHub Windows client.</remarks>
        public static Encoding GuessEncodingForBytes(byte[] buffer)
        {
            if (buffer == null)
                throw new ArgumentNullException("buffer");

            if (buffer.Length < 8)
                return Encoding.UTF8;

            var source = new[]
            {
                new Definition { Pattern = new byte[] { 239, 187, 191 }, Encoding = Encoding.UTF8 },
                new Definition { Pattern = new byte[] { 254, 255 }, Encoding = Encoding.BigEndianUnicode },
                new Definition { Pattern = new byte[] { 255, 255, 0, 0 }, Encoding = Encoding.UTF32 },
                new Definition { Pattern = new byte[] { 255, 254 }, Encoding = Encoding.Unicode },
                new Definition { Pattern = new byte[] { 43, 47, 118, 56 }, Encoding = Encoding.UTF7 },
                new Definition { Pattern = new byte[] { 43, 47, 118, 57 }, Encoding = Encoding.UTF7 },
                new Definition { Pattern = new byte[] { 43, 47, 118, 43 }, Encoding = Encoding.UTF7 },
                new Definition { Pattern = new byte[] { 43, 47, 118, 47 }, Encoding = Encoding.UTF7 }
            };

            Definition type = source.FirstOrDefault(bom => bom.Pattern.Zip<byte, byte, bool>(buffer, (l, r) => (l == r)).All<bool>(x => x));

            if (type != null)
                return type.Encoding;

            var flags = NativeMethods.IsTextUnicodeFlags.IS_TEXT_UNICODE_NOT_UNICODE_MASK;

            if (NativeMethods.IsTextUnicode(buffer, buffer.Length, ref flags))
                return Encoding.GetEncoding(Thread.CurrentThread.CurrentCulture.TextInfo.ANSICodePage);

            int numberOfZeros = buffer.Count(b => b == 0);

            double ratioOfZeros = (double)numberOfZeros / (double)buffer.Length;

            if (ratioOfZeros > 0.6)
                return Encoding.UTF32;

            if (ratioOfZeros > 0.3)
            {
                if (buffer[0] != 0)
                    return Encoding.Unicode;

                return Encoding.BigEndianUnicode;
            }

            if (NativeMethods.MultiByteToWideChar(Utf8Codepage, NativeMethods.MbwcFlags.MBErrInvalidChars, buffer, buffer.Length, null, 0) == 0)
                return Encoding.Unicode;

            return Encoding.UTF8;
        }
        public void ActionWorkerAllOnUITypeTesting()
        {
            using (ShimsContext.Create())
              {
            Session session = new Microsoft.Deployment.WindowsInstaller.Fakes.ShimSession().Instance;
            Microsoft.Deployment.WindowsInstaller.Fakes.ShimSession.AllInstances.GetModeInstallRunMode =
              (@this, mode) => { return mode == InstallRunMode.Scheduled; };

            // Установим по умолчанию сессию, иначе будут вызываться с других тестом Stub-объекты.
            // Не понятно почему, разобрать позже...
            session.SetDefaultSessionService(null);

            var workers = new[]
            {
              new { Worker = (IActionWorker)new StubActionCheckConnectionWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionDatabaseUIControlWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionDefineSqlServerPathWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionInstallingExtendedProceduresWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionMefControlWorker(session), ServerMode = true, ClientMode = true },
              new { Worker = (IActionWorker)new StubActionRestoringDatabaseWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionRunSqlScriptNewDbWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionRunSqlScriptExistingDbWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionSelectDatabasesWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionServerUIControlWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionTempDirectoryControlWorker(session), ServerMode = true, ClientMode = true },
              new { Worker = (IActionWorker)new StubActionUITypeWorker(session), ServerMode = true, ClientMode = true },

              new { Worker = (IActionWorker)new StubActionInitializationFinishInfoWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionWidgetCreaterWorker(session), ServerMode = true, ClientMode = false },
              new { Worker = (IActionWorker)new StubActionInstallReportWorker(session), ServerMode = true, ClientMode = true }
            };

            // Берем все не абстрактные типы с реализацией IActionWorker и проверяем количество в тестируемом списке.
            var workerTypes = typeof(IActionWorker).Assembly.GetTypes().
              Where(v => !v.IsAbstract && v.GetInterface(typeof(IActionWorker).Name) != null).ToArray();

            Assert.AreEqual(workerTypes.Count(), workers.Length, string.Format("Не все тесты IActionWorker реализованы ({0} из {1}).",
              workers.Length, workerTypes.Count()));

            foreach (var type in workerTypes)
            {
              Assert.IsNotNull(workers.FirstOrDefault(v => v.Worker.GetType().IsSubclassOf(type)),
            string.Format("Нет реализации для {0}.", type.Name));
            }

            // Проверяем функциональность.
            foreach (var worker in workers)
              Check(worker.Worker, worker.ServerMode, worker.ClientMode);
              }
        }
 private LogLevel GetMatchingLogLevelOrDefault(int? logLevel)
 {
     LogLevel[] logLevels = new[]
                        {
                            LogLevel.Debug,
                            LogLevel.Error,
                            LogLevel.Fatal,
                            LogLevel.Info,
                            LogLevel.Off,
                            LogLevel.Trace,
                            LogLevel.Warn
                        };
     return logLevels.FirstOrDefault(x => x.Ordinal == logLevel);
 }
        public MovingItemAndMovingItemInteraction(World world, MovingItem movingItem1, MovingItem movingItem2)
        {
            if (world == null)
                throw new ArgumentNullException("world");
            if (movingItem1 == null)
                throw new ArgumentNullException("movingItem1");
            if (movingItem2 == null)
                throw new ArgumentNullException("movingItem2");
            if (movingItem1 is Shot)
                throw new ArgumentOutOfRangeException("movingItem1");
            if (movingItem2 is Shot)
                throw new ArgumentOutOfRangeException("movingItem2");

            this._world = world;
            var items = new[] {movingItem1, movingItem2};
            this._player = items.OfType<Player>().SingleOrDefault();
            this._boulder = items.OfType<Boulder>().SingleOrDefault();
            this._mine = items.OfType<Mine>().SingleOrDefault();
            this._monster1 = items.OfType<Monster.Monster>().FirstOrDefault();
            this._monster2 = items.OfType<Monster.Monster>().Skip(1).FirstOrDefault();

            this._moveableObject = items.FirstOrDefault(item => item.Solidity == ObjectSolidity.Moveable);
            this._insubstantialObject = items.FirstOrDefault(item => item.Solidity == ObjectSolidity.Insubstantial);
        }
        public Tuple<string, int> GetPropertyForControl(object control)
        {
            // NB: These are intentionally arranged in priority order from most
            // specific to least specific.
            var items = new[] {
                new { Type = typeof(TextView), Property = "Text" },
                new { Type = typeof(ProgressBar), Property = "Progress" },
                new { Type = typeof(CompoundButton), Property = "Checked" },
            };

            var type = control.GetType();
            var kvp = items.FirstOrDefault(x => x.Type.IsAssignableFrom(type));

            return kvp != null ? Tuple.Create(kvp.Property, 5) : null;
        }
Example #28
0
        public EntityCodeGenerator(EntityCodeGenerationModel model, GeneratorConfig config)
        {
            var kdiff3Paths = new[]
            {
                config.KDiff3Path,
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "KDiff3\\kdiff3.exe"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "KDiff3\\kdiff3.exe"),
            };

            this.model = model;
            kdiff3Path = kdiff3Paths.FirstOrDefault(File.Exists);
            siteWebProj = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, config.WebProjectFile));
            siteWebPath = Path.GetDirectoryName(siteWebProj);
            scriptProject = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, config.ScriptProjectFile));
            scriptPath = Path.GetDirectoryName(scriptProject);
        }
        public ActionResult Customer(int id)
        {
            var customers = new[]{
                 new Customer{ Address="长安街1", Id=1, Name="张三"},
                 new Customer{ Address="长安街2", Id=2, Name="李四"},
                 new Customer{ Address="长安街3", Id=3, Name="dudu"},
                 new Customer{ Address="长安街4", Id=4, Name="DotDot"},
                 new Customer{ Address="长安街5", Id=5, Name="随它去吧"}

            };

            var customer = customers.FirstOrDefault(c => c.Id == id);

            return JsonpView(customer);

        }
        public Tuple<string, int> GetPropertyForControl(object control)
        {
            // NB: These are intentionally arranged in priority order from most
            // specific to least specific.
            var items = new[] {
                new { Type = typeof(Slider), Property = "Value" },
                new { Type = typeof(InputView), Property = "Text" },
                new { Type = typeof(TextCell), Property = "Text" },
                new { Type = typeof(Label), Property = "Text" },
                new { Type = typeof(ProgressBar), Property = "Value" },
                new { Type = typeof(Image), Property = "Source" },
            };

            var type = control.GetType();
            var kvp = items.FirstOrDefault(x => x.Type.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()));

            return kvp != null ? Tuple.Create(kvp.Property, 5) : null;
        }