コード例 #1
0
ファイル: ecmpluginparams.cs プロジェクト: bakera/ECCM
 public EcmPluginParams(Parser p, Setting s, EcmProject e, MarkedData incoming, int calledCount)
 {
     myParser = p;
     mySetting = s;
     myProject = e;
     myMarkedData = incoming;
     myCalledCount = calledCount;
 }
コード例 #2
0
ファイル: templateregexparser.cs プロジェクト: bakera/ECCM
 // �e���v���[�g�t�@�C���� Regex �p�[�X
 public string Parse(MarkedData md, string templateData)
 {
     // ���݂̃f�[�^��L���v�`��
     myCaptureDataList = GetCapture(templateData, md.InnerData);
     if(myCaptureDataList == null){
         Log.AddWarning("�e���v���[�g�Ɏg�p���錻�݃f�[�^�̃L���v�`�����ł��܂���ł����B");
         return CreateSample(templateData);
     }
     return CreateResult(templateData);
 }
コード例 #3
0
ファイル: parser.cs プロジェクト: bakera/ECCM
        // �e���v���[�g�̒��g�����
        private string InnerTemplateParse(MarkedData md, string templateName, bool commentDelete)
        {
            Type pluginType = null;
            string result = "";

            // �v���O�C����g����ݒ�̏ꍇ�A����
            if(Project.Setting.PluginKind != PluginKind.None){
                if(Project.PluginAssembly != null){
                    string nameSpace = Project.GetPluginNameSpace();
                    // ���O�� - �͖���
                    string pName = nameSpace + '.' + templateName.Replace("-", "");
                    pluginType = Project.PluginAssembly.GetType(pName);
                }

                // �v���O�C�������‚���Ώ���
                if(pluginType != null && pluginType.IsSubclassOf(typeof(EcmPluginBase))){
                    if(!commentDelete) result += md.StartMark;
                    result += ProcessPlugin(pluginType, md);
                    if(!commentDelete) result += md.EndMark;
                    return result;
                }
            }

            // �e���v���[�g��T��
            EcmTemplate template = GetTemplate(templateName);
            if(template.Exists){
                template.Backup();
                string templateResult = null;
                if(Setting.EnableRegexTemplate){
                    if(string.IsNullOrEmpty(md.InnerData)){
                        Log.AddInfo("{0} �e���v���[�g�t�@�C���̐��K�\�����L���ł����A���݃R���e���c�̃f�[�^���������߁A�e���v���[�g����̂܂܎g�p���܂� : {1}", Project.CurrentItem, templateName);
コード例 #4
0
ファイル: parser.cs プロジェクト: bakera/ECCM
        // �G�N�X�|�[�g�̃p�[�X
        private string ExportParse(MarkedData md, bool commentDelete)
        {
            Log.AddInfo("{0} �G�N�X�|�[�g��F�m : {1}", Project.CurrentItem, md.StartMark);

            string result = md.FrontData + md.StartMark;
            // �G�N�X�|�[�g������߂�
            string exportData = myExp[md.MarkName];
            if(exportData == null){
                Log.AddWarning("{0} �G�N�X�|�[�g���ꂽ��e������܂���ł��� : {1}", Project.CurrentItem, md.MarkName);
                result += GeneralParse(md.InnerData, false);
            } else {
                Log.AddInfo("{0} �G�N�X�|�[�g��e����� : {1} (�f�[�^�T�C�Y: {2})", Project.CurrentItem, md.MarkName, exportData.Length);
                result += GeneralParse(exportData, false);
            }
            result += md.EndMark;

            // ����ċA����
            Log.AddInfo("{0} �G�N�X�|�[�g�̌��̃f�[�^����� : {1}", Project.CurrentItem, md.MarkName);
            result += GeneralParse(md.BackData, commentDelete);
            return result;
        }
コード例 #5
0
ファイル: parser.cs プロジェクト: bakera/ECCM
        // �v���O�C������
        // �v���O�C���}�l�[�W������Ă΂�邱�Ƃ�����̂� public
        public string ProcessPlugin(Type pluginType, MarkedData md)
        {
            Log.AddInfo("{0} �v���O�C���𔭌� : {1}", Project.CurrentItem, pluginType.Name);

            // ���̃v���O�C�����Ă΂��͉̂����?
            if(myPluginProcessCounter.ContainsKey(pluginType)){
                myPluginProcessCounter[pluginType]++;
            } else {
                myPluginProcessCounter.Add(pluginType, 1);
            }
            int calledCount = myPluginProcessCounter[pluginType];

            string result = null;
            ConstructorInfo ci = null;
            EcmPluginBase pluginInstance = null;

            try{
                ci = pluginType.GetConstructor(EcmPluginBase.PluginConstractorParams);
                if(ci == null){
                    Log.AddAlert("{0} �R���X�g���N�^���擾�ł��܂���ł����B", Project.CurrentItem);
                    return null;
                }
            } catch(Exception e) {
                Log.AddAlert("{0} �R���X�g���N�^�̎擾���ɗ�O���������܂����B{1}", Project.CurrentItem, e);
                return null;
            }

            try{
                Object o = ci.Invoke(new Object[]{new EcmPluginParams(this, Setting, Project, md, calledCount)});
                pluginInstance = o as EcmPluginBase;
                if(pluginInstance == null){
                    Log.AddAlert("{0} �R���X�g���N�^����s���܂������A�I�u�W�F�N�g���쐬����܂���ł����B", Project.CurrentItem);
                    return null;
                }
            } catch(Exception e) {
                Log.AddAlert("{0} �R���X�g���N�^�̎��s���ɗ�O���������܂����B{1}", Project.CurrentItem, e);
                return null;
            }

            try{
                pluginInstance.Parse();
                result = pluginInstance.Document.ToString();
            } catch(Exception e) {
                Log.AddAlert("{0} �v���O�C���̎��s���ɗ�O���������܂����B{1}", Project.CurrentItem, e);
                return null;
            }

            Log.AddInfo("{0} �v���O�C��{1}�̏��������B���ʂ̕�����:{2}", Project.CurrentItem, pluginType.Name, result.Length);

            return result;
        }
コード例 #6
0
ファイル: markeddata.cs プロジェクト: bakera/ECCM
        // ���\�b�h
        public static MarkedData Parse(string data)
        {
            if(string.IsNullOrEmpty(data)) return null;
            Match sMatch = myOpenerReg.Match(data);
            if(!sMatch.Success) return null;

            string templateKind = sMatch.Groups[1].Value;
            string templateName = sMatch.Groups[2].Value;
            string templateIdName = sMatch.Groups[3].Value;
            string templateParam = sMatch.Groups[4].Value;
            string templateEmptyMark = sMatch.Groups[5].Value;

            // �I���}�[�N�̎�ނ𔻕�
            Regex endMarkReg = null;
            if(templateKind == "="){
                // ��v�f�v���p�e�B
                if(templateEmptyMark != "") return new MarkedData(data, sMatch, null);

                if(templateParam == ""){
                    endMarkReg = myTcReg;
                } else {
                    endMarkReg = myPcReg;
                }
            } else {
                endMarkReg = myEcReg;
            }

            // �I���}�[�N�T��
            Match eMatch = endMarkReg.Match(data);
            for(;;){
                if(!eMatch.Success){
                    throw new ParserException("{0} �ɑΉ�����I���}�[�N������܂���B", templateName);
                }
                string templateEndName = eMatch.Groups[1].Value;
                // ���O���Ή����Ă���� OK(�����I��), �����łȂ��ꍇ�͖������Ď���T��
                if(templateName == templateEndName) break;
                eMatch = eMatch.NextMatch();
            }

            MarkedData result = new MarkedData(data, sMatch, eMatch);
            return result;
        }