コード例 #1
0
ファイル: SpawnItem.cs プロジェクト: DieselPuppet/DatingDash
        public static SpawnItem Load(XmlElement elem, ILog log)
        {
            string type = elem.Name;
            if (!Pack.SpawnItemConfig.Types.Keys.Contains(type))
                throw new CommonException("Unknown type: {0}", type);

            var result = new SpawnItem(type, elem.GetFloatAttribute(DelayAttribName));

            foreach (XmlElement attachElem in elem.GetChildElements())
            {
                try
                {
                    result.Attachments.Add(SpawnItemAttachment.Load(attachElem));
                }
                catch (Exception ex)
                {
                    log.Write("Error while loading attachment: {0}. Skipped.", ex.Message);
                }
            }

            return result;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: taucode/taucode
        private CodeGenerator CreateCodeGenerator(XmlElement domainEl)
        {
            string[] dlls = domainEl.GetMandatoryAttribute("dlls").Split(',');
            CodeGenerator gen = new CodeGenerator();
            XmlElement[] entryEls = domainEl.GetChildElements("entry");

            _namedEntries.Clear();

            foreach (XmlElement entryEl in entryEls)
            {
                string typeName = entryEl.GetMandatoryAttribute("handle-interface");
                string entryName = entryEl.GetMandatoryAttribute("entry-name");

                Type handleInterfaceType = null;

                for (int i = 0; i < dlls.Length; i++)
                {
                    string fullDllPath = Path.Combine(Directory.GetCurrentDirectory(), dlls[i]);
                    Assembly asm = Assembly.LoadFile(fullDllPath);
                    handleInterfaceType = asm.GetType(typeName);
                    if (handleInterfaceType != null)
                    {
                        break;
                    }
                }

                if (handleInterfaceType == null)
                {
                    throw new ApplicationException(); // todo2[ak]
                }

                CodeGeneratorEntry entry = new CodeGeneratorEntry(handleInterfaceType);
                gen.AddEntry(entry);

                _namedEntries[entryName] = entry;
            }

            return gen;
        }
コード例 #3
0
ファイル: SpawnLine.cs プロジェクト: DieselPuppet/DatingDash
        public void Load(XmlElement elem, ILog log)
        {
            if (elem.Name != ElementName)
                throw new LevelXmlException("Unexpected element name: \"{0}\". Expected: \"{1}\".", elem.Name, ElementName);

            Clear();
            foreach (XmlElement itemElem in elem.GetChildElements())
            {
                try
                {
                    _items.Add(SpawnItem.Load(itemElem, log));
                }
                catch(Exception ex)
                {
                    log.Write("Error while loading spawn item: {0}. Item is skipped.", ex.Message);
                }
            }
        }