Inheritance: MonoBehaviour
Esempio n. 1
0
        // This function execute Publish button event handler
        private void BtnPublish_Click(object sender, RoutedEventArgs e)
        {
            List <String> args = new List <string>();

            args.Add(System.IO.Path.GetFullPath("../../../../../" + txtPath.Text.ToString()));
            args.Add("/s");
            Patterns = txtPatterns.Text.ToString();
            args.AddRange(Patterns.Split(' '));
            args.Add(txtRegex.Text.ToString());
            string strArgs = "";

            foreach (var a in args)
            {
                strArgs += a.ToString() + "##";
            }
            List <String> resultFiles    = new List <String>();
            CsEndPoint    serverEndPoint = new CsEndPoint();

            string[] pcmd = Environment.GetCommandLineArgs();
            serverEndPoint.machineAddress = pcmd[1];
            serverEndPoint.port           = Int32.Parse(pcmd[2]);
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "convertFiles");
            msg.add("strArgs", strArgs);
            translater.postMessage(msg);
        }
        public double[] Classify(Instance instance)
        {
            if (Patterns == null || !Patterns.Any())
            {
                return(null);
            }
            if (!_isInitialized)
            {
                Initialize();
            }
            var matchedPattern = _filteredPatterns.Where(p => p.IsMatch(instance));

            if (!matchedPattern.Any())
            {
                return(null);
            }
            var selectedPatterns = SelectionPolicy.SelectPatterns(instance, matchedPattern);

            if (!selectedPatterns.Any())
            {
                return(null);
            }
            var votes = VotesAggregator.Aggregate(selectedPatterns);

            if (VotesNormalizer != null)
            {
                votes = VotesNormalizer.Normalize(votes);
            }
            return(votes);
        }
        private void Initialize()
        {
            if (!_isInitialized)
            {
                _filteredPatterns = Filters != null?
                                    Patterns.Where(p => Filters.All(f => f.PassFilter(p))).ToArray() :
                                        Patterns.ToArray();

                _data = new ClassifierData
                {
                    ClassFeature      = Patterns.First().ClassFeature,
                    TrainingInstances = TrainingInstances,
                    AllPatterns       = _filteredPatterns,
                };
                if (SelectionPolicy != null)
                {
                    SelectionPolicy.Data = _data;
                }
                if (VotesAggregator != null)
                {
                    VotesAggregator.Data = _data;
                }
                if (VotesNormalizer != null)
                {
                    VotesNormalizer.Data = _data;
                }
            }
            _isInitialized = true;
        }
Esempio n. 4
0
        public void TestIndexedValuePropOM()
        {
            var epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());

            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName);
            }

            var type = typeof(SupportBeanComplexProps).FullName;

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            PatternExpr pattern = Patterns.FollowedBy(Patterns.EveryFilter(type, "a"),
                                                      Patterns.Filter(Filter.Create(type, Expressions.EqProperty("Indexed[0]", "a.Indexed[0]")), "b"));

            model.FromClause = FromClause.Create(PatternStream.Create(pattern));
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            var patternText = "select * from pattern [every a=" + type + " -> b=" + type + "(Indexed[0]=a.Indexed[0])]";

            Assert.AreEqual(patternText, model.ToEPL());

            var stmt = epService.EPAdministrator.Create(model);

            RunIndexedValueProp(epService, stmt);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Esempio n. 5
0
            private IDictionary <string, int> GetDigitsForPatterns()
            {
                IDictionary <string, int> decodedPatterns = new Dictionary <string, int>();

                string one   = Patterns.First(x => x.Length == 2);
                string four  = Patterns.First(x => x.Length == 4);
                string seven = Patterns.First(x => x.Length == 3);
                string eight = Patterns.First(x => x.Length == 7);
                string three = Patterns.First(x => x.Length == 5 && ContainsNumberPattern(x, seven));
                string nine  = Patterns.First(x => x.Length == 6 && ContainsNumberPattern(x, three));
                string zero  = Patterns.First(x => x.Length == 6 && ContainsNumberPattern(x, seven) && x != nine);
                string six   = Patterns.First(x => x.Length == 6 && x != nine && x != zero);
                string five  = Patterns.First(x => x.Length == 5 && x != three && ContainsNumberPattern(six, x));
                string two   = Patterns.First(x => x.Length == 5 && x != three && x != five);

                decodedPatterns.Add(one, 1);
                decodedPatterns.Add(two, 2);
                decodedPatterns.Add(three, 3);
                decodedPatterns.Add(four, 4);
                decodedPatterns.Add(five, 5);
                decodedPatterns.Add(six, 6);
                decodedPatterns.Add(seven, 7);
                decodedPatterns.Add(eight, 8);
                decodedPatterns.Add(nine, 9);
                decodedPatterns.Add(zero, 0);

                return(decodedPatterns);
            }
Esempio n. 6
0
        public List <MatchResult> Match(RootUst ust)
        {
            try
            {
                IEnumerable <PatternRoot> patterns = Patterns
                                                     .Where(pattern => pattern.Languages.Any(patternLang => ust.Sublanguages.Contains(patternLang)));
                if (!IsIgnoreFilenameWildcards)
                {
                    patterns = patterns.Where(pattern => pattern.FilenameWildcardRegex?.IsMatch(ust.SourceFile.FullName) ?? true);
                }

                var parentStack = new List <Ust>();

                var result = new List <MatchResult>();
                foreach (PatternRoot pattern in patterns)
                {
                    pattern.Logger = Logger;
                    var results = pattern.Match(ust, UstConstantFolder, parentStack);
                    result.AddRange(results);
                }

                return(result);
            }
            catch (Exception ex) when(!(ex is ThreadAbortException))
            {
                Logger.LogError(new MatchingException(ust.SourceFile, ex));
                return(new List <MatchResult>());
            }
        }
        private void AddPattern()
        {
            PatternModel model = new PatternModel(PatternKind == "Include" ? EntryKind.Include : EntryKind.Exclude, CurrentPattern, Patterns.Count.ToString(), Patterns, () => _watcher);

            model.Pattern = _watcher?.AddPattern(model.Kind, model.RawPattern);
            Patterns.Add(model);
        }
Esempio n. 8
0
 public Pattern(string pName, Patterns pType, double pStrength, string pComments)
 {
     Name     = pName;
     Type     = pType;
     Strength = pStrength;
     Comments = pComments;
 }
Esempio n. 9
0
        static async Task Main(string[] args)
        {
            // NOTE: Comment / Uncomment demoes as desired

            await AsyncIterators.Demo();

            DefaultInterfaceMembers.Demo();

            IndicesAndRanges.Demo1();
            IndicesAndRanges.Demo2();
            IndicesAndRanges.Demo3();
            IndicesAndRanges.Demo4();
            IndicesAndRanges.Demo5();

            NullableTypes.Demo();

            Patterns.Demo1();
            Patterns.Demo2();

            ReadOnlyMembers.Demo1();
            ReadOnlyMembers.Demo2();

            StaticLocalFunctions.Demo1();
            StaticLocalFunctions.Demo2();

            SwitchExpressions.Demo1();
            SwitchExpressions.Demo2();

            UsingStatement.Demo1();
            UsingStatement.Demo2();

            Console.ReadKey();

            await Task.CompletedTask;
        }
Esempio n. 10
0
        public void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e) //По таймеру человек думает и делает дела
        {
            if (Program.isOnPause == false && Program.Window == 0 && Man.CurHealth > 0)
            {
                //Man.Heal(Man.Regeneration); // Можно конечно создать дополнительный таймер, но пусть пока будет так

                // Task Warden = new Task(() => { WardenStyle(); });
                // Warden.Start();//Промеряем местность на наличие врагов
                WardenStyle();
                if (targets.Count > 0)
                {
                    CurPattern = Patterns.SeekAndDestroy;
                }

                if (CurPattern == Patterns.SeekAndDestroy)
                {
                    Fight();
                }
                if (CurPattern == Patterns.Rest)
                {
                }
                if (CurPattern == Patterns.Explore)
                {
                }

                Moving();
            }
        }
Esempio n. 11
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Patterns.Any())
     {
         writer.WritePropertyName("patterns");
         writer.WriteStartArray();
         foreach (var item in Patterns)
         {
             writer.WriteStringValue(item);
         }
         writer.WriteEndArray();
     }
     else
     {
         writer.WriteNull("patterns");
     }
     if (PreserveOriginal != null)
     {
         writer.WritePropertyName("preserveOriginal");
         writer.WriteBooleanValue(PreserveOriginal.Value);
     }
     writer.WritePropertyName("@odata.type");
     writer.WriteStringValue(ODataType);
     writer.WritePropertyName("name");
     writer.WriteStringValue(Name);
     writer.WriteEndObject();
 }
Esempio n. 12
0
        /// <summary>
        /// Implemented by concrete subclasses, this performs the final conversion from a non-null JSON value to
        /// a value of type T.
        /// </summary>
        /// <param name="reader">The JSON reader to pull data from</param>
        /// <param name="serializer">The serializer to use for nested serialization</param>
        /// <returns>The deserialized value of type T.</returns>
        protected override Instant ReadJsonImpl(JsonReader reader, JsonSerializer serializer)
        {
            if (reader.TokenType != JsonToken.String)
            {
                throw new InvalidNodaDataException(
                          $"Unexpected token parsing {typeof(Instant).Name}. Expected String, got {reader.TokenType}.");
            }
            string text = reader.Value.ToString();

            var mainResult = Patterns
                             .Select(x => x.Parse(text))
                             .FirstOrDefault(z => z.Success);

            if (mainResult?.Success == true)
            {
                return(mainResult.Value);
            }

            var secondaryResult = AlternatePatterns
                                  .Select(z => z.Parse(text))
                                  .FirstOrDefault(z => z.Success);

            if (secondaryResult?.Success == true)
            {
                return(secondaryResult.Value.ToInstant());
            }
            return(Patterns.First().Parse(text).Value);
        }
Esempio n. 13
0
        public void Normalize()
        {
            switch (Type)
            {
            case CroInfoType.Default:
            {
                if (Patterns == null || Patterns.Length == 0 || Patterns.Contains("*.nupkg"))
                {
                    Patterns = new string[] { "*.exe", "*.dll" };
                }
                if (string.IsNullOrEmpty(Partial) || Partial == "[nuget]")
                {
                    Partial = "Programs";
                }
                break;
            }

            case CroInfoType.Ignore:
            {
                Patterns  = new string[0];
                Partial   = string.Empty;
                AddToPath = false;
                break;
            }

            case CroInfoType.NuGet:
            {
                Patterns  = new string[] { "*.nupkg" };
                Partial   = "[nuget]";
                AddToPath = false;
                break;
            }
            }
        }
Esempio n. 14
0
        public override bool Execute()
        {
            Patterns = Regex.Replace(Patterns, @"\s+", ""); //remove whitespce
            Patterns = FixFilePath(Patterns);               //DirecotrySeparator Fix

            string[] patternList =
                Patterns.Split(new string[] { "\n", "\r\n", ";" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string _pattern in patternList)
            {
                string p = "(^|[\\\\]|[/])"
                           + Regex.Escape(_pattern)
                           .Replace("\\*\\*", ".*")
                           .Replace("\\*", "[^\\\\/]*")
                           .Replace("\\?", "[^\\\\/]?")
                           + "$";

                Log.LogMessage(MessageImportance.Low, "Pattern {0}", p);

                foreach (ITaskItem item in List)
                {
                    if (Regex.IsMatch(item.ItemSpec, p))
                    {
                        Log.LogMessage(MessageImportance.Low, "Found {0}", item.ItemSpec);

                        if (!_matchList.Contains(item))
                        {
                            _matchList.Add(item);
                        }
                    }
                }
            }

            return(true);
        }
        public SimpleFlatFieldDefinition[] GetColumns(int length)
        {
            Column[] expliciteColumns = ExpliciteColumns;
            if (Pattern == null && expliciteColumns == null)
            {
                throw new DataHolderException(
                          "Array-field \"{0}\" had no Pattern NOR an explicit set of Columns - Make sure either of them are set and valid.",
                          this);
            }
            if (Pattern != null && expliciteColumns != null)
            {
                throw new DataHolderException(
                          "Array-field \"{0}\" defined Pattern AND an explicit set of Columns - Make sure to only specify one.",
                          (object)this);
            }
            if (Pattern != null)
            {
                List <SimpleFlatFieldDefinition> flatFieldDefinitionList = new List <SimpleFlatFieldDefinition>();
                for (int offset = Offset; offset < Offset + length; ++offset)
                {
                    flatFieldDefinitionList.Add(new SimpleFlatFieldDefinition(Table,
                                                                              Patterns.Compile(Pattern, offset)));
                }
                return(flatFieldDefinitionList.ToArray());
            }

            length = expliciteColumns.Length;
            SimpleFlatFieldDefinition[] flatFieldDefinitionArray = new SimpleFlatFieldDefinition[length];
            for (int index = 0; index < length; ++index)
            {
                flatFieldDefinitionArray[index] =
                    new SimpleFlatFieldDefinition(expliciteColumns[index].Table, expliciteColumns[index].Name);
            }
            return(flatFieldDefinitionArray);
        }
        /// <summary>
        /// Applies the rule.
        /// </summary>
        /// <returns>The rule.</returns>
        /// <param name="sentence">Sentence.</param>
        public override string ApplyRule(string sentence)
        {
            Patterns.Add(_dateTextFormatPattern);
            Patterns.Add(_dateNumericFormatPattern);

            return(base.ApplyRule(sentence));
        }
Esempio n. 17
0
        // -----------< Helper Function - Assemble message for posting >------------
        private CsMessage AssembleMsg()
        {
            CsMessage msg = new CsMessage();

            msg.add("SubDir", SubDir);
            msg.add("Directory", WDirectory);
            msg.add("path", WDirectory);
            //msg.add("OutputPath", OutputPath);
            for (int i = 0; i < Patterns.Count(); i++)
            {
                msg.add("Pattern" + (i + 1), Patterns[i]);
            }
            for (int i = 0; i < Regexes.Count(); i++)
            {
                msg.add("Regex" + (i + 1), Regexes[i]);
            }
            if (Analysers != null)
            {
                for (int i = 0; i < Analysers.Count(); i++)
                {
                    msg.add("Analyser" + (i + 1), Analysers[i]);
                }
            }
            return(msg);
        }
Esempio n. 18
0
 public AlignGroup(string name, int leading_space, params AlignPattern[] patterns)
     : this()
 {
     Name         = name;
     LeadingSpace = leading_space;
     Patterns.AddRange(patterns);
 }
Esempio n. 19
0
        public void ThenUserShouldClickOnDownloadLinkForDownloadingPdfFile()
        {
            try
            {
                SelectBrowser.driver.SwitchTo().Window(SelectBrowser.driver.WindowHandles.Last());
                //Assert.IsTrue(SelectBrowser.driver.Url.Contains("w9form"));
                using (var session = Sikuli.CreateSession())
                {
                    var down_text   = Patterns.FromFile(@"C:\Users\Anuruddha.Tiwari\source\repos\ThomasNetProject\ThomasNetProject\Images\DownloadButton.PNG", 0.9f);
                    var save_button = Patterns.FromFile(@"C:\Users\Anuruddha.Tiwari\source\repos\ThomasNetProject\ThomasNetProject\Images\SaveButton.PNG", 0.9f);
                    session.Wait(down_text, 500);
                    session.Click(down_text);
                    test.Log(Status.Pass, "User Clicks on the Download Button");
                    session.Wait(save_button, 500);
                    session.Click(save_button);
                    test.Log(Status.Pass, "User Clicks on the Save Button");
                }

                //Assert.IsTrue(PDFReaderP.ExtractPDF(@"C:\Users\ankit.kansal\Downloads\ReconReport_V9.pdf").Contains("Account"));
            }
            catch (AssertFailedException ex)
            {
                Console.WriteLine("Exception==>" + ex);
                ScreenshotPage.TakesScreenshotWithDate(@"Screesnhot", System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Esempio n. 20
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns>
        public bool Equals(PatternPropertiesKeyword?other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (Patterns.Count != other.Patterns.Count)
            {
                return(false);
            }
            var byKey = Patterns.Join(other.Patterns,
                                      td => td.Key.ToString(),
                                      od => od.Key.ToString(),
                                      (td, od) => new { ThisDef = td.Value, OtherDef = od.Value })
                        .ToList();

            if (byKey.Count != Patterns.Count)
            {
                return(false);
            }

            return(byKey.All(g => Equals(g.ThisDef, g.OtherDef)));
        }
Esempio n. 21
0
        public bool Exists(string image)
        {
            var imageObject = Patterns.FromFile(_pathToProject + image);

            Log.Info(String.Format("{0} : exist", image));
            return(_session.Exists(imageObject));
        }
Esempio n. 22
0
        public void Click(string image)
        {
            var imageObject = Patterns.FromFile(_pathToProject + image);

            _session.Click(imageObject);
            Log.Info(String.Format("{0} : click", image));
        }
Esempio n. 23
0
        void sendArgs()
        {
            Regex    = txtRegex.Text;
            Patterns = txtPatterns.Text;
            List <String> args = new List <string>();

            args.Add("prog.exe");
            if (wDirectory != null)
            {
                args.Add(wDirectory);
            }
            if (cbRecurse.IsChecked.HasValue)
            {
                args.Add("/s");
            }
            if (Regex != null)
            {
                args.AddRange(Regex.Split(' '));
            }
            if (Patterns != null)
            {
                args.AddRange(Patterns.Split(' '));
            }
            shim.SendCmd(args);
            args.Clear();
        }
Esempio n. 24
0
        public void Hover(string image)
        {
            var imageObject = Patterns.FromFile(_pathToProject + image);

            _session.Hover(imageObject);
            Log.Info(String.Format("{0} : hover", image));
        }
Esempio n. 25
0
        // solves equation f(sin(x), cos(x), tan(x), cot(x)) for x
        internal static bool TrySolveLinear(Entity expr, Variable variable, out Set res)
        {
            res = Empty;
            var replacement = Variable.CreateTemp(expr.Vars);

            expr = expr.Replace(Patterns.NormalTrigonometricForm);
            expr = expr.Replace(Patterns.TrigonometricToExponentialRules(variable, replacement));
            MultithreadingFunctional.ExitIfCancelled();
            // if there is still original variable after replacements,
            // equation is not in a form f(sin(x), cos(x), tan(x), cot(x))
            if (expr.ContainsNode(variable))
            {
                return(false);
            }

            if (AnalyticalEquationSolver.Solve(expr, replacement) is FiniteSet els)
            {
                MultithreadingFunctional.ExitIfCancelled();
                res = (Set)els.Select(sol => MathS.Pow(MathS.e, MathS.i * variable).Invert(sol, variable).ToSet()).Unite().InnerSimplified;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 26
0
 private void TxtPath_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (lstFiles != null)
     {
         lstFiles.Items.Clear();
         lstFiles.Items.Add("[..]");
         var dirs = Directory.GetDirectories(wDirectory);
         foreach (var dir in dirs)
         {
             string dirName = "{" + Path.GetFileName(dir) + "}";
             lstFiles.Items.Add(Path.GetFileName(dirName));
         }
         List <string> filesMatchingPattern = new List <string>();
         if (Patterns != null && filesMatchingPattern.Count() != 0)
         {
             var patterns = Patterns.Split(' ');
             foreach (var patt in patterns)
             {
                 filesMatchingPattern.AddRange(Directory.GetFiles(wDirectory, patt));
             }
         }
         else
         {
             filesMatchingPattern = Directory.GetFiles(wDirectory).ToList();
         }
         foreach (var file in filesMatchingPattern)
         {
             lstFiles.Items.Add(Path.GetFileName(file));
         }
     }
 }
        public void Validate_Multiple_Email_Enteries(string email)
        {
            Patterns pattern = new Patterns();
            string   result  = pattern.ValidateEmail(email);

            Assert.AreEqual("Valid", result);
        }
Esempio n. 28
0
 public AlignGroup(XElement node)
     : this()
 {
     Name         = node.Element(nameof(Name)).As <string>();
     LeadingSpace = node.Element(nameof(LeadingSpace)).As <int>();
     Patterns.AddRange(node.Elements(nameof(Patterns), nameof(AlignPattern)).Select(x => x.As <AlignPattern>()));
 }
Esempio n. 29
0
        public void CanCreateNewProjectWithPatterns()
        {
            var pattern = Patterns.DbCreate();

            Shell.Navigate <EditProjectViewModel>(null);

            UnderTest.Project = new Project
            {
                Name        = "Name",
                Description = "Description"
            };

            UnderTest.UpdatePatternsCommand.Execute(null);
            NavigatesTo <UpdateProjectPatternsViewModel>(UnderTest.PatternSelectionDto);

            var updateProjectPatternsVm = Instance <UpdateProjectPatternsViewModel>();

            updateProjectPatternsVm.PatternSelections = updateProjectPatternsVm.PatternSelections.Select(ps =>
            {
                ps.IsSelected = true;
                return(ps);
            }).AsObservable();

            updateProjectPatternsVm.ConfirmCommand.Execute(null);

            Assert.True(UnderTest.Project.PatternProjects.Any());

            UnderTest.SaveCommand.Execute(null);

            var entries = _projectRepository.GetAll();

            HasEntries <Project>(1);
            HasEntries <PatternProject>(1);
            HasEntries <Pattern>(1);
        }
Esempio n. 30
0
        //------<Publish button to publish the converted files>-----//

        private void btnPublish_Click(object sender, RoutedEventArgs e)
        {
            List <string> args = new List <string>();

            args.Add("PUB_WPF.exe");
            args.Add(WDirectory);
            if (cbRecurse.IsChecked.HasValue)    //Recusring through the values
            {
                args.Add("/s");
            }
            args.AddRange(Patterns.Split(' '));
            args.AddRange(Regex.Split(' '));
            shim = new Shim();
            List <string> final_list = new List <string>();

            final_list = shim.SendCmd(args);      // obtaining a list of converted files after arguments has been sent
            foreach (var v in final_list)
            {
                listConverted.Items.Add(v);
            }
            int i = 0;

            foreach (var file in final_list)
            {
                if (i < 2)               // displays a maximum of 2 converted files when published
                {
                    System.Diagnostics.Process x = new System.Diagnostics.Process();
                    x.StartInfo.FileName = file;
                    x.Start();     //displaying the converted files
                    x.WaitForExit();
                }
                i = i + 1;
            }
        }
 void target_CopyFileComplete(object sender, Patterns.WorkItemEventArgs<CopyFileWorkItem> e)
 {
     if (e.WorkItem.FailedReason != null)
     {
         lock (this)
         {
             FailedWorkItems.Add(e.WorkItem);
         }
     }
 }
		/// <summary>
		/// Constructs the pattern list on the right panel
		/// </summary>
		public void BuildPatternMenus () {
			Patterns p = new Patterns();
			//Regional Patterns
			p.CreateRegionalPatterns();
			listBoxRegionalPatternMenu.ItemsSource = p;

			//Recursive ones
			p = new Patterns();
			p.CreateRecursivePatterns();
			listBoxRecursivePatternMenu.ItemsSource = p;

			//Structured
			p = new Patterns();
			p.CreateStructuredPatterns();
			listBoxStructuredPatternMenu.ItemsSource = p;

			//Special patterns
			p = new Patterns();
			p.CreateSpecialPatterns();
			listBoxSpecialPatternMenu.ItemsSource = p;
		}
Esempio n. 33
0
    //         public  void CreateRoad(string patternFile)
    //         {
    //             _road = new string[100 * 10];
    //             int length = 0;
    //             Patterns pat = new Patterns();
    //             pat.ReadPatternsFile(patternFile);
    //             string bottomSlot = pat.GetSlotRandom();
    //             for (int i = 0; i < 100; i++)
    //             {
    //                 string[] pattern = pat.GetPatternRandomWithBottomSlot(bottomSlot);
    //                 for (int j = 0; j < 10; ++j)
    //                 {
    //                     _road[length++] = pattern[j];
    //                 }
    //                 bottomSlot = _road[length-1];
    //             }
    //         }
    public string[] CreateRoad()
    {
        string bottomSlot = "@@@@OO";
            int length = 0;
            for (int i = 0; i < _levelLength.Count(); ++i)
            {
                Patterns pat = new Patterns();
                pat.ReadPatternsFile(Application.dataPath + "/" + _patternFileName[i]);
                for (int j = 0; j < _levelLength[i]; j++)
                {
                    string[] pattern = pat.GetPatternRandomWithBottomSlot(bottomSlot);
                    for (int k = 0; k < 10; k++)
                    {
                        _road[length++] = pattern[k];
                    }
                    bottomSlot = _road[length - 1];

                }
            }
            return _road;
    }
 void target_CopyFileStart(object sender, Patterns.WorkItemEventArgs<CopyFileWorkItem> e)
 {
     using (new WriterLock(inProgressWorkItemsLock, -1))
     {
         inProgressWorkItems.Add(e.WorkItem);
     }
 }
        void target_CopyFileComplete(object sender, Patterns.WorkItemEventArgs<CopyFileWorkItem> e)
        {
            FileInfo fi = e.WorkItem.Item as FileInfo;
            using (new WriterLock(inProgressWorkItemsLock, -1))
            {
                inProgressWorkItems.Remove(e.WorkItem);
            }

            if (fi != null)
            {
                lock (this)
                {
                    CompletedSize += fi.Length;
                }
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Recognizes the <see cref="StringPattern"/> of the specified string.
        /// </summary>
        /// <param name="value">The string to be recognized.</param>
        /// <returns>The recognized <see cref="StringPattern"/> object.</returns>
        public static StringPattern Recognize(string value) {
            var pattern = Patterns.AllCapitalLetter |
                          Patterns.AllLowerCaseLetter |
                          Patterns.AllDigit |
                          Patterns.AllLetters;

            var digits = 0;
            for (var i = 0; i < value.Length; i++) {
                var c = char.GetUnicodeCategory(value[i]);

                var isLetter = c == UnicodeCategory.UppercaseLetter ||
                               c == UnicodeCategory.LowercaseLetter ||
                               c == UnicodeCategory.TitlecaseLetter ||
                               c == UnicodeCategory.ModifierLetter ||
                               c == UnicodeCategory.OtherLetter;

                if (isLetter) {
                    pattern |= Patterns.ContainsLetters;
                    pattern &= ~Patterns.AllDigit;


                    if (c == UnicodeCategory.UppercaseLetter) {
                        if (i == 0) {
                            pattern |= Patterns.InitialCapitalLetter;
                        }
                        pattern |= Patterns.ContainsUpperCase;
                        pattern &= ~Patterns.AllLowerCaseLetter;
                    } else {
                        pattern &= ~Patterns.AllCapitalLetter;
                    }
                } else {
                    // contains chars other than letter, this means
                    // it can not be one of these:

                    pattern &= ~Patterns.AllLetters;
                    pattern &= ~Patterns.AllCapitalLetter;
                    pattern &= ~Patterns.AllLowerCaseLetter;

                    if (c == UnicodeCategory.DecimalDigitNumber) {
                        pattern |= Patterns.ContainsDigit;
                        digits++;
                    } else {
                        pattern &= ~Patterns.AllDigit;
                    }

                    switch (value[i]) {
                        case ',':
                            pattern |= Patterns.ContainsComma;
                            break;
                        case '.':
                            pattern |= Patterns.ContainsPeriod;
                            break;
                        case '/':
                            pattern |= Patterns.ContainsSlash;
                            break;
                        case '-':
                            pattern |= Patterns.ContainsHyphen;
                            break;
                    }
                }
            }
            return new StringPattern(pattern, digits);
        }
Esempio n. 37
0
	// Use this for initialization
	void Start () {
        pattern = this.gameObject.GetComponent<Patterns>();
		data = this.gameObject.GetComponent<FireData>();
	}
Esempio n. 38
0
 private StringPattern(Patterns pattern, int digits) {
     this.pattern = pattern;
     this.digits = digits;
 }