Ejemplo n.º 1
0
        public void QueueUserWorkItemShouldProcessSimultaneousRequestsSequentially()
        {
            // Arrange
            const int expected = NUM_THREADS * LOOP_COUNT;
            var countdownEvent = new CountdownEvent(expected);
            ITaskScheduler singleThreadedTaskScheduler = new Core.Impl.SequentialTaskScheduler(null);
            Helper volatileFieldHelper = new Helper();

            // Act
            for (int i = 0; i < NUM_THREADS; i++)
            {
                new Thread(() =>
                {
                    for (int j = 0; j < LOOP_COUNT; j++)
                    {
                        singleThreadedTaskScheduler.ScheduleTask(() =>
                        {
                            int initialCount = volatileFieldHelper.Field;
                            Thread.Yield();
                            volatileFieldHelper.Field = initialCount + 1;
                            countdownEvent.Signal();
                        });
                    }
                }).Start();
            }

            // Assert
            Assert.IsTrue(countdownEvent.Wait(TimeSpan.FromSeconds(5)), "CountdownEvent timed out waiting to be signaled.");
            Assert.AreEqual(expected, volatileFieldHelper.Field, "Wrong count - race condition?");
        }
Ejemplo n.º 2
0
        internal void closeAndReset()
        {
            internalClose();

            // first helper is synchronized when getZooKeeper is called. Subsequent calls
            // are not synchronized.
            helper = new CloseHelper(this);
        }
Ejemplo n.º 3
0
        private async void Page_Loaded(object sender,RoutedEventArgs e) {
            try {
                HtmlHandler h = new HtmlHandler();
                await h.DownloadHtml("/browse/popular/" + url + "/1");
                var tbody = h.GetNodeByType(h.HtmlDoc,"tbody");
                ObservableCollection<IModel> ls = new ObservableCollection<IModel>();
                Helper hlp = new Helper();
                if(tbody != null)
                    foreach(var tr in tbody.ChildNodes) {
                        try {
                            if(tr == null)
                                continue;
                            var a1 = h.GetNodeByAttr(tr,"td","class","a1");
                            if(a1 == null)
                                continue;
                            IModel mdl = new IModel();
                            mdl.Url = h.GetAttr(h.GetNodeByType(a1,"a"),"href").ToString();

                            var l = h.GetNodeByAttr(a1,"span","class","l r neutral-icon");
                            mdl.Good =(l==null);
                            if(mdl.Good)
                                l = h.GetNodeByAttr(a1,"span","class","l r positive-icon");
                            
                            mdl.Lang = hlp.FormatTxt(l?.InnerText ?? "");
                            var YearNode = h.GetNodeByAttr(a1,"div","class","subtle");
                            var NameNode = YearNode.ParentNode;
                            mdl.Year = Int32.Parse(YearNode.InnerText.Substring(1,4));
                            mdl.Name = hlp.FormatTxt(NameNode.InnerText.Replace(YearNode.InnerText,""));

                            mdl.NumDls = Int32.Parse(hlp.FormatTxt(h.GetNodeByAttr(tr,"td","class","a7")?.InnerText).Replace(",","")?? "0");
                            mdl.Date = h.GetNodeByAttr(tr,"td","class","a6")?.InnerText ?? "";
                            mdl.Date = hlp.FormatTxt(mdl.Date);

                            mdl.Owner = h.GetNodeByAttr(tr,"td","class","a5")?.InnerText??"";
                            mdl.Owner = hlp.FormatTxt(mdl.Owner);
                            ls.Add(mdl);
                            if(ls.Count > 25)
                                break;
                        }
                        catch(Exception) { }
                    }
                GVName.ItemsSource = ls;
                #region Fix Xaml
                ring.IsActive = false;
                ringPanel.Visibility = Visibility.Collapsed;
                GVName.Visibility = Visibility.Visible;
                #endregion
            }
            catch(Exception) { Frame.Navigate(typeof(Offline)); }
        }
		public static void Register(FrameworkElement obj, DependencyProperty property, Action<object, object> changed)
		{
			if (helpers == null)
				helpers = new List<Helper>();

			var helper = new Helper(obj, property, changed, obj.GetValue(property));
			var binding = new Binding();
			binding.Path = new PropertyPath("Property");
			binding.Source = helper;
			binding.Mode = BindingMode.TwoWay;
			obj.SetBinding(property, binding);
			
			helpers.Add(helper);
		}
Ejemplo n.º 5
0
		private static void Game_OnGameLoad(EventArgs args)
		{
			//AutoUpdater.InitializeUpdater();
			Chat.Print("Ultimate Carry Version " + LocalVersion + " load ...");
			Helper = new Helper();

			Menu = new Menu("UltimateCarry", "UltimateCarry_" + ObjectManager.Player.ChampionName, true);

			var targetSelectorMenu = new Menu("Target Selector", "TargetSelector");
			SimpleTs.AddToMenu(targetSelectorMenu);
			Menu.AddSubMenu(targetSelectorMenu);
			if (ObjectManager.Player.ChampionName == "Azir")
			{
				var orbwalking = Menu.AddSubMenu(new Menu("AzirWalking", "Orbwalking"));
				Azirwalker = new Azir.Orbwalking.Orbwalker(orbwalking);
				Menu.Item("FarmDelay").SetValue(new Slider(125, 100, 200));
			}
			else
			{
				var orbwalking = Menu.AddSubMenu(new Menu("Orbwalking", "Orbwalking"));
				Orbwalker = new Orbwalking.Orbwalker(orbwalking);
				Menu.Item("FarmDelay").SetValue(new Slider(0, 0, 200));
			}
			var activator = new Activator();
			var potionManager = new PotionManager();
			var baseult = new BaseUlt();
			var bushRevealer = new AutoBushRevealer();
		//var overlay = new Overlay();
		
			try
			{
				// ReSharper disable once AssignNullToNotNullAttribute
				var handle = System.Activator.CreateInstance(null, "UltimateCarry." + ObjectManager.Player.ChampionName);
				Champion = (Champion) handle.Unwrap();
			}
			// ReSharper disable once EmptyGeneralCatchClause
			catch (Exception)
			{
				//Champion = new Champion(); //Champ not supported
			}
					
			Menu.AddToMainMenu();
			Chat.Print("Ultimate Carry loaded!");
		}
        /*oblicza trasę na podstawie otrzymanych współrzędnych
         * jesli waypointów mniej niż dwa informacja
         * w przeciwnym wypadku zapisz je na mapie
        */
        public void CalculateRoute(Microsoft.Phone.Controls.Maps.Map map, GeocodeService.GeocodeResult[] coordinates, Helper.MapResultReceived croute, TravelMode tm = TravelMode.Driving)
        {
            if (coordinates.Length < 2)
            {
                MessageBox.Show("Too small number od location: you need startPoint and endpoint at least");
                return;
            }
            try
            {
                MapResponseSendHere = new Helper.MapResultReceived(croute);
                routedMap = map;
                RouteService.RouteServiceClient routeService = new RouteService.RouteServiceClient("BasicHttpBinding_IRouteService");
                routeService.Endpoint.Binding.ReceiveTimeout = timeout;
                routeService.Endpoint.Binding.SendTimeout = timeout;
                routeService.Endpoint.Binding.OpenTimeout = timeout;

                RouteRequest routeRequest = new RouteRequest();
                {
                    routeRequest.Credentials = new Microsoft.Phone.Controls.Maps.Credentials() { ApplicationId = bingMapKey };
                    routeRequest.Options = new RouteService.RouteOptions()
                    { RoutePathType = RouteService.RoutePathType.Points, Mode = tm };
                }
                routeRequest.Waypoints = new System.Collections.ObjectModel.ObservableCollection<RouteService.Waypoint>();
                foreach (GeocodeService.GeocodeResult coord in coordinates)
                {
                    if (null != coord)
                    {
                        if (coordinates[coordinates.Length - 1] != coord) //jesli to ostatni punkt ustaw: MOBICA
                            routeRequest.Waypoints.Add(GeocodeToWaypoint(coord));
                        else
                            routeRequest.Waypoints.Add(GeocodeToWaypoint(coord, "MOBICA"));
                    }
                }

                routeService.CalculateRouteCompleted += (sender, e) => CalculateRouteCompleted(sender, e);
                routeService.CalculateRouteAsync(routeRequest, coordinates.Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An exception occurred: " + ex.Message);

            }
        }
Ejemplo n.º 7
0
 public override object[] CreateData()
 {
     var helperA = new Helper
         ("aaa");
     return new object[]
     {
         new STIdentityEvaluationTestCase
             (null),
         new STIdentityEvaluationTestCase
             (helperA),
         new STIdentityEvaluationTestCase
             (helperA),
         new STIdentityEvaluationTestCase
             (helperA),
         new STIdentityEvaluationTestCase
             (new HelperDerivate("bbb")),
         new STIdentityEvaluationTestCase
             (new Helper("dod"))
     };
 }
Ejemplo n.º 8
0
        public static string GetContractReference(Type type)
        {
            var attribs = type.GetCustomAttributes(false);
            var helper = new Helper(attribs);

            var s1 = Optional<string>.Empty;
            var name = s1
                .Combine(() => helper.GetString("ProtoContractAttribute", "Name"))
                .Combine(() => helper.GetString("DataContractAttribute", "Name"))
                .Combine(() => helper.GetString("XmlTypeAttribute", "TypeName"))
                .GetValue(type.Name);

            var ns = s1
                .Combine(() => helper.GetString("DataContractAttribute", "Namespace"))
                .Combine(() => helper.GetString("XmlTypeAttribute", "Namespace"))
                .Convert(s => s.Trim() + "/", "");

            ns = AppendNesting(ns, type);

            return ns + name;
        }
 protected virtual void OnItemDataLoaded(Helper.Item item)
 {
     if (item != null) {
         LayoutRoot.Children.Clear();
         this.Title = item.Entity.Title;
         if(item.Entity.Type.Equals("album")){
             G3Album album = new G3Album();
             List<G3Item> items = new List<G3Item>();
             item.Members.ForEach(delegate(string member)
             {
                 items.Add(new G3Item(member));
             });
             album.Items = items;
             LayoutRoot.Children.Add(album);
         }
         else if (item.Entity.Type.Equals("photo")) {
             LayoutRoot.Children.Add(new Content.G3Photo(item.Entity));
         }
         ItemDataEventArgs itemDataEventArgs = new ItemDataEventArgs(item.Entity, this.NavigationService.Source);
         this.ItemDataLoad(this, itemDataEventArgs);
     }
 }
Ejemplo n.º 10
0
        public static string GetContractReference(Type type)
        {
            var attribs = type.GetCustomAttributes(false);
            var helper = new Helper(attribs);

            var name = Combine(
                () => helper.GetString("ProtoContractAttribute", "Name"),
                () => helper.GetString("DataContractAttribute", "Name"),
                () => helper.GetString("XmlTypeAttribute", "TypeName"),
                () => type.Name);

            var ns = Combine(
                () => helper.GetString("DataContractAttribute", "Namespace"),
                () => helper.GetString("XmlTypeAttribute", "Namespace"));

            if (null != ns)
            {
                ns = ns.Trim() + '/';
            }

            ns = AppendNesting(ns, type);

            return ns + name;
        }
Ejemplo n.º 11
0
 public STIdentityEvaluationTestCase(Helper h)
 {
     helper = h;
 }
Ejemplo n.º 12
0
 private static void Game_OnGameLoad(EventArgs args)
 {
     Helper = new Helper();
     var baseult = new BaseUlt();
 }
Ejemplo n.º 13
0
 public static SQLServerExpressDatabaseLoader GetSqlServerExpressLoader(Helper.ConnectionStringHelper connectionStringHelper, string databaseName)
 {
     return new SQLServerExpressDatabaseLoader(new SQLServerExpressDatabaseConnector(connectionStringHelper, databaseName));
 }
Ejemplo n.º 14
0
		static TreeViewItem SelectTreeViewItemForBinding (Helper helper, ItemsControl ic, object dataItem)
		{
			if (ic == null || dataItem == null || !ic.HasItems)
				return null;
			IItemContainerGenerator generator = ic.ItemContainerGenerator;
			if (ic.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
			{
				foreach (var t in ic.Items)
				{
					var tvi = ic.ItemContainerGenerator.ContainerFromItem (t);
					if (t == dataItem)
						return tvi as TreeViewItem;

					var tmp = SelectTreeViewItemForBinding (dataItem, tvi as ItemsControl);
					if (tmp != null)
						return tmp;
				}
			}
			else
				using (generator.StartAt (generator.GeneratorPositionFromIndex (-1), GeneratorDirection.Forward))
				{
					foreach (var t in ic.Items)
					{
						bool isNewlyRealized;
						var tvi = generator.GenerateNext (out isNewlyRealized);
						if (isNewlyRealized)
						{
							generator.PrepareItemContainer (tvi);
						}
						if (t == dataItem)
							return tvi as TreeViewItem;

						var tmp = SelectTreeViewItemForBinding (dataItem, tvi as ItemsControl);
						if (tmp != null)
							return tmp;
					}
				}
			return null;
		}
Ejemplo n.º 15
0
 public static FirebirdDatabaseLoader GetFirebirdLoader(Helper.ConnectionStringHelper connectionStringHelper)
 {
     return new FirebirdDatabaseLoader(new FirebirdDatabaseConnector(connectionStringHelper));
 }
        private bool Initalize()
        {
            helper      = Helper.Initialize(solidWorks.IGetMathUtility());
            corpus      = new Locator(solidWorks.IGetMathUtility());
            shaft       = new Locator(solidWorks.IGetMathUtility());
            planeLocator     = new Locator(solidWorks.IGetMathUtility());
            prismLocator1    = new Locator(solidWorks.IGetMathUtility());
            prismLocator2    = new Locator(solidWorks.IGetMathUtility());

            document = solidWorks.ActiveDoc as IModelDoc2;
            assembly = document as IAssemblyDoc;

            if (assembly == null)
            {
                ShowMessage("Please, open document with assembly");
                return false;
            }

            horizont = assembly.IFeatureByName(TOP_PLANE_NAME_EN);
            horizont = horizont == null ? assembly.IFeatureByName(TOP_PLANE_NAME_RU) : horizont;
            loader = Loader.Initialize(solidWorks, assembly);
            mounter = Mounter.Initialize(document);
            Debug.WriteLine("loading of assembly ... done!");

            object[] components = assembly.GetComponents(true);
            foreach(IComponent2 component in components)
            {
                if (component.Name2.Contains(configuration[Property.MAIN_DETAIL_NAME]))
                {
                    shaft.Component = component;
                    Debug.WriteLine("shaft search ... done!");
                    break;
                }
            }

            if (shaft.Component == null)
            {
                ShowMessage("Please, add shaft to assembly or enter other/correct name");
                return false;
            }

            return true;
        }
Ejemplo n.º 17
0
 public static OracleDatabaseLoader GetOracleLoader(Helper.ConnectionStringHelper connectionStringHelper, string databaseName)
 {
     return new OracleDatabaseLoader(new OracleDatabaseConnector(connectionStringHelper, databaseName));
 }
Ejemplo n.º 18
0
 public static MySQLDatabaseLoader GetMySQLLoader(Helper.ConnectionStringHelper connectionStringHelper)
 {
     return new MySQLDatabaseLoader(new MySQLDatabaseConnector(connectionStringHelper));
 }
Ejemplo n.º 19
0
 public static PostgreSQLDatabaseLoader GetPostgreSQLLoader(Helper.ConnectionStringHelper connectionStringHelper, string databaseName)
 {
     return new PostgreSQLDatabaseLoader(new PostgreSQLDatabaseConnector(connectionStringHelper));
 }
        /* zamienia adres na współrzędne
         * poprzez wysłanie requestu i oczekiwanie na odpowiedź
         * @args:
         * address - string z adresem który bedzie zmianeiony na wspolrzedne
         * cr - funkcja ktora zostanie wywlana gdy przyjda wspolrzedne
         * counter - ktory event z kolei jest wysylany z requestem
        */
        public void Geocode(String address, Helper.GeocodeResultReceived cr, int counter)
        {
            GeocodeResponseSendHere.Add(counter, new Helper.GeocodeResultReceived(cr));
            GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

            GeocodeRequest geocodeRequest = new GeocodeRequest();
            {
                geocodeRequest.Credentials = new Credentials() { ApplicationId = bingMapKey };
                geocodeRequest.Query = address;
                geocodeRequest.Options = new GeocodeOptions()
                {
                    Filters = new System.Collections.ObjectModel.ObservableCollection<FilterBase>(),
                    Count = 1
                };

            };
            geocodeRequest.Options.Filters.Add(new ConfidenceFilter() { MinimumConfidence = Mobica.GeocodeService.Confidence.High });
            geocodeService.GeocodeAsync(geocodeRequest, counter);

            geocodeService.GeocodeCompleted += (sender, e) => GeocodeCompleted(sender, e);
        }
Ejemplo n.º 21
0
 public static Database LoadMySQLDatabase(Helper.ConnectionStringHelper connectionStringHelper, List<SchemaData> databaseObjectsToFetch)
 {
     return GetMySQLLoader(connectionStringHelper).LoadDatabase(databaseObjectsToFetch, null);
 }
 public ItemDataEventArgs(Helper.ItemEntity item, Uri source)
 {
     this.item = item;
     this.source = source;
 }
Ejemplo n.º 23
0
 void PacketReceived(Helper.Multiplayer.Packets.Packet p)
 {
     InputQueue.Enqueue(p);
 }
 public UploadShellExtension() {
     _helper = new Helper();
 }
Ejemplo n.º 25
0
		static Task<TreeViewItem> FindItem (object dataItem, ItemsControl ic)
		{
			var helper = new Helper { SelectedItem = dataItem };

			helper.Find (ic);

			return helper.Task;
		}
Ejemplo n.º 26
0
 internal void closeAndClear()
 {
     internalClose();
     helper = null;
 }
Ejemplo n.º 27
0
 public static SQLServer2005DatabaseLoader GetSQLServer2005Loader(Helper.ConnectionStringHelper connectionStringHelper)
 {
     return new SQLServer2005DatabaseLoader(new SQLServer2005DatabaseConnector(connectionStringHelper));
 }
Ejemplo n.º 28
0
		public static uint GetVirtualKeyCode(char c)
		{
			var helper = new Helper { Value = VkKeyScan(c) };

			byte virtualKeyCode = helper.Low;
			byte shiftState = helper.High;

			return virtualKeyCode;
		}
Ejemplo n.º 29
0
 public CoreConverter(Helper helper)
 {
     _h = helper;
 }
Ejemplo n.º 30
-1
		private static void Game_OnGameLoad(EventArgs args)
		{
			AutoUpdater.InitializeUpdater();

            Helper = new Helper();

			Menu = new Menu("UltimateCarry", "UltimateCarry_" + ObjectManager.Player.ChampionName, true);

			var targetSelectorMenu = new Menu("Target Selector", "TargetSelector");
			SimpleTs.AddToMenu(targetSelectorMenu);
			Menu.AddSubMenu(targetSelectorMenu);
			var orbwalking = Menu.AddSubMenu(new Menu("Orbwalking", "Orbwalking"));
			Orbwalker = new Orbwalking.Orbwalker(orbwalking);

			//var overlay = new Overlay();
			var potionManager = new PotionManager();
			var activator = new Activator();
            var bushRevealer = new AutoBushRevealer();

            new BaseUlt();
		
			try
			{
				var handle = System.Activator.CreateInstance(null, "UltimateCarry." + ObjectManager.Player.ChampionName);
				Champion = (Champion) handle.Unwrap();
			}
			catch (Exception)
			{
				//Champion = new Champion(); //Champ not supported
			}
					
			Menu.AddToMainMenu();
		}