/// <summary> /// Initializes a new instance of the <see cref="SectionParserDefinitionViewModel"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="sectionParser">The section parser to use.</param> public SectionParserDefinitionViewModel(SectionDefinitionViewModel parent, ISectionParser sectionParser) : this() { Assertions.AssertNotNull(parent, "parent"); Assertions.AssertNotNull(sectionParser, "sectionParser"); _parent = parent; _parser = sectionParser; CreateOptionVMs(); }
public ModelToObjParser(ISectionHeaderParser headerParser, ISectionParser sectionParser, IObjParser objParser) { this.headerParser = headerParser; this.sectionParser = sectionParser; this.objParser = objParser; sectionTypes = new Dictionary <uint, Func <Section> > { { 1572868536, () => new Animation() }, { 1982055525, () => new Author() }, { 246692983, () => new Bones() }, { 2058384083, () => new Geometry() }, { 1012162716, () => new Material() }, { 690449181, () => new MaterialGroup() }, { 1646341512, () => new Model() }, { 268226816, () => new Object3D() }, { 3819155914, () => new PassthroughGP() }, { 1686773868, () => new QuatLinearRotationController() }, { 1707874341, () => new SkinBones() }, { 1280342547, () => new Topology() }, }; }
public WhoisParser(ISectionTokenizer sectionTokenizer, ISectionParser sectionParser) { this.SectionTokenizer = sectionTokenizer; this.SectionParser = sectionParser; }
public EpubDetailsProvider(ISectionParser sectionParser) { _sectionParser = sectionParser; }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (tablehandlers.Count == 0) { foreach (PropertyInfo info in doc.Tables.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { object[] attrs = info.GetCustomAttributes(true); foreach (object attr in attrs) { TableAttribute casted = attr as TableAttribute; if (casted != null) { tablehandlers[casted.TableName] = (ISectionParser)Activator.CreateInstance(casted.TableParser); } } } } if (currentParser == null) { if (groupcode == 0 && value.Trim() == "TABLE") { waitingtableheader = true; } else if (waitingtableheader && groupcode == 2 && !ignoretable) { if (tablehandlers.ContainsKey(value.Trim())) { currentParser = tablehandlers[value.Trim()]; waitingtableheader = false; ignoretable = false; firstrecordfound = false; } else { //TODO: generate warning ignoretable = true; } } else if (waitingtableheader && groupcode == 0 && value.Trim() == "ENDTAB") { waitingtableheader = false; ignoretable = false; } } else { if (groupcode == 0 && value.Trim() == "ENDTAB") { currentParser = null; } else { if (groupcode == 0) { firstrecordfound = true; } if (firstrecordfound) { currentParser.ParseGroupCode(doc, groupcode, value); } } } }
public void Load(Stream file) { CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); bool versionwarningsent = false; Dictionary <string, ISectionParser> sectionparsers = new Dictionary <string, ISectionParser>(); sectionparsers["HEADER"] = new HeaderParser(); sectionparsers["CLASSES"] = new ClassParser(); sectionparsers["TABLES"] = new TableParser(); sectionparsers["ENTITIES"] = new EntityParser(); sectionparsers["BLOCKS"] = new BlockParser(); ISectionParser currentParser = null; TextReader reader = new StreamReader(file); LoadState state = LoadState.OutsideSection; int? groupcode; string value; reader.ReadDXFEntry(out groupcode, out value); while (groupcode != null) { switch (state) { case LoadState.OutsideSection: if (groupcode == 0 && value.Trim() == "SECTION") { state = LoadState.InSection; reader.ReadDXFEntry(out groupcode, out value); if (groupcode != 2) { throw new Exception("Sektion gefunden aber keinen Namen zur Sektion"); } value = value.Trim(); if (sectionparsers.ContainsKey(value)) { currentParser = sectionparsers[value]; } } break; case LoadState.InSection: if (groupcode == 0 && value.Trim() == "ENDSEC") { state = LoadState.OutsideSection; //after each section check wether the File Version is set if (Header.AutoCADVersion != null && Header.AutoCADVersion != "AC1014") { if (!versionwarningsent) { try { if (OnFileVersionIncompatible != null) { OnFileVersionIncompatible(this, EventArgs.Empty); } } catch (Exception) { } versionwarningsent = true; } } } else { if (currentParser != null) { currentParser.ParseGroupCode(this, (int)groupcode, value); } } break; default: break; } reader.ReadDXFEntry(out groupcode, out value); } if (state == LoadState.InSection) { throw new Exception("Dateiende erreicht aber immer noch offene Sektion vorhanden"); } Thread.CurrentThread.CurrentCulture = currentCulture; }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (tablehandlers.Count == 0) { foreach (PropertyInfo info in doc.Tables.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { object[] attrs = info.GetCustomAttributes(true); foreach (object attr in attrs) { TableAttribute casted = attr as TableAttribute; if (casted != null) { tablehandlers[casted.TableName] = (ISectionParser)Activator.CreateInstance(casted.TableParser); } } } } if (currentParser == null) { if (groupcode == 0 && value.Trim() == "TABLE") { waitingtableheader = true; } else if (waitingtableheader && groupcode == 2 && !ignoretable) { if (tablehandlers.ContainsKey(value.Trim())) { currentParser = tablehandlers[value.Trim()]; waitingtableheader = false; ignoretable = false; firstrecordfound = false; } else { //TODO: generate warning ignoretable = true; } } else if (waitingtableheader && groupcode == 0 && value.Trim() == "ENDTAB") { waitingtableheader = false; ignoretable = false; } } else { if (groupcode == 0 && value.Trim() == "ENDTAB") { currentParser = null; } else { if (groupcode == 0) { firstrecordfound = true; } if (firstrecordfound) currentParser.ParseGroupCode(doc, groupcode, value); } } }