private bool ReadFragments() { if (Header.HasFlag(PacketHeaderFlags.BlobFragments)) { while (DataReader.BaseStream.Position != DataReader.BaseStream.Length) { try { var fragment = new ClientPacketFragment(); if (!fragment.Unpack(DataReader)) { return(false); } Fragments.Add(fragment); } catch (Exception) { // corrupt packet return(false); } } } return(true); }
public void MergeFieldAndFragment() { var fragment = new FragmentDefinition(new NameNode("fragment")); var fragmentSelection = new SelectionSet(); fragmentSelection.Add(FirstTestField); fragment.SelectionSet = fragmentSelection; fragment.Type = new GraphQL.Language.AST.NamedType( new NameNode("Person")); var fragments = new Fragments { fragment }; var schema = new Schema(); schema.RegisterType(new PersonType()); var context = new ExecutionContext { Fragments = fragments, Schema = schema }; var fragSpread = new FragmentSpread(new NameNode("fragment")); var outerSelection = new SelectionSet(); outerSelection.Add(fragSpread); outerSelection.Add(SecondTestField); var fields = ExecutionHelper.CollectFields( context, new PersonType(), outerSelection); fields.ShouldHaveSingleItem(); fields["test"].SelectionSet.Selections.ShouldContain(x => x.IsEqualTo(FirstInnerField)); fields["test"].SelectionSet.Selections.ShouldContain(x => x.IsEqualTo(SecondInnerField)); }
void Update() { UpdateTimerUI(); ChangeCursorLock(); if (scoreMaximoSalvo != PlayerPrefs.GetInt(levelIndex + "Stars")) { scoreMaximoSalvo = PlayerPrefs.GetInt(levelIndex + "Stars"); } _txtFragments.text = Fragments.ToString(); if (completeLevelUI.activeSelf == true) { if (Input.GetButtonDown("A")) { print("A"); } if (Input.GetButtonDown("X")) { print("x"); } if (Input.GetButtonDown("B")) { print("B"); } if (Input.GetButtonDown("Y")) { print("Y"); } } }
public void CreateFragments(int count = 1) { for (int i = 0; i < count; i++) { Fragments.Add(new Fragment()); } }
// Given a particular clue string (e.g. A-B-C) for the document, record it; This clue constraints a fragment scope for that particular document // Input clue stirng can be in any order (e.g. C-A-B) public void AddDocumentClue(string clue, Document doc) { // Lower case is required clue = clue.ToLower(); // Condition on quantity of fragments List <string> fragments = ClueHelper.SeperateClueFragments(clue); // Add to all collection Clue addedOrExisting = ClueSet.Add(clue); // Add to scope if (fragments.Count > 1) { FragmentScopes.Add(addedOrExisting, doc); } // Add to fragments foreach (string fragment in fragments) { if (Fragments.ContainsKey(fragment)) { Fragments[fragment].Documents.Add(doc); } else { Fragments[fragment] = new FragmentInfo(fragment, doc); } Fragments[fragment].FullClues.Add(addedOrExisting); } }
public void HandleData(MemBlock b, ISender return_path, object state) { //Read the header: uint crc32 = (uint)NumberSerializer.ReadInt(b, 0); int id = NumberSerializer.ReadInt(b, 4); ushort block = (ushort)NumberSerializer.ReadShort(b, 8); MemBlock data = b.Slice(10); var cachekey = new Triple <uint, int, ushort>(crc32, id, block); MemBlock packet = null; lock (_sync) { if (false == _fragments.Contains(cachekey)) { //This is a new block: _fragments.Add(cachekey, data); var fc_key = new Pair <uint, int>(crc32, id); Fragments this_fc; if (false == _frag_count.TryGetValue(fc_key, out this_fc)) { this_fc = new Fragments(); _frag_count.Add(fc_key, this_fc); } if (this_fc.AddBlock(block)) { //We have all of them, decode and clean up: packet = DecodeAndClear(crc32, id, (ushort)this_fc.Total); } } } if (null != packet) { Handle(packet, new FragmentingSender(DEFAULT_SIZE, return_path)); } }
/// <summary> /// Given a fragment, find whether or not it matches any existing fragments - either partial or completely; Return all matches /// Partial means anywhere, not just beginning characters; Return value can exclude exact match of partialFragment, if specifed /// </summary> /// <param name="partialFragment"></param> /// <param name="partialMatches"></param> /// <param name="bExcludeSearch"></param> /// <returns></returns> private bool TryGetFragmentFromPartialString(string partialFragment, out List <FragmentInfo> partialMatches, bool bExcludeSearch = false) { partialMatches = new List <FragmentInfo>(); if (Fragments.ContainsKey(partialFragment)) { partialMatches.Add(Fragments[partialFragment]); } else { foreach (KeyValuePair <string, FragmentInfo> entry in Fragments) { if (entry.Key.Contains(partialFragment) == true) { if (bExcludeSearch == true && partialFragment == entry.Key) { continue; } else { partialMatches.Add(entry.Value); } } } } if (partialMatches.Count != 0) { return(true); } else { partialMatches = null; return(false); } }
void ValidateAllFragmentsHasValue() { if (Fragments.Any(fragment => !fragment.HasValue)) { _errorMessages.Add("Message contain one or more hashes with missing number in front or after"); } }
public override IList <ValidationResult> Execute(SchemaFile file) { // When there are no parameters for these types default will be used, default scale is 0 so flag it return(Fragments .Where(x => (x.SqlDataTypeOption == SqlDataTypeOption.Decimal || x.SqlDataTypeOption == SqlDataTypeOption.Numeric) && !x.Parameters.Any()) .ToValidationResults()); }
public void Build() { var deserializer = new DeserializerBuilder().Build(); var serializer = new SerializerBuilder().Build(); var services = new List <KeyValuePair <YamlNode, YamlNode> >(); var volumes = new List <KeyValuePair <YamlNode, YamlNode> >(); foreach (var doc in Fragments.Select(f => ParseDocument(f))) { if (doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot) { services.AddRange(fragmentServicesRoot.Children); } if (doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot) { volumes.AddRange(fragmentVolumesRoot.Children); } } YamlMappingNode output = new YamlMappingNode(); output.Add("version", new YamlScalarNode("3") { Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted }); output.Add("services", new YamlMappingNode(Merge(services))); output.Add("volumes", new YamlMappingNode(volumes)); var result = serializer.Serialize(output); var outputFile = GetFilePath(); File.WriteAllText(outputFile, result.Replace("''", "")); }
public void TestCarAddWithFragmentWithVariables() { Car car = new Car { Active = true, Purchase = DateTime.Parse("02/01/1999"), Time = TimeSpan.Parse("13:14:55"), Title = "Car One", Value = 10000M, Id = 0 }; var fragmentType = new FragmentType("fields", "car_type"); var fragments = new Fragments(new Fragment(new QueryType(fragmentType, new Fields(new Field("id"), new Field("title"), new Field("active"))))); var arguments = new Arguments(new Argument(new Parameter("input"))); var variables = new Variables("getCar", new Variable <object>("input", car, "car_input")); var queryTypes = new QueryType("car_add", new Fields(new Field(fragmentType)), arguments); TypeQL typeQL = new TypeQL(variables, fragments, queryTypes); var text = typeQL.ToBodyJson(); //var textComplete = typeQL.ToStringJson(); var varDic = typeQL.Variables.ToDictionary(); IExecutionResult result = RequestExecutor.Execute(text, varDic); var json = result.ToJson(); Assert.IsNull(result.Errors); }
/// <summary> /// Given a seuqnece of phrases, generate suggestions about potential fragments that can together form a valid fragment group /// Or if it doesn't belong any fragment group (i.e. it's a standalone fragment), just return informaion about itself /// </summary> /// <param name="keyPhrases"></param> /// <param name="nextClues"></param> /// <param name="foundDocuments"></param> private void FindPotentialGroupFragments(string[] keyPhrases, out List <ClueFragment> nextClues, out List <Document> foundDocuments) { nextClues = null; foundDocuments = null; List <string> companionFragments = GetPotentialGroupFragments(keyPhrases); if (companionFragments != null) { // Generate return results nextClues = new List <ClueFragment>(); foreach (string fragment in companionFragments) { HashSet <Document> relatedDocuments = Fragments[fragment].Documents; nextClues.Add(new ClueFragment(fragment, relatedDocuments.Count, fragment, relatedDocuments.ToList())); } } else { if (keyPhrases.Length == 1 && Fragments.ContainsKey(keyPhrases[0])) { foundDocuments = Fragments[keyPhrases[0]].Documents.ToList(); } } }
private void ValidateAllFragmentsHasValidValue() { if (Fragments.Any(fragment => !fragment.IsValid)) { ErrorMessages.Add("Message contain one or more hashes with missing number in front."); } }
/// <summary> /// A fragment transition animation has ended. /// </summary> /// <param name="enter">if set to <c>true</c> a new fragment has entered.</param> public void FragmentAnimationEnded(bool enter) { if (enter) { var oldFragment = Fragments.Count > 1 ? Fragments[Fragments.Count - 2] : null; var newFragment = Fragments.Last(); if (oldFragment != null) { oldFragment.OnFragmentDidHide(); oldFragment.View.Visibility = ViewStates.Invisible; } newFragment.OnFragmentDidShow(); } else { var newFragment = Fragments.Count > 1 ? Fragments[Fragments.Count - 2] : null; var oldFragment = Fragments.Last(); oldFragment.OnFragmentDidHide(); newFragment?.OnFragmentDidShow(); Fragments.Remove(Fragments.Last()); } InFragmentTransition = false; }
//#region Deprecated Dctionary<string, ClueNode> Clue(Tree) construct //public void AddDocumentToClue(string clue, Document doc) //{ // string[] clueFragments = SeperateClueFragments(clue); // if (Clues.ContainsKey(clueFragments[0]) == false) // Clues[clueFragments[0]] = new ClueNode(); // Clues[clueFragments[0]].AddDocument(clueFragments, 0, doc); //} //public List<Document> GetDocumentsFromClue(string clue) //{ // string[] clueFragments = SeperateClueFragments(clue); // return GetDocumentsFromPhrases(clueFragments); //} //public List<Document> GetDocumentsFromPhrases(string[] cluePhrases) //{ // if (Clues.ContainsKey(cluePhrases[0]) != false) // return Clues[cluePhrases[0]].GetDocuments(cluePhrases, 0); // else // return null; //} //public ClueNode GetClueNodeFromPhrases(string[] cluePhrases) //{ // if (Clues.ContainsKey(cluePhrases[0]) != false) // return Clues[cluePhrases[0]].GetNode(cluePhrases, 0); // else // return null; //} //public List<ClueNode> GetClueNodeFromPartialPhrase(string[] cluePhrases) // Compared with GetClueNodeFromPhrases(), this function doesn't assume the last keyword phrase to be exact //{ // // Make a partial copy // string[] partialPhrases = null; // Array.Copy(cluePhrases, partialPhrases, cluePhrases.Length - 1); // // Get node up till that partial copy // ClueNode node = null; // if (Clues.ContainsKey(partialPhrases[0]) != false) // node = Clues[partialPhrases[0]].GetNode(partialPhrases, 0); // else // return null; // // Check result // if (node != null) // { // // Find partial matches // List<ClueNode> partialMatches = new List<ClueNode>(); // string partialPhrase = cluePhrases[cluePhrases.Length - 1]; // foreach (KeyValuePair<string, ClueNode> entry in node.Children) // { // if(entry.Key.IndexOf(partialPhrase) == 0) // partialMatches.Add(entry.Value); // } // if (partialMatches.Count != 0) return partialMatches; // else return null; // } // else // return null; //} //#endregion #endregion #region Search Functions /// <summary> /// Given a clue, find any documents under that clue, or return null if not a valid clue /// </summary> /// <returns></returns> private List <Document> GetMatchingClueDocuments(string clue) { string[] fragments = SeperateClueFragments(clue.ToLower()); // Single fragment clue if (fragments.Length == 1) { if (Fragments.ContainsKey(fragments[0]) == true) { return(Fragments[fragments[0]].Documents.ToList()); } else { return(null); } } // Multiple fragment clue else { foreach (KeyValuePair <string, List <Document> > fragmentScope in FragmentScopes.Data) { if (ClueHelper.IsClueFragmentsMatching(fragments, SeperateClueFragments(fragmentScope.Key)) == true) { return(fragmentScope.Value); } } return(null); } }
public void RemoveDocumentClue(string clue, Document doc) { string[] fragments = ClueHelper.SeperateClueFragments(clue); // Remove from scope if (fragments.Length > 1) { FragmentScopes.Remove(clue, doc); } // Remove from fragments foreach (string fragment in fragments) { if (Fragments.ContainsKey(fragment) == false) { throw new InvalidOperationException("Key/Value isn't balanced for current operation doesn't have a previous counterpart."); } else { Fragments[fragment].Documents.Remove(doc); } // Remove from that fragment's scope if it's no longer used by anyone if (FragmentScopes.Get(clue) == null) { Fragments[fragment].FragmentScopes.Remove(clue); } } // Remove clue from collection if not used by others if (FragmentScopes.Get(clue) == null) { AllClues.Remove(clue); } }
public void Build() { Console.WriteLine($"Generating {GetFilePath()}"); var deserializer = new DeserializerBuilder().Build(); var serializer = new SerializerBuilder().Build(); Console.WriteLine($"With fragments:"); foreach (var fragment in Fragments.ToList()) { var fragmentPath = GetFragmentLocation(fragment); if (!File.Exists(fragmentPath)) { Console.WriteLine($"\t{fragment} not found in {fragmentPath}, ignoring..."); Fragments.Remove(fragment); } else { Console.WriteLine($"\t{fragment}"); } } var services = new List <KeyValuePair <YamlNode, YamlNode> >(); var volumes = new List <KeyValuePair <YamlNode, YamlNode> >(); var networks = new List <KeyValuePair <YamlNode, YamlNode> >(); foreach (var doc in Fragments.Select(f => ParseDocument(f))) { if (doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot) { services.AddRange(fragmentServicesRoot.Children); } if (doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot) { volumes.AddRange(fragmentVolumesRoot.Children); } if (doc.Children.ContainsKey("networks") && doc.Children["networks"] is YamlMappingNode fragmentNetworksRoot) { networks.AddRange(fragmentNetworksRoot.Children); } } YamlMappingNode output = new YamlMappingNode(); output.Add("version", new YamlScalarNode("3") { Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted }); output.Add("services", new YamlMappingNode(Merge(services))); output.Add("volumes", new YamlMappingNode(volumes)); output.Add("networks", new YamlMappingNode(networks)); var result = serializer.Serialize(output); var outputFile = GetFilePath(); File.WriteAllText(outputFile, result.Replace("''", "")); Console.WriteLine($"Generated {outputFile}"); Console.WriteLine(); }
public override Fragment GetItem(int position) { var fragmentInfo = Fragments.ElementAt(position); var fragment = Fragment.Instantiate(_context, FragmentJavaName(fragmentInfo.FragmentType)); ((MvxFragment)fragment).ViewModel = fragmentInfo.ViewModel; return(fragment); }
private async void GetDrawerInfo() { var profile = await _profileDrawerControllerService.GetUserProfile(); RunOnUiThread(() => { if (profile != null) { //set up profile picture, logout button and favorites if the user is logged in LoggedIn = true; NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Gone; NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Visible; var authHeader = NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader); authHeader.Visibility = ViewStates.Visible; Picasso.With(this).Load(profile.ProfileImageUrl) .Into(authHeader.FindViewById <ImageView>(Resource.Id.drawerAuthenticatedHeader_Avatar)); authHeader.Tag = profile.ProfileId; authHeader.SetOnClickListener(this); authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Fullname).Text = profile.ProfileFirstName + " " + profile.ProfileLastName; authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Handle).Text = profile.ProfileHandle; //Setting up auth tab layout //MainTabLayout.Visibility = ViewStates.Visible; Fab.Visibility = ViewStates.Visible; //TODO: Change these to real fragments later if (Fragments.Count == 1) { Fragments.Add(NotificationFragment.NewInstance()); Fragments.Add(NotificationFragment.NewInstance()); } MainFragAdapter.NotifyDataSetChanged(); SetTabIcons(); } else { //set up icon and hide tab layout when user is not logged in LoggedIn = false; Fab.Visibility = ViewStates.Gone; NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Gone; NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Visible; NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader).Visibility = ViewStates.Gone; NavView.FindViewById <ImageView>(Resource.Id.drawerNonAuthenticatedHeader_Avatar) .SetImageDrawable( ViewUtil.GetSVGDrawable(this, "profile_empty", 200, Resource.Color.Upward_dark_grey)); MainTabLayout.Visibility = ViewStates.Gone; } PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).Edit() .PutBoolean(Constants.PREF_SIGNED_IN_KEY, LoggedIn).Commit(); }); }
public void Clear() { _schema = null; Path.Clear(); Fragments.Clear(); UsedVariables.Clear(); UnusedVariables.Clear(); DeclaredVariables.Clear(); Errors.Clear(); }
internal void Release() { foreach (var f in Fragments) { ReleaseFragment(f); } Fragments.Clear(); GenericPool <Message> .Release(this); }
public override IList <ValidationResult> Execute(SchemaFile file) { var validationResults = Fragments .SelectMany(fragment => GetFieldPairReferences(file, fragment)) .Where(pair => InvokesImplicitConversion(pair)) .Select(pair => ToValidationResult(pair)) .ToList(); return(validationResults); }
public override Fragment GetItem(int position) { var frag = Fragments.ElementAt(position); var fragment = Fragment.Instantiate(_context, FragmentJavaName(frag.FragmentType)); //Java.Lang.Class.FromType(typeof(frag)).Name); ((MvxFragment)fragment).DataContext = frag.ViewModel; return(fragment); }
private void ReadFragments() { if (Header.HasFlag(PacketHeaderFlags.BlobFragments)) { while (Payload.BaseStream.Position != Payload.BaseStream.Length) { Fragments.Add(new ClientPacketFragment(Payload)); } } }
public IMSBuildGlob ToMSBuildGlob() { if (Fragments.Count == 1) { // Optimize the common case, avoiding allocation of enumerable/enumerator. return(Fragments[0].ToMSBuildGlob()); } return(CompositeGlob.Create(Fragments.Select(f => f.ToMSBuildGlob()))); }
public void InsertFragment(int index, SupportFragment fragment, string name) { try { Fragments.Insert(index, fragment); FragmentNames.Insert(index, name); } catch (Exception e) { Console.WriteLine(e); } }
public void AddFragment(SupportFragment fragment, string name) { try { Fragments.Add(fragment); FragmentNames.Add(name); } catch (Exception e) { Console.WriteLine(e); } }
public void AddFragment(SupportFragment fragment, string name) { try { Fragments.Add(fragment); FragmentNames.Add(name); } catch (Exception exception) { Crashes.TrackError(exception); } }
public void InsertFragment(int index, SupportFragment fragment, string name) { try { Fragments.Insert(index, fragment); FragmentNames.Insert(index, name); } catch (Exception exception) { Crashes.TrackError(exception); } }
/// <summary> /// Pushes the fragment onto the view stack. /// </summary> /// <param name="fragment">The fragment.</param> public void PushFragment(CrexBaseFragment fragment) { var oldFragment = Fragments.LastOrDefault(); var tx = FragmentManager.BeginTransaction(); tx.SetCustomAnimations(global::Android.Resource.Animator.FadeIn, global::Android.Resource.Animator.FadeOut, global::Android.Resource.Animator.FadeIn, global::Android.Resource.Animator.FadeOut); tx.Add(global::Android.Resource.Id.Content, fragment); Fragments.Add(fragment); InFragmentTransition = true; tx.Commit(); }
public Document() { _definitions = new List<IDefinition>(); Operations = new Operations(); Fragments = new Fragments(); }
public Document() { Operations = new Operations(); Fragments = new Fragments(); }
public ExecutionContext() { Fragments = new Fragments(); Errors = new ExecutionErrors(); }
private SupportFragment CreateFragment(Fragments fragmentEnum) { SupportFragment f = null; switch (fragmentEnum) { case Fragments.Home: f = new HomeFragment(); break; case Fragments.Login: f = new LoginFragment(); break; case Fragments.Profile: f = new ProfileFragment(); break; case Fragments.RecordAudio: f = new RecordAudioFragment(); break; case Fragments.RegisterUser: f = new RegisterUserFragment(); break; case Fragments.Riff: f = new RiffFragment(); break; } return f; }
public void ShowFragment(Fragments fragmentEnum) { if (UserHelper.CurrentUser == null && fragmentEnum != Fragments.Login && fragmentEnum != Fragments.RegisterUser) return; var fragment = CreateFragment(fragmentEnum); // if (fragment.IsVisible) // { // return; // } var trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.main, fragment); trans.Commit(); _currentFragment = null; _currentFragment = fragment; }
public void HandleData(MemBlock b, ISender return_path, object state) { //Read the header: uint crc32 = (uint)NumberSerializer.ReadInt(b, 0); int id = NumberSerializer.ReadInt(b, 4); ushort block = (ushort)NumberSerializer.ReadShort(b, 8); MemBlock data = b.Slice(10); var cachekey = new Triple<uint, int, ushort>(crc32, id, block); MemBlock packet = null; lock(_sync) { if( false == _fragments.Contains(cachekey) ) { //This is a new block: _fragments.Add(cachekey, data); var fc_key = new Pair<uint, int>(crc32, id); Fragments this_fc; if( false == _frag_count.TryGetValue(fc_key, out this_fc) ) { this_fc = new Fragments(); _frag_count.Add(fc_key, this_fc); } if( this_fc.AddBlock(block) ) { //We have all of them, decode and clean up: packet = DecodeAndClear(crc32, id, (ushort)this_fc.Total); } } } if( null != packet ) { Handle(packet, return_path); } }