public static int?AddTerm(this IDivision division, IModelContext modelContext) { // TODO: Get vocabulary name from config var vocabularyName = "University_Structure"; var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.Name == vocabularyName); if (vocabulary != null) { var termName = GetSafeTermName(division.ShortTitle, division.Title); try { var term = new Term(termName, string.Empty, vocabulary.VocabularyId); var parentDivision = division.GetParentDivision(modelContext); if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } return(new TermController().AddTerm(term)); } catch (Exception ex) { Exceptions.LogException(new Exception($"Error adding {termName} term to {vocabularyName} vocabulary.", ex)); } } else { Exceptions.LogException(new Exception($"Could not find vocabulary with name {vocabularyName}.")); } return(null); }
public DivisionViewModel(IDivision division, ViewModelContext <DivisionSettings> context) { Division = division; Context = context; _subDivisionViewModels = Division.SubDivisions.Select(d => new DivisionViewModel(d, Context)).ToList(); }
public static void UpdateTerm(this IDivision division, IModelContext modelContext) { var termName = GetSafeTermName(division.ShortTitle, division.Title); try { var parentDivision = division.GetParentDivision(modelContext); if (division.DivisionTermID != null) { var termCtrl = new TermController(); var term = termCtrl.GetTerm(division.DivisionTermID.Value); if (term != null) { term.Name = termName; if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } termCtrl.UpdateTerm(term); } } } catch (Exception ex) { Exceptions.LogException(new Exception($"Error updating {termName} term.", ex)); } }
public override void Visit(IDivision division) { if (Process(division)) { visitor.Visit(division); } base.Visit(division); }
public Category(IDivision d, string n, string des) { this.Div = d; this.Name = n; this.Description = des; d.AddCategory(this); }
private bool IsDivisionChampion(ITeam team) { IDivision div = GetConference(team).Divisions.Where(d => d.Teams.Contains(team)).FirstOrDefault(); ITeam[] teams = div.Teams.ToArray(); Array.Sort(teams, new DivisionCompare(league)); return(teams[3] == team); }
private static Dictionary <string, object> DivisionToAttributes(IDivision division) { return(new Dictionary <string, object>() { { "Division_ID", division.ID.ToString() }, { "Name", division.Name }, }); }
public static VCard GetVCard(this IDivision division) { var vcard = new VCard(); // org. name if (!string.IsNullOrWhiteSpace(division.Title)) { vcard.OrganizationName = division.Title; } // email if (!string.IsNullOrWhiteSpace(division.Email)) { vcard.Emails.Add(division.Email); } // secondary email if (!string.IsNullOrWhiteSpace(division.SecondaryEmail)) { vcard.Emails.Add(division.SecondaryEmail); } // phone if (!string.IsNullOrWhiteSpace(division.Phone)) { vcard.Phones.Add(new VCardPhone() { Number = division.Phone, Type = VCardPhoneType.Work }); } // fax if (!string.IsNullOrWhiteSpace(division.Fax)) { vcard.Phones.Add(new VCardPhone() { Number = division.Fax, Type = VCardPhoneType.Fax }); } // website if (!string.IsNullOrWhiteSpace(division.WebSite)) { vcard.Url = division.WebSite; } // location if (!string.IsNullOrWhiteSpace(division.Location)) { // TODO: Add organization address vcard.DeliveryAddress = division.Location; } // revision vcard.LastRevision = division.LastModifiedOnDate; return(vcard); }
public static int?AddOrUpdateTerm(this IDivision division, IModelContext modelContext) { var vocabularyName = UniversityConfig.Instance.Vocabularies.OrgStructure; var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.Name == vocabularyName); if (vocabulary == null) { Exceptions.LogException(new Exception($"Could not find the {vocabularyName} vocabulary.")); return(null); } var termName = GetSafeTermName(division.ShortTitle, division.Title); var termCtrl = new TermController(); var term = default(Term); if (division.DivisionTermID == null) { term = termCtrl.GetTermsByVocabulary(vocabulary.VocabularyId).FirstOrDefault(t => t.Name == termName); if (term != null) { Exceptions.LogException(new Exception($"Could not create term {termName} in the {vocabularyName} vocabulary as it already exists.")); return(null); } term = new Term(termName, string.Empty, vocabulary.VocabularyId); } else { term = termCtrl.GetTerm(division.DivisionTermID.Value); term.Name = termName; } var parentDivision = division.GetParentDivision(modelContext); if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } else { term.ParentTermId = null; } try { if (division.DivisionTermID == null) { return(termCtrl.AddTerm(term)); } termCtrl.UpdateTerm(term); return(term.TermId); } catch (Exception ex) { Exceptions.LogException(new Exception($"Error creating/updating {termName} term in the vocabulary {vocabularyName}.", ex)); } return(null); }
IDivision IDivision.Divide(IDivision divisor, out IDivision reminder) { ComplexPolynom pd = divisor as ComplexPolynom; ComplexPolynom[] cp = Divide(pd); cp[1].Reduce(); reminder = cp[1]; return(cp[0]); }
public static IDivision GetParentDivision(this IDivision division, IModelContext modelContext) { if (division.ParentDivisionID != null) { return(modelContext.Get <DivisionInfo> (division.ParentDivisionID.Value)); } return(null); }
private HLLocation ProcessDivisionExpression(IDivision pExpression) { HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand); HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitDivide(locationTemporary, locationLeftOperand, locationRightOperand); return(pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary); }
public static IDivision GetParentDivision(this IDivision division, IModelContext modelContext) { Contract.Ensures(Contract.Result <IDivision> () != null); if (division.ParentDivisionID != null) { return(modelContext.Get <DivisionInfo, int> (division.ParentDivisionID.Value)); } return(null); }
public static string GetSearchUrl(this IDivision division, ModuleInfo module, PortalSettings portalSettings) { if (!string.IsNullOrEmpty(division.HomePage)) { return(Globals.NavigateURL(int.Parse(division.HomePage), false, portalSettings, "", portalSettings.PortalAlias.CultureCode)); } return(Globals.NavigateURL(module.TabID, false, portalSettings, "", portalSettings.PortalAlias.CultureCode, "", "mid", module.ModuleID.ToString())); }
/// <summary> /// Calculates greatest common divisor /// </summary> /// <param name="el1">First element</param> /// <param name="el2">Second element</param> /// <returns>The greatest common divisor</returns> static private IDivision greatestCommonDivisor(IDivision el1, IDivision el2) { if (el2.IsZero) { return(el1); } IDivision rem; IDivision el = el1.Divide(el2, out rem); return(greatestCommonDivisor(el2, rem)); }
public static string SearchText(this IDivision division) { return(FormatHelper.JoinNotNullOrEmpty( ", ", division.Title, UniversityModelHelper.HasUniqueShortTitle(division.ShortTitle, division.Title) ? division.ShortTitle : null, division.Phone, division.Fax, division.Email, division.SecondaryEmail, division.WebSite, division.Location, division.WorkingHours )); }
public static string FormatEduProgramDivisionLink(IDivision division, string role = null, bool isPublished = true) { if (division != null) { var classAttr = isPublished ? string.Empty : " class=\"u8y-not-published-element\""; var roleLabel = !string.IsNullOrEmpty(role) ? role + ": " : string.Empty; if (!string.IsNullOrWhiteSpace(division.HomePage)) { var url = Globals.NavigateURL(int.Parse(division.HomePage)); return($"<span{classAttr}>{roleLabel}<a href=\"{url}\" target=\"_blank\">{division.Title}</a></span>"); } return($"<span{classAttr}>{roleLabel}{division.Title}</span>"); } return(string.Empty); }
/// <summary> /// Calculates greatest common divisor /// </summary> /// <param name="el1">First element</param> /// <param name="el2">Second element</param> /// <returns>The greatest common divisor</returns> static public IDivision GreatestCommonDivisor(IDivision el1, IDivision el2) { IDivision c, d; if (el1.Norm > el2.Norm) { c = el1; d = el2; } else { c = el2; d = el1; } return(greatestCommonDivisor(c, d)); }
public override void Visit(IDivision division) { this.Visit(division.LeftOperand); this.Visit(division.RightOperand); Bpl.Expr rexp = TranslatedExpressions.Pop(); Bpl.Expr lexp = TranslatedExpressions.Pop(); var tok = division.Token(); var loc = this.sink.CreateFreshLocal(division.RightOperand.Type); var locExpr = Bpl.Expr.Ident(loc); var storeLocal = Bpl.Cmd.SimpleAssign(tok, locExpr, rexp); this.StmtTraverser.StmtBuilder.Add(storeLocal); var a = new Bpl.AssertCmd(tok, Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, locExpr, Bpl.Expr.Literal(0))); this.StmtTraverser.StmtBuilder.Add(a); TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Div, lexp, locExpr)); }
public static void InsertDivision(IDivision division) { CheckWorkBook(); var attributes = DivisionToAttributes(division); var id = new KeyValuePair <string, object>("Division_ID", attributes["Division_ID"]); if (Excel.IO.ExcelIOAPIs.IsIDOfWorksheet(FilePath, worksheets[2], id)) { var idColumn = new Dictionary <string, object>() { { id.Key, id.Value } }; RowUpdate.Update(FilePath, worksheets[2], idColumn, attributes); return; } RowInsert.Insert(FilePath, worksheets[2], attributes); }
/// <summary> /// Finds all roots of polynom /// </summary> /// <param name="accuracy">Accuracy</param> /// <returns>Array of roots</returns> public Complex[] Roots(double accuracy) { if (Deg == 1) { return(new Complex[] { (-coeff[0] / coeff[1]) }); } if (Deg == 2) { return(SquareRoots); } ComplexPolynom polynom = this; ComplexPolynom p = this; ComplexPolynom deri = Derivation; IDivision div = this; ComplexPolynom comd = StaticExtensionClassicalAlgebra.GreatestCommonDivisor(this, deri) as ComplexPolynom; if (comd.Deg > 0) { List <Complex> r = new List <Complex>(); ComplexPolynom divcomdeg = Divide(comd)[0]; Complex[] r1 = comd.Roots(accuracy); Complex[] r2 = divcomdeg.Roots(accuracy); r.AddRange(r1); r.AddRange(r2); return(r.ToArray()); } Complex[] roots = new Complex[p.Deg]; for (int i = 0; i < roots.Length; i++) { if (p.Deg == 1) { roots[i] = (-p.coeff[0]) / p.coeff[1]; break; } Complex x = p.Root(accuracy); roots[i] = x; ComplexPolynom pol = new ComplexPolynom(new Complex[] { -x, 1 }); p = p.Divide(pol)[0]; } return(roots); }
public void Division_Constructor() { IDivision nfcNorth = this.NFL.GetDivision("NFC", "North"); IDivision nfcSouth = this.NFL.GetDivision("NFC", "South"); IDivision nfcEast = this.NFL.GetDivision("NFC", "East"); IDivision nfcWest = this.NFL.GetDivision("NFC", "West"); IDivision afcNorth = this.NFL.GetDivision("AFC", "North"); IDivision afcSouth = this.NFL.GetDivision("AFC", "South"); IDivision afcEast = this.NFL.GetDivision("AFC", "East"); IDivision afcWest = this.NFL.GetDivision("AFC", "West"); switch (this.LeagueDataFile.StripPath()) { case "NFL_2016.xml": case "NFL_2017.xml": Assert.AreEqual("North", nfcNorth.Name); Assert.AreEqual("South", nfcSouth.Name); Assert.AreEqual("East", nfcEast.Name); Assert.AreEqual("West", nfcWest.Name); Assert.AreEqual("North", afcNorth.Name); Assert.AreEqual("South", afcSouth.Name); Assert.AreEqual("East", afcEast.Name); Assert.AreEqual("West", afcWest.Name); Assert.AreEqual(4, nfcNorth.Teams.Count()); Assert.AreEqual(4, nfcSouth.Teams.Count()); Assert.AreEqual(4, nfcEast.Teams.Count()); Assert.AreEqual(4, nfcWest.Teams.Count()); Assert.AreEqual(4, afcNorth.Teams.Count()); Assert.AreEqual(4, afcSouth.Teams.Count()); Assert.AreEqual(4, afcEast.Teams.Count()); Assert.AreEqual(4, afcWest.Teams.Count()); break; default: break; } }
public void Division_WinPercentage() { IDivision nfcSouth = this.NFL.GetDivision("NFC", "South"); ITeam saints = this.NFL.GetTeam("NO"); IDivision nfcWest = this.NFL.GetDivision("NFC", "West"); ITeam seahawks = this.NFL.GetTeam("SEA"); switch (this.StatsDataFile.StripPath()) { case "NFLStats_2016.xml": Assert.AreEqual((2.0 / 6.0), nfcSouth.WinPercentage(saints)); Assert.AreEqual(((3.0 + (1.0 * 0.5)) / 6.0), nfcWest.WinPercentage(seahawks)); break; case "NFLStats_2017.xml": Assert.AreEqual((4.0 / 6.0), nfcSouth.WinPercentage(saints)); break; default: break; } }
/// <summary> /// Returns a deep copy of the given division expression. /// </summary> /// <param name="division"></param> public Division Copy(IDivision division) { Contract.Requires(division != null); Contract.Ensures(Contract.Result<Division>() != null); var mutableCopy = this.shallowCopier.Copy(division); this.CopyChildren((BinaryOperation)mutableCopy); return mutableCopy; }
/// <summary> /// Traverses the children of the division expression. /// </summary> public virtual void TraverseChildren(IDivision division) { Contract.Requires(division != null); this.TraverseChildren((IBinaryOperation)division); }
/// <summary> /// Performs some computation with the given division expression. /// </summary> /// <param name="division"></param> public virtual void Visit(IDivision division) { }
public EmployeeListViewModel (IEnumerable<IEmployee> employees, IDivision division) { Employees = employees; Division = division; }
public override void Visit(IDivision operation) { ProcessOperation(operation); }
public virtual void onASTElement(IDivision division) { }
public void Visit(IDivision division) { throw new NotImplementedException(); }
/// <summary> /// Performs some computation with the given division expression. /// </summary> /// <param name="division"></param> public virtual void Visit(IDivision division) { this.Visit((IBinaryOperation)division); }
/// <summary> /// Rewrites the given division expression. /// </summary> /// <param name="division"></param> public virtual IExpression Rewrite(IDivision division) { return division; }
/// <summary> /// Returns a shallow copy of the given division expression. /// </summary> /// <param name="division"></param> public Division Copy(IDivision division) { Contract.Requires(division != null); Contract.Ensures(Contract.Result<Division>() != null); return new Division(division); }
/// <summary> /// Generates IL for the specified division. /// </summary> /// <param name="division">The division.</param> public override void TraverseChildren(IDivision division) { this.Traverse(division.LeftOperand); this.Traverse(division.RightOperand); if (division.TreatOperandsAsUnsignedIntegers) this.generator.Emit(OperationCode.Div_Un); else this.generator.Emit(OperationCode.Div); this.StackSize--; }
public override void Visit(IDivision division) { if(Process(division)){visitor.Visit(division);} base.Visit(division); }
public override void Visit(IDivision binary) { _formattedValue = Format(binary.LeftOperand) + " / " + Format(binary.RightOperand); }
private HLLocation ProcessDivisionExpression(IDivision pExpression) { HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand); HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitDivide(locationTemporary, locationLeftOperand, locationRightOperand); return pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary; }
public override IExpression Rewrite(IDivision operation) { return(ReplaceOperation(operation)); }
public void Visit(IDivision division) { this.result = this.rewriter.Rewrite(division); }
public override void TraverseChildren(IDivision division) { MethodEnter(division); base.TraverseChildren(division); MethodExit(); }
public EmployeeListViewModel(IEnumerable <IEmployee> employees, IDivision division) { Employees = employees; Division = division; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given division expression. /// </summary> /// <param name="division"></param> public virtual void Visit(IDivision division) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(division); this.Visit(division.LeftOperand); this.Visit(division.RightOperand); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count. this.path.Pop(); }
/// <summary> /// /// </summary> /// <param name="division"></param> public Division(IDivision division) : base(division) { this.TreatOperandsAsUnsignedIntegers = division.TreatOperandsAsUnsignedIntegers; }
/// <summary> /// Traverses the division expression. /// </summary> public void Traverse(IDivision division) { Contract.Requires(division != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(division); if (this.StopTraversal) return; this.TraverseChildren(division); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(division); }
public static IEnumerable <IOccupiedPosition> GetHeadEmployeePositions(this IDivision division) { return(division.OccupiedPositions.Where(op => op.PositionID == division.HeadPositionID)); }
public void Visit(IDivision division) { this.traverser.Traverse(division); }
public override void TraverseChildren(IDivision division) { base.TraverseChildren(division); ((Division)division).Type = this.GetBinaryNumericOperationType(division, division.TreatOperandsAsUnsignedIntegers); }
public void Visit(IDivision division) { Contract.Requires(division != null); throw new NotImplementedException(); }
/// <summary> /// Visits the specified division. /// </summary> /// <param name="division">The division.</param> public override void Visit(IDivision division) { Division mutableDivision = new Division(division); this.resultExpression = this.myCodeCopier.DeepCopy(mutableDivision); }
public override void Visit(IDivision division) { base.Visit(division); Bpl.Expr rexp = TranslatedExpressions.Pop(); Bpl.Expr lexp = TranslatedExpressions.Pop(); TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Div, lexp, rexp)); }
/// <summary> /// Returns a deep copy of the given division expression. /// </summary> /// <param name="division"></param> public Division Copy(IDivision division) { var mutableCopy = this.shallowCopier.Copy(division); this.CopyChildren((BinaryOperation)mutableCopy); return mutableCopy; }
/// <summary> /// /// </summary> /// <param name="division"></param> public Division(IDivision division) : base(division) { }
/// <summary> /// Returns a shallow copy of the given division expression. /// </summary> /// <param name="division"></param> public Division Copy(IDivision division) { return new Division(division); }
public void Visit(IDivision division) { this.result = this.copier.Copy(division); }
public void Factory() { collections = new RomanNumberCollection(); division = new Division(); }
public override void TraverseChildren(IDivision division) { var needsParen = LowerPrecedenceThanParentExpression(division); var savedCurrentPrecedence = this.currentPrecedence; this.currentPrecedence = this.Precedence(division); if (needsParen) this.sourceEmitterOutput.Write("("); this.Traverse(division.LeftOperand); if (division.LeftOperand is ITargetExpression) this.sourceEmitterOutput.Write(" /= "); else this.sourceEmitterOutput.Write(" / "); this.Traverse(division.RightOperand); if (needsParen) this.sourceEmitterOutput.Write(")"); this.currentPrecedence = savedCurrentPrecedence; }
public override void TraverseChildren(IDivision division) { var targetExpression = division.LeftOperand as ITargetExpression; if (targetExpression != null) { // x /= e bool statement = this.currentExpressionIsOpAssignStatement; this.currentExpressionIsOpAssignStatement = false; this.VisitAssignment(targetExpression, division, (IExpression e) => this.TraverseDivisionRightOperandAndDoOperation(e), treatAsStatement: statement, pushTargetRValue: true, resultIsInitialTargetRValue: division.ResultIsUnmodifiedLeftOperand); } else { // x / e this.Traverse(division.LeftOperand); this.TraverseDivisionRightOperandAndDoOperation(division); } }
/// <summary> /// Rewrites the given division expression. /// </summary> /// <param name="division"></param> public virtual IExpression Rewrite(IDivision division) { var mutableDivision = division as Division; if (mutableDivision == null) return division; this.RewriteChildren(mutableDivision); return mutableDivision; }