static void Main(string[] args) { First myFirst = new First(); myFirst.Print(); Second mySecond = new Second(); mySecond.Print(); Thrid myThrid = new Thrid(); myThrid.Print(); Fourth myFourth = new Fourth(); myFourth.Print(); }
//http://www.csharp-station.com/Tutorial/CSharp/Lesson01 // Stopped at 5 // Stopped at 12 static void Main(string[] args) { string sname = First.StaticName; string sname2 = First.GetStaticName(); First first = new First(); First first2 = new First("Joee", "Kirk"); string tostringValue = first2.ToString(); first.PublicName = "Joe"; first.AnotherPublicName = "Matt"; first.Age = 10; Console.WriteLine(first.AnotherPublicName); Console.ReadKey(); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"></see>. /// </returns> public override int GetHashCode() { return((First == null?0:First.GetHashCode()) ^ (Second == null?0:Second.GetHashCode())); }
public bool Matches(IStyledObject styledObject) { return(First.Matches(styledObject) && Second.Matches(styledObject)); }
public override string ToString() => $"({First.Force()} {Second.Force()})";
public string ToString(IFormatProvider provider) => $"({First.ToString(provider)}," + $"{Second.ToString(provider)},{Third.ToString(provider)})";
public void SpecifyOrder(Order order) { order.Specify(First <GridInterceptingMessageHandler> .Then <SagaMessageHandler>()); }
public static void Menu() { bool exit = false; string line; string grammar = null; Translate tr = new Translate(); Console.WriteLine("Functions: "); Console.WriteLine("In order to set the grammar"); Console.WriteLine("> G <rules>"); Console.WriteLine("Ex: G S:(A,B). A:(B,'a';@). B:(C,'b';C). C:('c';@). EOGram!"); Console.WriteLine("In order to calculate FIRST"); Console.WriteLine("> first <k>"); Console.WriteLine("Example: first 2"); Console.WriteLine("In order to calcualte EFF"); Console.WriteLine("> eff <k>"); Console.WriteLine("Example: eff 3"); Console.WriteLine("In order to exit the program"); Console.WriteLine("> e - exit"); Console.Write("> "); while (!exit) { line = Console.ReadLine(); if (line.Length > 0) { if (line.Length == 1 && line[0] == 'e') exit = true; else { List<string> parts = line.Split(' ').Where(x => x != "").ToList(); string fun = parts[0]; switch (fun) { case "G": if (grammar == null) grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR); else { Console.WriteLine("Rewrite? y/n: "); string answer = Console.ReadLine(); if (answer[0] == 'y') grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR); } break; case "first": case "eff": if (grammar == null) Console.WriteLine("error: no grammar"); else { int k; IEnumerable<string> rules = grammar.Split(' '); List<Pair<char, string>> func_rules = new List<Pair<char, string>>(); if (!int.TryParse(parts[1], out k)) { Console.WriteLine("error: incorrect number of k: " + parts[1]); return; } else if (k <= 0) { Console.WriteLine("error: " + k + " must be greater than 0"); return; } foreach (string rule in rules) { IEnumerable<string> parts_of_rule = rule.Split('>'); if (parts_of_rule.Count() != 2) { Console.WriteLine("error: " + rule + " must have two parts"); return; } if (parts_of_rule.ElementAt(0).Length != 1) { Console.WriteLine("error: the left part of " + rule + " must be non-terminal"); return; } char left_part = parts_of_rule.ElementAt(0)[0]; foreach (string right_part in parts_of_rule.ElementAt(1).Split('|')) if (right_part == "") { Console.WriteLine("error: " + rule + " mustn\'t have the empty argument"); return; } else func_rules.Add(new Pair<char, string>(left_part, right_part)); } Console.WriteLine("Ex: S"); Console.WriteLine("Input sequence: "); Console.Write("> "); string sequence = tr.ToMyForm(Console.ReadLine(), Translate.TYPE.SEQUENCE); if (fun == "first") { First first = new First(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules); Console.WriteLine(first.Execute(sequence).ToString()); break; } else { Eff eff = new Eff(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules); Console.WriteLine(eff.Execute(sequence).ToString()); break; } } break; } } } else Console.WriteLine("Try again\n"); Console.Write("> "); } }
//Here we specify that sagas will always be executed before message hanlders. public void SpecifyHandlersOrder(First<PluginGateway> ordering) { ordering.AndThen<SagaMessageHandler>(); }
public int ConvertToQuery() { var qb = DbUtil.Db.QueryBuilderScratchPad(); qb.CleanSlate(DbUtil.Db); if (m.memberstatus > 0) { qb.AddNewClause(QueryType.MemberStatusId, CompareType.Equal, m.memberstatus); } if (m.name.HasValue()) { string First, Last; NameSplit(m.name, out First, out Last); if (First.HasValue()) { var g = qb.AddNewGroupClause(CompareType.AnyTrue); g.AddNewClause(QueryType.LastName, CompareType.StartsWith, Last); g.AddNewClause(QueryType.MaidenName, CompareType.StartsWith, Last); g = qb.AddNewGroupClause(CompareType.AnyTrue); g.AddNewClause(QueryType.FirstName, CompareType.StartsWith, First); g.AddNewClause(QueryType.NickName, CompareType.StartsWith, First); g.AddNewClause(QueryType.MiddleName, CompareType.StartsWith, First); } else { if (Last.AllDigits()) { qb.AddNewClause(QueryType.PeopleId, CompareType.Equal, Last.ToInt()); } else { qb.AddNewClause(QueryType.LastName, CompareType.StartsWith, Last); } } } if (m.address.IsNotNull()) { if (AddrRegex.IsMatch(m.address)) { var match = AddrRegex.Match(m.address); m.address = match.Groups["addr"].Value; } m.address = m.address.Trim(); if (m.address.HasValue()) { var g = qb.AddNewGroupClause(CompareType.AnyTrue); g.AddNewClause(QueryType.PrimaryAddress, CompareType.Contains, m.address); g.AddNewClause(QueryType.PrimaryAddress2, CompareType.Contains, m.address); g.AddNewClause(QueryType.PrimaryCity, CompareType.Contains, m.address); g.AddNewClause(QueryType.PrimaryZip, CompareType.Contains, m.address); } } if (m.communication.IsNotNull()) { m.communication = m.communication.Trim(); if (m.communication.HasValue()) { var g = qb.AddNewGroupClause(CompareType.AnyTrue); g.AddNewClause(QueryType.CellPhone, CompareType.Contains, m.communication); g.AddNewClause(QueryType.EmailAddress, CompareType.Contains, m.communication); g.AddNewClause(QueryType.EmailAddress2, CompareType.Contains, m.communication); g.AddNewClause(QueryType.HomePhone, CompareType.Contains, m.communication); g.AddNewClause(QueryType.WorkPhone, CompareType.Contains, m.communication); } } if (m.birthdate.HasValue() && m.birthdate.NotEqual("na")) { DateTime dt; if (DateTime.TryParse(m.birthdate, out dt)) { if (Regex.IsMatch(m.birthdate, @"\d+/\d+/\d+")) { qb.AddNewClause(QueryType.Birthday, CompareType.Equal, m.birthdate); } else { qb.AddNewClause(QueryType.Birthday, CompareType.Equal, m.birthdate); } } else { int n; if (int.TryParse(m.birthdate, out n)) { if (n >= 1 && n <= 12) { qb.AddNewClause(QueryType.Birthday, CompareType.Equal, m.birthdate); } else { qb.AddNewClause(QueryType.Birthday, CompareType.Equal, m.birthdate); } } } } if (m.campus > 0) { qb.AddNewClause(QueryType.CampusId, CompareType.Equal, m.campus); } else if (m.campus == -1) { qb.AddNewClause(QueryType.CampusId, CompareType.IsNull, m.campus); } if (m.gender != 99) { qb.AddNewClause(QueryType.GenderId, CompareType.Equal, m.gender); } if (m.marital != 99) { qb.AddNewClause(QueryType.MaritalStatusId, CompareType.Equal, m.marital); } qb.AddNewClause(QueryType.IncludeDeceased, CompareType.Equal, "1,T"); DbUtil.Db.SubmitChanges(); return(qb.QueryId); }
private IQueryable <OrganizationMember> FetchMembers() { if (members == null) { members = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == OrganizationId let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) // for Match Any where gc > 0 || Groups[0] <= 0 || GroupsMode == 1 // for Match All where gc == Groups.Length || Groups[0] <= 0 || GroupsMode == 0 // for Match No SmallGroup assigned where om.OrgMemMemTags.Count() == 0 || Groups[0] != -1 select om; } var active = new[] { MemberTypeCode.InActive, MemberTypeCode.Prospect }; switch (Select) { case GroupSelect.Active: members = from om in members where !active.Contains(om.MemberTypeId) where (om.Pending ?? false) == false select om; break; case GroupSelect.Pending: members = from om in members where !active.Contains(om.MemberTypeId) where (om.Pending ?? false) == true select om; break; case GroupSelect.Inactive: members = from om in members where om.MemberTypeId == MemberTypeCode.InActive select om; break; case GroupSelect.Prospect: members = from om in members where om.MemberTypeId == MemberTypeCode.Prospect select om; break; } if (NameFilter.HasValue()) { string First, Last; Util.NameSplit(NameFilter, out First, out Last); if (First.HasValue()) { members = from om in members let p = om.Person where p.LastName.StartsWith(Last) where p.FirstName.StartsWith(First) || p.NickName.StartsWith(First) select om; } else { members = from om in members let p = om.Person where p.LastName.StartsWith(Last) || p.PeopleId == Last.ToInt() select om; } } if (SgPrefix.HasValue()) { var a = SgPrefix.Split(','); foreach (var p in a) { if (p.StartsWith("-")) { members = from om in members where om.OrgMemMemTags.All(mm => !mm.MemberTag.Name.StartsWith(p.Substring(1))) select om; } else { members = from om in members where om.OrgMemMemTags.Any(mm => mm.MemberTag.Name.StartsWith(p)) select om; } } } return(members); }
/// <summary> /// A hashcode such that two UOPairs{T} with the same elements will have the same hashcode. /// Depending on the subtypes, the hash code may be different on 32-bit and 64-bit machines /// </summary> public override int GetHashCode() { return(First.GetHashCode() ^ Second.GetHashCode() ^ uopairStringHashCode ^ typeof(T).GetHashCode()); }
/// <summary> /// Loads all message handler assemblies in the runtime directory /// and specifies that the handlers in the given 'order' are to /// run before all others and in the order specified. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="order"></param> /// <returns></returns> public ConfigUnicastBus LoadMessageHandlers <T>(First <T> order) { return(LoadMessageHandlers(order.Types)); }
public void SpecifyHandlersOrder(First<PluginGateway> ordering) { ordering.AndThen<DeleteProfileCommandHandler>().AndThen<PluginCommandHandler>(); }
/// <summary> /// Computes a numerical score measuring the association between /// the given <paramref name="input" /> vector and a given /// <paramref name="classIndex" />. /// </summary> /// <param name="input">The input vector.</param> /// <param name="classIndex">The index of the class whose score will be computed.</param> /// <returns>System.Double.</returns> public override double Score(double[] input, int classIndex) { return(Second.Score(First.Transform(input), classIndex)); }
public static IEnumerable <NamesInfo> Names(string text, int limit) { string First, Last; var qp = DbUtil.Db.People.AsQueryable(); if (Util2.OrgLeadersOnly) { qp = DbUtil.Db.OrgLeadersOnlyTag2().People(DbUtil.Db); } qp = from p in qp where p.DeceasedDate == null select p; Util.NameSplit(text, out First, out Last); var hasfirst = First.HasValue(); if (text.AllDigits()) { string phone = null; if (text.HasValue() && text.AllDigits() && text.Length == 7) { phone = text; } if (phone.HasValue()) { var id = Last.ToInt(); qp = from p in qp where p.PeopleId == id || p.CellPhone.Contains(phone) || p.Family.HomePhone.Contains(phone) || p.WorkPhone.Contains(phone) orderby p.Name2 select p; } else { var id = Last.ToInt(); qp = from p in qp where p.PeopleId == id orderby p.Name2 select p; } } else { var id = Last.ToInt(); qp = from p in qp where ( (p.LastName.StartsWith(Last) || p.MaidenName.StartsWith(Last) || p.LastName.StartsWith(text) || p.MaidenName.StartsWith(text)) && (!hasfirst || p.FirstName.StartsWith(First) || p.NickName.StartsWith(First) || p.MiddleName.StartsWith(First) || p.LastName.StartsWith(text) || p.MaidenName.StartsWith(text)) ) || p.PeopleId == id orderby p.Name2 select p; } var r = from p in qp let age = p.Age.HasValue ? " (" + p.Age + ")" : "" orderby p.Name2 select new NamesInfo() { Pid = p.PeopleId, Name = p.Name2 + age, Addr = p.PrimaryAddress ?? "", }; return(r.Take(limit)); }
public IQueryable <Person> FetchPeople() { if (people != null) { return(people); } DbUtil.Db.SetNoLock(); if (Util2.OrgMembersOnly) { people = DbUtil.Db.OrgMembersOnlyTag2().People(DbUtil.Db); } else if (Util2.OrgLeadersOnly) { people = DbUtil.Db.OrgLeadersOnlyTag2().People(DbUtil.Db); } else { people = DbUtil.Db.People.AsQueryable(); } if (usersonly) { people = people.Where(p => p.Users.Count() > 0); } if (m.memberstatus > 0) { people = from p in people where p.MemberStatusId == m.memberstatus select p; } if (m.name.HasValue()) { if (m.name.StartsWith("e:")) { var name = m.name.Substring(2); people = from p in people where p.EmployerOther.Contains(name) select p; } else { string First, Last; NameSplit(m.name, out First, out Last); if (First.HasValue()) { people = from p in people where (p.LastName.StartsWith(Last) || p.MaidenName.StartsWith(Last) || p.LastName.StartsWith(m.name) || p.MaidenName.StartsWith(m.name)) && (p.FirstName.StartsWith(First) || p.NickName.StartsWith(First) || p.MiddleName.StartsWith(First) || p.LastName.StartsWith(m.name) || p.MaidenName.StartsWith(m.name)) select p; } else if (Last.AllDigits()) { people = from p in people where p.PeopleId == Last.ToInt() select p; } else { people = from p in people where p.LastName.StartsWith(Last) || p.MaidenName.StartsWith(Last) || p.LastName.StartsWith(m.name) || p.MaidenName.StartsWith(m.name) select p; } } } if (m.address.IsNotNull()) { if (AddrRegex.IsMatch(m.address)) { var match = AddrRegex.Match(m.address); m.address = match.Groups["addr"].Value; } m.address = m.address.Trim(); if (m.address.HasValue()) { people = from p in people where p.Family.AddressLineOne.Contains(m.address) || p.Family.AddressLineTwo.Contains(m.address) || p.Family.CityName.Contains(m.address) || p.Family.ZipCode.Contains(m.address) select p; } } if (m.communication.IsNotNull()) { m.communication = m.communication.Trim(); if (m.communication.HasValue()) { people = from p in people where p.CellPhone.Contains(m.communication) || p.EmailAddress.Contains(m.communication) || p.EmailAddress2.Contains(m.communication) || p.Family.HomePhone.Contains(m.communication) || p.WorkPhone.Contains(m.communication) select p; } } if (m.birthdate.HasValue() && m.birthdate.NotEqual("na")) { DateTime dt; if (DateTime.TryParse(m.birthdate, out dt)) { if (Regex.IsMatch(m.birthdate, @"\d+/\d+/\d+")) { people = people.Where(p => p.BirthDay == dt.Day && p.BirthMonth == dt.Month && p.BirthYear == dt.Year); } else { people = people.Where(p => p.BirthDay == dt.Day && p.BirthMonth == dt.Month); } } else { int n; if (int.TryParse(m.birthdate, out n)) { if (n >= 1 && n <= 12) { people = people.Where(p => p.BirthMonth == n); } else { people = people.Where(p => p.BirthYear == n); } } } } if (m.campus > 0) { people = people.Where(p => p.CampusId == m.campus); } else if (m.campus == -1) { people = people.Where(p => p.CampusId == null); } if (m.gender != 99) { people = people.Where(p => p.GenderId == m.gender); } if (m.marital != 99) { people = people.Where(p => p.MaritalStatusId == m.marital); } return(people); }
// The argument type is less derived. public static First AFirstRFirst(First first) { return new First(); }
public override string ToString() { return("{" + First.ToString() + "}, {" + Second.ToString() + "}"); }
public void Start() { First.GracefullyClose(Second, Third); }
public static IEnumerable <SearchInfo> Names(string text) { string First, Last; var qp = DbUtil.Db.People.AsQueryable(); var qo = from o in DbUtil.Db.Organizations where o.OrganizationStatusId == CmsData.Codes.OrgStatusCode.Active select o; if (Util2.OrgLeadersOnly) { qp = DbUtil.Db.OrgLeadersOnlyTag2().People(DbUtil.Db); } qp = from p in qp where p.DeceasedDate == null select p; Util.NameSplit(text, out First, out Last); var hasfirst = First.HasValue(); if (text.AllDigits()) { string phone = null; if (text.HasValue() && text.AllDigits() && text.Length == 7) { phone = text; } if (phone.HasValue()) { var id = Last.ToInt(); qp = from p in qp where p.PeopleId == id || p.CellPhone.Contains(phone) || p.Family.HomePhone.Contains(phone) || p.WorkPhone.Contains(phone) select p; qo = from o in qo where o.OrganizationId == id select o; } else { var id = Last.ToInt(); qp = from p in qp where p.PeopleId == id select p; qo = from o in qo where o.OrganizationId == id select o; } } else { qp = from p in qp where ( (p.LastName.StartsWith(Last) || p.MaidenName.StartsWith(Last) || p.LastName.StartsWith(text) || p.MaidenName.StartsWith(text)) && (!hasfirst || p.FirstName.StartsWith(First) || p.NickName.StartsWith(First) || p.MiddleName.StartsWith(First) || p.LastName.StartsWith(text) || p.MaidenName.StartsWith(text)) ) select p; qo = from o in qo where o.OrganizationName.Contains(text) || o.LeaderName.Contains(text) select o; } var rp = from p in qp orderby p.Name2 select new SearchInfo() { id = p.PeopleId, line1 = p.Name2 + (p.Age.HasValue ? $" ({Person.AgeDisplay(p.Age, p.PeopleId)})" : ""), line2 = p.PrimaryAddress ?? "", isOrg = false, }; var ro = from o in qo orderby o.OrganizationName select new SearchInfo() { id = o.OrganizationId, line1 = o.OrganizationName, line2 = o.Division.Name, isOrg = true }; var list = new List <SearchInfo>(); list.AddRange(rp.Take(6)); if (list.Count > 0) { list.Add(new SearchInfo() { id = 0 }); } var roTake = ro.Take(4).ToList(); list.AddRange(roTake); if (roTake.Count > 0) { list.Add(new SearchInfo() { id = 0 }); } list.AddRange(new List <SearchInfo>() { new SearchInfo() { id = -1, line1 = "People Search" }, new SearchInfo() { id = -2, line1 = "Last Search" }, new SearchInfo() { id = -3, line1 = "Organization Search" }, }); return(list); }
public void ExecuteMultipleOperationsInTransaction() { Session s = Session.CreateNewSession(DatabaseServer.SqlServer, SharedData.sqlserver); CategoryTableMetadata ctm = new CategoryTableMetadata(); CategoryPersistentObject persistent = new CategoryPersistentObject(s, ctm); First first = new First(); FirstPersistentObject fp = new FirstPersistentObject(s, first); Third third = new Third(); third.ThirdStuff = "lalala"; Second sp = new Second(); sp.Age = 456; sp.Quantity = 43; sp.AttachTableMetadata(third); first.Name = "Crocodilu"; first.AttachTableMetadata(sp); s.BeginTransaction(); QueryCriteria qc = new QueryCriteria(ctm.TableName, ctm.TableFields[0]); qc.Add(CriteriaOperator.Max, ctm.TableFields[0]); //get the last one CategoryTableMetadata[] ct = (CategoryTableMetadata[])persistent.GetTableMetadata(qc); persistent.Delete(ct[0]); CategoryTableMetadata cc = new CategoryTableMetadata(); cc.CategoryName = "fluffy"; cc.Description = "tingling"; persistent.Create(cc); fp.Create(first); List <ExecutionQuery> scc = s.Queries; for (int i = 0; i < scc.Count; i++) { Console.WriteLine(scc[i]); } s.Commit(); }
public bool Equals(Pair <TFirst, TSecond> other) { return(other != null && First.Equals(other.First) && Second.Equals(other.Second)); }
public bool Contains(T t) => (First.Equals(t)) || Rest.Contains(t);
public IQueryable <Person> ApplySearch() { if (query.IsNotNull()) { return(query); } var db = DbUtil.Db; if (Util2.OrgMembersOnly) { query = db.OrgMembersOnlyTag2().People(db); } else if (Util2.OrgLeadersOnly) { query = db.OrgLeadersOnlyTag2().People(db); } else { query = db.People.Select(p => p); } query = query.Where(pp => pp.DeceasedDate == null); if (Name.HasValue()) { string First, Last; Util.NameSplit(Name, out First, out Last); DbUtil.LogActivity("iphone search '{0}' '{1}'".Fmt(First, Last)); if (First.HasValue()) { query = from p in query where p.LastName.StartsWith(Last) || p.MaidenName.StartsWith(Last) || p.LastName.StartsWith(Name) || p.MaidenName.StartsWith(Name) // gets Bob St Clair where p.FirstName.StartsWith(First) || p.NickName.StartsWith(First) || p.MiddleName.StartsWith(First) || p.LastName.StartsWith(Name) || p.MaidenName.StartsWith(Name) // gets Bob St Clair select p; } else if (Last.AllDigits()) { query = from p in query where p.PeopleId == Last.ToInt() select p; } else { query = from p in query where p.LastName.StartsWith(Name) || p.MaidenName.StartsWith(Name) || p.FirstName.StartsWith(Name) || p.NickName.StartsWith(Name) || p.MiddleName.StartsWith(Name) select p; } } if (Addr.IsNotNull()) { Addr = Addr.Trim(); if (Addr.HasValue()) { query = from p in query where p.Family.AddressLineOne.Contains(Addr) || p.Family.AddressLineTwo.Contains(Addr) || p.Family.CityName.Contains(Addr) || p.Family.ZipCode.Contains(Addr) select p; } } if (Comm.IsNotNull()) { Comm = Comm.Trim(); if (Comm.HasValue()) { query = from p in query where p.CellPhone.Contains(Comm) || p.EmailAddress.Contains(Comm) || p.Family.HomePhone.Contains(Comm) || p.WorkPhone.Contains(Comm) select p; } } return(query); }
public void CollectConditionTargets(IStyledObject node, IWatchRuleFactory watchRuleFactory, ICollection <IWatchRule> affectedNodes) { First.CollectConditionTargets(node, watchRuleFactory, affectedNodes); Second.CollectConditionTargets(node, watchRuleFactory, affectedNodes); }
private void Another([Unused] First first) { }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> public override int GetHashCode() { return(First.GetHashCode() ^ Second.GetHashCode()); }
public override void ExecuteCmdlet() { try { if (!ProcessParameters()) { return; } GetBackupResponse backupList = null; backupList = StorSimpleClient.GetAllBackups(deviceId, filterType, isAllSelected, IdToPass, FromDateTime.ToString(), ToDateTime.ToString(), Skip == null ? "0" : Skip.ToString(), First == null ? null : First.ToString()); WriteObject(backupList.BackupSetsList, true); WriteVerbose(string.Format(Resources.BackupsReturnedCount, backupList.BackupSetsList.Count)); if (backupList.NextPageUri != null && backupList.NextPageStartIdentifier != "1") { if (First != null) { //user has provided First(Top) parameter while calling the commandlet //so we need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.BackupNextPageFormatMessage, First, backupList.NextPageStartIdentifier)); } else { //user has NOT provided First(Top) parameter while calling the commandlet //so we DONT need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.BackupNextPagewithNoFirstMessage, backupList.NextPageStartIdentifier)); } } else { WriteVerbose(Resources.BackupNoMorePagesMessage); } } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// Computes a numerical score measuring the association between /// the given <paramref name="input" /> vector and each class. /// </summary> /// <param name="input">The input vector.</param> /// <param name="result">An array where the result will be stored, /// avoiding unnecessary memory allocations.</param> /// <returns></returns> public override double[][] Scores(double[][] input, double[][] result) { return(Second.Scores(First.Transform(input), result)); }
public override string ToString() { return(First.ToString() + "->" + Second.ToString() + " : " + Weight); }
private void Start() { Player = GameObject.FindGameObjectWithTag("Player").GetComponent <First>(); Dead = Player.Dead; ForSavesVar = GameObject.FindGameObjectWithTag("Player").GetComponent <ForSaves>().MyData; }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { //File.WriteAllText(@"./result.txt", ""); System.Random r = new System.Random(); // --------------------Output-------------------- System.Console.WriteLine($"Q : The number of queries"); System.Console.WriteLine($"K : The number of k_steps"); System.Console.WriteLine($"F : Target mean value"); System.Console.WriteLine($"E : Predicted mean value"); System.Console.WriteLine($"|F-E| : Abs error"); System.Console.WriteLine($"A : Counter"); System.Console.WriteLine($""); System.Console.WriteLine($"Q K F E |F-E| (A)"); System.Console.WriteLine($"--------------------------------"); // ---------------------------------------------- // --------------------Variable-------------------- int Total_Query = 400; // The number of queries int k_max = 3; // The number of k-steps int aa_loop = 10; // How many trials of QCoin prediction // ------------------------------------------------ // -------------------Start QCoin------------------ double F; double avg_error = 0.0; int query = 0; for (int aa = 0; aa < aa_loop; aa++) { F = r.NextDouble(); // Determine target value F randomly query = 0; int first_count = 0; // 1st step double delta = Math.Sin(Math.PI / 2.0 / 2.0) / 2.0; // Error ±δ int loop = (int)Math.Floor(Total_Query / (Math.Pow(2.0, k_max) - 1)); // Calculate the number of loops to reduce within Error delta for (int i = 0; i < loop; i++) { int M_obs = (int)First.Run(qsim, F).Result; // Run on a quantum simulator (move to "Operations.qs") first_count += M_obs; // Count how many times "QCoin" returns 1 (head). } double E = (double)first_count / loop; double lower_limit = E - delta; if (lower_limit < 0.0) { lower_limit = 0.0; } double upper_limit = E + delta; if (upper_limit > 1.0) { upper_limit = 1.0; } query += loop; // 2nd and later steps int k; for (k = 2; k <= k_max; k++) { int n = (int)Math.Pow(2.0, k - 2); delta = Math.Sin(Math.PI / 2.0 / Math.Pow(2.0, k)) / 2.0; // Error ±δ // Determine upper limit of angle double upper_theta = Math.Asin(upper_limit - lower_limit); double after_Grover_scale = Math.Sin(upper_theta * (2.0 * n)); int count = 0; for (int i = 0; i < loop; i++) { int M_obs = (int)Output.Run(qsim, F, lower_limit, n).Result; // Run on a quantum simulator (move to "Operations.qs") count += M_obs; // Count how many times "QCoin" returns 1 (head). } double prob = (double)count / loop; E = Math.Pow(prob, 0.5); if (E > after_Grover_scale) { E = after_Grover_scale; } double E_theta = Math.Asin(E); E = Math.Sin(E_theta / (2.0 * n)) + lower_limit; // Determine lower and upper limit from E double next_lower_limit = E - delta; double next_upper_limit = E + delta; if (next_lower_limit > lower_limit) { lower_limit = next_lower_limit; } if (next_upper_limit < upper_limit) { upper_limit = next_upper_limit; } query += (2 * n) * loop; } // ----------------Output---------------- System.Console.WriteLine($"{query} {k_max} {F:F5} {E:F5} {Math.Abs(E-F):F5} ({aa+1})"); avg_error += Math.Abs(E - F); // -------------------------------------- } avg_error = avg_error / aa_loop; // --------------------------------Output-------------------------------- System.Console.WriteLine($"--------------------------------"); System.Console.WriteLine($"Avg_error: {avg_error:F8}"); System.Console.WriteLine($""); // -------------------------Output to result.txt------------------------- // File.AppendAllText(@"./result.txt", k_max.ToString()); // File.AppendAllText(@"./result.txt", " "); // File.AppendAllText(@"./result.txt", query.ToString()); // File.AppendAllText(@"./result.txt", " "); // File.AppendAllText(@"./result.txt", avg_error+Environment.NewLine); // ---------------------------------------------------------------------- } }
public void SpecifyHandlersOrder(First<PluginGateway> ordering) { ordering.AndThen<TfsWorkItemsListener>().AndThen<VersionControlSystemListener>(); }
public override string ToString() { return("[" + First.ToString() + "; " + Second.ToString() + "; " + this.Third + "]"); }
public void SecondMethod3(string one, First two) { }
/// <summary> /// Updates this consolidator with the specified data /// </summary> /// <param name="data">The new data for the consolidator</param> public void Update(BaseData data) { First.Update(data); }
// The return type is more derived // and the argument type is less derived. public static Second AFirstRSecond(First first) { return new Second(); }
public override IResultValue Evaluate() { return(new ResultBoolean(First.Evaluate().ToDecimal() > Second.Evaluate().ToDecimal())); }