private static void ParseText(SectionList list, string page) { if (page.Length <= 0) { return; } int index = 0; while (index < page.Length) { int k = page.IndexOf("<%", index); if (k < 0) { break; // no code blocks found, exit } if (k > 0) { list.Add(new Section(list.Count, page.Substring(index, k - index), SectionType.Text)); } index = k; int j = page.IndexOf("%>", index); if (j <= index) { break; // no matching closing brackets found } list.Add(new Section(list.Count, page.Substring(index + 2, j - (index + 2)), SectionType.Code)); index = j + 2; } list.Add(new Section(list.Count, page.Substring(index), SectionType.Text)); }
private static string ParseDeclarations(SectionList list, string page) { StringBuilder result = new StringBuilder(); Regex reg1 = new Regex("<script[^>]*runat[\\s]*=[\\s]*\"?server\"?[^>]*>", RegexOptions.IgnoreCase); Regex reg2 = new Regex("</\\s*script\\s*>", RegexOptions.IgnoreCase); int index = 0; while (index < page.Length) { // try find start of block Match m1 = reg1.Match(page, index); if (!m1.Success) { break; // exit loop here } //start <script> found, now find end. Match m2 = reg2.Match(page, m1.Index + m1.Length); if (!m2.Success) { break; // exit loop here } result.Append(page.Substring(index, m1.Index - index)); string block = page.Substring(m1.Index + m1.Length, m2.Index - (m1.Index + m1.Length)); Section s = new Section(list.Count, block, SectionType.Declaration); list.Add(s); index = m2.Index + m2.Length; } result.Append(page.Substring(index)); return(result.ToString()); }
/// <summary> /// Iniファイルのテキストからセクション読み込み /// </summary> /// <param name="text"></param> public void ReadIniSection(string text) { using (var sr = new StringReader(text)) { Section section = null; Regex reg_section = new Regex(@"(?<=\s*\[).+(?=\])"); string readLine = ""; while ((readLine = sr.ReadLine()) != null) { if (reg_section.IsMatch(readLine)) { section = new Section(reg_section.Match(readLine).Value); SectionList.Add(section); continue; } else if (readLine.Contains("=")) { if (section == null) { section = new Section(); SectionList.Add(section); } section.SetEntryWithoutCheckEqual(readLine); } } } }
private ConfigEntryUtill(string section, params string[] keys) : base() { //MyLog.LogDebug("ConfigEntryUtill.ctor", section, keys.Length); this.section = section; SectionList.Add(section, this); Add(keys.ToList()); }
private ConfigEntryUtill(string section, T defaultValue) : base() { //MyLog.LogDebug("ConfigEntryUtill.ctor", section); this.section = section; this.defaultValue = defaultValue; SectionList.Add(section, this); }
private void LoadFromFile(string file) { var contract = Serializer <Contract> .Deserialize(File.ReadAllText(file)); if (contract != null) { MyModel = contract; MyModuleType = contract.ModuleType; } // get list of sections // reset SectionList.Clear(); // update _dataFactory.DbSource = DbSource; // populate SectionList name of Sections var dataEntryContract = _dataFactory.GetMetaQueryable <DataEntryContract>().FirstOrDefault(d => d.ModuleType == MyModuleType); if (dataEntryContract != null) { dataEntryContract.Sections.ForEach(s => SectionList.Add(s.Name)); } sectionList.ItemsSource = SectionList; }
/// <summary> /// Add a section to the geo polyline /// </summary> /// <param name="section"></param> public void Add(GeoBase section) { // if the section is the right type and // is connected to the other sections switch (section.GeometryEntityType) { case GeometryEntityTypes.Vertex: throw new ArgumentException("The Argument Provided should be either a " + $"{typeof(GeoLine)} or a {typeof(GeoArc)} not " + $"a {typeof(Vertex)}"); case GeometryEntityTypes.GeoLine: // Todo: Add Exception Throw if section is out of range SectionList.Add(section); IsCounterClockWise = IsCounterClockWiseCalc(); Length += ((GeoLine)section).Length; Area += ((GeoLine)section).Area; break; case GeometryEntityTypes.GeoArc: // Todo: Add Exception Throw if section is out of range SectionList.Add(section); IsCounterClockWise = IsCounterClockWiseCalc(); Length += ((GeoArc)section).Length; Area += CalcAreaGeoArc((GeoArc)section); break; default: throw new ArgumentOutOfRangeException(); } }
public CourseComponentsModel(List <Section> s) { foreach (var x in s) { SectionList.Add(new SectionModel(x)); } }
private void SaveSection() { SectionModel sec = new SectionModel(); sec = CurrentSection; SectionList.Add(sec); }
public SectionList Load() { var sectionList = new SectionList(); var globalSection = new Section("Global"); Item settingsRoot = _database.GetItem(_settingsRoot); sectionList.Add(GetSettings(settingsRoot, globalSection, settingsRoot.Name)); return sectionList; }
public SectionList Load() { var sectionList = new SectionList(); var globalSection = new Section("Global"); Item settingsRoot = _database.GetItem(_settingsRoot); sectionList.Add(GetSettings(settingsRoot, globalSection, settingsRoot.Name)); return(sectionList); }
private SectionList GetActiveSections() { SectionList activeSections = new SectionList(); foreach (Section section in _sections) { if (section.IsActive(_context)) { activeSections.Add(section); } } return(activeSections); }
/// <summary> /// The Main GeoPolyLine Constructor /// </summary> /// <param name="xValues">X Coordinates</param> /// <param name="yValues">Y Coordinates</param> /// <param name="bulgeList">A List of Bulges</param> /// <param name="polylineFlag">The isClosed Property of a polyline</param> public GeoPolyline(List <double> xValues, IReadOnlyList <double> yValues, IReadOnlyList <double> bulgeList, bool polylineFlag) { // Throw Exception if the number of vertices does not match the if (xValues.Count != yValues.Count) { throw new EntityException("There must be a matching number of vertices"); } // Initialize and preallocate the vertex list Vertices = new List <Vertex>(xValues.Capacity); // Initializing a pre-allocating the section list SectionList = polylineFlag ? new List <GeoBase>(Vertices.Capacity) : new List <GeoBase>(Vertices.Capacity - 1); // Place x and y into the vertices list Vertices.AddRange(xValues.Select((t, vertexIndex) => new Vertex(t, yValues[vertexIndex]))); // Iterate through all of the vertices and build either GeoArcs or GeoLines for (var vertexIndex = 0; vertexIndex < Vertices.Count; ++vertexIndex) { var currentVertex = Vertices[vertexIndex]; var nextVertex = vertexIndex == Vertices.Count - 1 ? Vertices[0] : Vertices[vertexIndex + 1]; if (Math.Abs(bulgeList[vertexIndex] - Bulge.BulgeNull) > GeoMath.Tolerance) { var geoArc = new GeoArc(currentVertex, nextVertex, bulgeList[vertexIndex]); geoArc.PropertyChanged += GeoArcOnPropertyChanged; SectionList.Add(geoArc); } else { var geoLine = new GeoLine(currentVertex, nextVertex); geoLine.PropertyChanged += GeoLineOnPropertyChanged; SectionList.Add(new GeoLine(currentVertex, nextVertex)); } if (!polylineFlag) { SectionList.RemoveAt(SectionList.Count - 1); } } UpdateGeometry(string.Empty); }
public void LoadString(string str) { if (string.IsNullOrEmpty(str)) { return; } ConfigSection section = GetFirstSection(ref str); while (section != null) { SectionList.Add(section); section = GetFirstSection(ref str); } }
private SectionList GetConfigurationSections(string schemaPath) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(schemaPath); SectionList sectionList = new SectionList(); XmlElement documentElement = xmlDocument.DocumentElement; foreach (XmlNode xmlNode in documentElement.ChildNodes) { if (xmlNode.LocalName.Equals("sectionSchema", StringComparison.InvariantCultureIgnoreCase)) { sectionList.Add(new SectionDefinition(xmlNode.Attributes["name"].Value)); } } return(sectionList); }
private static string ParseDirectives(SectionList list, string page) { // finds directives //<%\s*@\s*(?<directive>[\w]*)[^%]*%> //<%\s*@\s*(?<directive>[\w]*)\s*(?<p1>[\w]*)\s*=(?<v1>[^\s%]*)[^%]*%> // parses the directive and up to 4 name/value pairs //<%\s*@\s*(?<directive>[\w]*)\s*((?<p1>[\w]*)\s*=(?<v1>[^\s%]*))?\s*((?<p2>[\w]*)\s*=(?<v2>[^\s%]*))?\s*((?<p3>[\w]*)\s*=(?<v3>[^\s%]*))?\s*((?<p4>[\w]*)\s*=(?<v4>[^\s%]*))?[^%]*%> StringBuilder result = new StringBuilder(); //Regex reg =new Regex(@"<%\s*@\s*(?<directive>[\w]*)[^%]*%>", RegexOptions.IgnoreCase); Regex reg = new Regex(@"<%\s*@\s*(?<directive>[\w]*)\s*((?<p1>[\w]*)\s*=(?<v1>[^\s%]*))?\s*((?<p2>[\w]*)\s*=(?<v2>[^\s%]*))?\s*((?<p3>[\w]*)\s*=(?<v3>[^\s%]*))?\s*((?<p4>[\w]*)\s*=(?<v4>[^\s%]*))?[^%]*%>", RegexOptions.IgnoreCase); MatchCollection mc = reg.Matches(page); int index = 0; foreach (Match m in mc) { result.Append(page.Substring(index, m.Index - index)); DirectiveValues dvs = new DirectiveValues(m.Groups["directive"].Value.ToLower()); if (m.Groups["p1"].Value != string.Empty) { dvs.Add(m.Groups["p1"].Value.ToLower(), StripQuotes(m.Groups["v1"].Value)); } if (m.Groups["p2"].Value != string.Empty) { dvs.Add(m.Groups["p2"].Value.ToLower(), StripQuotes(m.Groups["v2"].Value)); } if (m.Groups["p3"].Value != string.Empty) { dvs.Add(m.Groups["p3"].Value.ToLower(), StripQuotes(m.Groups["v3"].Value)); } if (m.Groups["p4"].Value != string.Empty) { dvs.Add(m.Groups["p4"].Value.ToLower(), StripQuotes(m.Groups["v4"].Value)); } Section s = new Section(list.Count, page.Substring(m.Index, m.Length), SectionType.Directive, dvs); list.Add(s); index = m.Index + m.Length; } result.Append(page.Substring(index)); return(result.ToString()); }
private static SectionList GetConfigurationSections(string sectionGroupName, IAppHostSectionGroup sectionGroup) { SectionList sectionList = new SectionList(); string text = string.IsNullOrEmpty(sectionGroupName) ? sectionGroup.Name : (sectionGroupName + "/" + sectionGroup.Name); for (uint num = 0u; num < sectionGroup.Count; num += 1u) { IAppHostSectionGroup sectionGroup2 = sectionGroup[num]; SectionList configurationSections = GetConfigurationSections(text, sectionGroup2); sectionList.AddRange(configurationSections); } IAppHostSectionDefinitionCollection sections = sectionGroup.Sections; for (uint num2 = 0u; num2 < sections.Count; num2 += 1u) { IAppHostSectionDefinition appHostSectionDefinition = sections[num2]; sectionList.Add(new SectionDefinition(string.IsNullOrEmpty(text) ? appHostSectionDefinition.Name : (text + "/" + appHostSectionDefinition.Name), (AllowDefinition)Enum.Parse(typeof(AllowDefinition), appHostSectionDefinition.AllowDefinition, true), (OverrideModeDefault)Enum.Parse(typeof(OverrideModeDefault), appHostSectionDefinition.OverrideModeDefault, true), appHostSectionDefinition.Type)); } return(sectionList); }
private void btnSubmit_Click(object sender, EventArgs e) { Section sec = new Section(); sec.setID(this.txtSecID.Text.ToString()); sec.InstructorID = this.cmbInstructor.SelectedItem.ToString(); sec.TaughtCourseID = this.cmbTCourse.SelectedItem.ToString(); sec.Capacity = this.txtCapacity.Text.ToString(); sections.Add(sec); if (sec.getValid() == true) { MessageBox.Show("Section have been added successfully."); } else { MessageBox.Show("An error has occured. Record was not added."); } nextID(); clear(); }
private SectionList GetActiveSections () { SectionList activeSections = new SectionList (); foreach (Section section in _sections) { if (section.IsActive (_context)) activeSections.Add (section); } return activeSections; }
private ConfigEntryUtill() : base() { //MyLog.LogDebug("ConfigEntryUtill.ctor", sectionMain); SectionList.Add(sectionMain, this); }
public MainViewModel() { SubjectModel A1 = new SubjectModel() { Name = "Chemistry", SubjectCode = "111", Units = 3 }; SubjectModel A2 = new SubjectModel() { Name = "Algebra", SubjectCode = "222", Units = 3 }; SubjectModel A3 = new SubjectModel() { Name = "Calculus", SubjectCode = "333", Units = 3 }; SubjectModel A4 = new SubjectModel() { Name = "Differential Eq.", SubjectCode = "444", Units = 3 }; SubjectModel A5 = new SubjectModel() { Name = "Statics", SubjectCode = "555", Units = 3 }; SubjectModel A6 = new SubjectModel() { Name = "Dynamics", SubjectCode = "666", Units = 3 }; SubjectModel A7 = new SubjectModel() { Name = "Ciruits", SubjectCode = "777", Units = 3 }; SubjectModel A8 = new SubjectModel() { Name = "Sociology", SubjectCode = "888", Units = 3 }; SubjectModel A9 = new SubjectModel() { Name = "Physics", SubjectCode = "999", Units = 3 }; SubjectModel A10 = new SubjectModel() { Name = "Theology", SubjectCode = "101", Units = 3 }; SubjectList.Add(A1); SubjectList.Add(A2); SubjectList.Add(A3); SubjectList.Add(A4); SubjectList.Add(A5); SubjectList.Add(A6); SubjectList.Add(A7); SubjectList.Add(A8); SubjectList.Add(A9); SubjectList.Add(A10); StudentModel q = new StudentModel() { FirstName = "Gil", LastName = "Bancud", RequiredUnits = 6 }; StudentList.Add(q); SectionModel p = new SectionModel() { SectionName = "SEC1" }; SectionList.Add(p); AdviserModel r = new AdviserModel() { LastName = "Adviser1" }; AdviserList.Add(r); }