コード例 #1
0
        public void Visit(IVisitor visitor, CEnum cenum)
        {
            CodeWriter.WriteLine($"namespace {cenum.Namespace}");
            CodeWriter.WriteLine("{");
            CodeWriter.Indent();

            CodeWriter.WriteLine($"public enum {cenum.EnumName}");
            CodeWriter.WriteLine("{");
            CodeWriter.Indent();
            bool first = true;

            foreach (var v in cenum.EnumValues)
            {
                if (!first)
                {
                    CodeWriter.WriteLine(",");
                }

                CodeWriter.Write($"{v.EnumValueName} = {v.EnumValue}");

                first = false;
            }
            CodeWriter.WriteLine();
            CodeWriter.Unindent();
            CodeWriter.WriteLine("}");

            CodeWriter.Unindent();
            CodeWriter.WriteLine("}");
        }
コード例 #2
0
 public void VisitEnum(CEnum eration)
 {
     if (canGenerate(eration))
     {
         classname = eration.RawName;
         visitor.VisitEnum(eration);
         classname = "";
     }
 }
コード例 #3
0
ファイル: Translator.cs プロジェクト: YSheldon/cdef
        public CEnum TranslateEnum(IDiaSymbol sym)
        {
            IDiaEnumSymbols symbols;

            sym.findChildren(SymTagEnum.SymTagNull, null, 0, out symbols);

            CEnum res = new CEnum();

            foreach (IDiaSymbol constant in symbols)
            {
                res.Add(constant.name, (uint)constant.value);
            }
            return(res);
        }
コード例 #4
0
        public CEnum Convert(CProtoEnum protoEnum)
        {
            var e = new CEnum()
            {
                EnumName = $"{protoEnum.EnumName}"
            };

            foreach (var v in protoEnum.EnumValue)
            {
                e.EnumValues.Add(new CEnumValue()
                {
                    EnumValueName = v.EnumValueName, EnumValue = v.EnumValueNumber
                });
            }

            return(e);
        }
コード例 #5
0
 private static void UpdateNames(Type i_oType)
 {
     if (i_oType == null)
     {
         return;
     }
     FieldInfo[] aoFieldInfo = i_oType.GetFields(BindingFlags.Public | BindingFlags.Static);
     foreach (FieldInfo oFieldInfo in aoFieldInfo)
     {
         CEnum oEnumResult = oFieldInfo.GetValue(null) as CEnum;
         if (oEnumResult == null)
         {
             continue;
         }
         oEnumResult.Name = oFieldInfo.Name;
     }
 }
コード例 #6
0
        private void frmConfig_Load(object sender, EventArgs e)
        {
            //DataTable dt = GetTable();
            //if (dt.Rows.Count == 0)
            //{
            //    dt.Rows.Add(dt.NewRow());
            //}

            this.Text += " " + Application.ProductVersion;

            DataTable dt = CEnum.GetDataTableByValueNameDescription <SyncTypes>();

            cboSyncType.ValueMember   = "Name";
            cboSyncType.DisplayMember = "Name";
            cboSyncType.DataSource    = dt;

            RestoreConfig();

            //grvList.Columns["FtpPassword"].Visible = false;
        }
コード例 #7
0
        /// <inheritdoc />
        public override CProcessorParseResult Parse(string str, CProcessorState state)
        {
            if (!state.Values.GetValue <bool>("InEnum"))
            {
                str = str.Substring("enum ".Length).Trim();
                var openIndex = str.IndexOf("{", StringComparison.CurrentCulture);
                var name      = str.Substring(0, openIndex).Trim();
                state.Values.SetValue("InEnum", true);
                var e = new CEnum(name, state.CurrentTree);
                state.CurrentTree.AddSubTree(e);

                return(new CProcessorParseResult(e, false, string.Empty));
            }

            str = str.Trim();
            var equalIndex = str.IndexOf("=", StringComparison.InvariantCulture);

            if (equalIndex > 0)
            {
                var name = str.Substring(0, equalIndex).Trim();
                str = str.Substring(equalIndex + 1).Trim();
                var nextIndex = str.IndexOf(",", StringComparison.InvariantCulture);
                var value     = nextIndex > 0 ? str.Substring(0, nextIndex).Trim() : str.Trim();
                var eValue    = new CEnumValue(name, value, state.CurrentTree);
                state.CurrentTree.AddSubTree(eValue);

                return(new CProcessorParseResult(state.CurrentTree, false, string.Empty));
            }

            if (str.IndexOf("}", StringComparison.InvariantCulture) >= 0)
            {
                return(new CProcessorParseResult(state.CurrentTree.Parent, true, string.Empty));
            }

            // Skip Line
            return(new CProcessorParseResult(state.CurrentTree, false, string.Empty));
        }
コード例 #8
0
 public void Visit(CEnum cenum)
 {
     _enumVisitor.CodeWriter.Clear();
     _enumVisitor.Visit(this, cenum);
 }
コード例 #9
0
        private static void ProtocolReaderLine()
        {
            if (LineText == "")
            {
                return;
            }
            if (LineText[0] == '$')
            {
                if (LineText.Length >= 2)
                {
                    if (LineText[1] == '$')
                    {
                        MMode2 = LineText.TrimStart('$');
                    }
                    else
                    {
                        MMode1 = LineText.TrimStart('$');
                    }
                }
                return;
            }
            if (LineText[0] == '@')
            {
                ClassDesc = LineText.TrimStart('@');
                return;
            }
            LineText.Trim();
            ProtocolReaderLineAnalyze();

            if (LineContect.Count <= 0)
            {
                return;
            }
            if (LineContect[0] == "enums")
            {
                BodyType    = EBodyType.eBodyTypeEnum;
                EnumCurrent = new CEnum(LineContect[1], ClassDesc);
                CEnumId     = 0;
            }
            else if (LineContect[0] == "enume")
            {
                DictEnum.Add(EnumCurrent.Name, EnumCurrent);
            }
            else if (LineContect[0] == "msgs")
            {
                BodyType = EBodyType.eBodyTypeClass;
                if (LineContect.Count > 2)
                {
                    ClassCurrent = new CClass(0, LineContect[1], ClassDesc, S2I(LineContect[2]));
                }
                else
                {
                    ClassCurrent = new CClass(0, LineContect[1], ClassDesc);
                }
            }
            else if (LineContect[0] == "msge")
            {
                DictClass.Add(ClassCurrent.Name, ClassCurrent);
            }
            else if (LineContect[0] == "pubs")
            {
                BodyType = EBodyType.eBodyTypeClass;
                if (LineContect.Count > 2)
                {
                    ClassCurrent = new CClass(1, LineContect[1], ClassDesc, S2I(LineContect[2]));
                }
                else
                {
                    ClassCurrent = new CClass(1, LineContect[1], ClassDesc);
                }
            }
            else if (LineContect[0] == "pube")
            {
                DictClass.Add(ClassCurrent.Name, ClassCurrent);
            }
            else
            {
                if (BodyType == EBodyType.eBodyTypeEnum)
                {
                    var node = new CEnum.Node()
                    {
                        Line = LineCount,
                        Body = LineContect[0],
                    };
                    if (LineContect.Count > 1)
                    {
                        CEnumId    = S2I(LineContect[1]);
                        node.Value = CEnumId;
                    }
                    else
                    {
                        CEnumId++;
                        node.Value = CEnumId;
                    }
                    node.Desc = LineDesc;
                    EnumCurrent.DictBody.Add(LineCount, node);
                }
                else if (BodyType == EBodyType.eBodyTypeClass)
                {
                    var node = new CClassNode();
                    GetNodeFromLine(ref node);
                    ClassCurrent.DictBody.Add(LineCount, node);
                }
            }
        }
コード例 #10
0
        void tmr_Elapsed(object sender, ElapsedEventArgs e)
        {
            const char Delim = '─';

            if (this.mRunning)
            {
                return;
            }
            else
            {
                this.mRunning = true;
            }

            string LogFullPath      = GetLogFullPath();
            string LogFolderForSync = Path.GetDirectoryName(LogFullPath);

            try
            {
                CXmlConfig xc = GetXmlConfig();

                string[] aRootPathSrc = xc.GetSetting("RootPathSrc", "").Split(Delim);

                string[] aFtpHost = xc.GetSetting("FtpHost", "").Split(Delim);
                string[] aFtpId   = xc.GetSetting("FtpId", "").Split(Delim);

                string[] aFtpPassword = xc.GetSetting("FtpPassword", "").Split(Delim);
                for (int i = 0; i < aFtpPassword.Length; i++)
                {
                    aFtpPassword[i] = CEncrypt.DecryptPassword(aFtpPassword[i]);
                }

                string[] aFtpFolder = xc.GetSetting("FtpFolder", "").Split(Delim);

                string[] aSyncType = xc.GetSetting("SyncType", "").Split(Delim);

                string[] aMinifyJs = xc.GetSetting("MinifyJs", "").Split(Delim);

                string[] aFileNameToAppendParam = xc.GetSetting("FileNameToAppendParam", "").Split(Delim);

                string[]   asDateTimeAfter = xc.GetSetting("DateTimeAfter", "").Split(Delim);
                DateTime[] aDateTimeAfter  = new DateTime[asDateTimeAfter.Length];
                for (int i = 0; i < asDateTimeAfter.Length; i++)
                {
                    aDateTimeAfter[i] = CFindRep.IfNotDateTimeThen19000101(asDateTimeAfter[i]);
                }


                for (int i = 0; i < aRootPathSrc.Length; i++)
                {
                    CFtpInfoSync[] aFtpInfo = new CFtpInfoSync[]
                    {
                        new CFtpInfoSync()
                        {
                            Host     = aFtpHost[i],
                            UserId   = aFtpId[i],
                            Password = aFtpPassword[i],
                            Folder   = aFtpFolder[i]
                        }
                    };

                    CSyncFile sf = new CSyncFile(aRootPathSrc[i], aFtpInfo, CEnum.GetValueByName <SyncTypes>(aSyncType[i]), (aMinifyJs[i] == "1"), aFileNameToAppendParam, aDateTimeAfter[i], LogFolderForSync);
                    sf.DisallowedFolder = new string[] { LogFolderForSync };
                    sf.CopyAll();

                    aDateTimeAfter[i] = DateTime.Now;
                }


                for (int i = 0; i < aDateTimeAfter.Length; i++)
                {
                    asDateTimeAfter[i] = aDateTimeAfter[i].ToString(CConst.Format_yyyy_MM_dd_HH_mm_ss);
                }

                xc.SaveSetting("DateTimeAfter", string.Join(Delim.ToString(), asDateTimeAfter));
            }
            catch (Exception ex)
            {
                CFile.AppendTextToFile(LogFullPath, "Error " + DateTime.Now.ToString()
                                       + "\r\n" + ex.Message
                                       + "\r\n" + ex.StackTrace
                                       + "\r\n" + ex.Source);
            }

            this.mRunning = false;
        }
コード例 #11
0
ファイル: CEnumTest.cs プロジェクト: emacslisp/cs
        public static void TMain(string[] args)
        {
            CEnum s = new CEnum();

            s.EnumInfo();
        }
コード例 #12
0
        private bool IsValid(out SInfo InfoIs, out string ErrMsgIs)
        {
            InfoIs   = new SInfo();
            ErrMsgIs = "";

            DataTable dt = GetTable();

            InfoIs.Name = txtName.Text.Trim();
            if (InfoIs.Name == "")
            {
                ErrMsgIs = "Name not entered.";
                return(false);
            }

            InfoIs.RootFolderSrc = txtRootFolderSrc.Text.Trim();
            if (InfoIs.RootFolderSrc == "")
            {
                ErrMsgIs = "Source Folder not entered.";
                return(false);
            }
            if (!Directory.Exists(InfoIs.RootFolderSrc))
            {
                ErrMsgIs = "Source Folder: " + InfoIs.RootFolderSrc + " is not exists.";
                return(false);
            }

            InfoIs.aRootFolderDest = txtRootFolderDest.Text.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string RootFolderDest in InfoIs.aRootFolderDest)
            {
                if (RootFolderDest != "")
                {
                    if (!Directory.Exists(RootFolderDest))
                    {
                        ErrMsgIs = "Destination Folder: " + RootFolderDest + " is not exists.";
                        return(false);
                    }
                }
            }

            if (txtFtpHost.Text.Trim() != "")
            {
                InfoIs.FtpInfo            = new CFtpInfoSync();
                InfoIs.FtpInfo.Host       = txtFtpHost.Text.Trim();
                InfoIs.FtpInfo.Folder     = txtFtpFolder.Text.Trim();
                InfoIs.FtpInfo.Port       = Convert.ToInt32(nudFtpPort.Value);
                InfoIs.FtpInfo.UsePassive = chkFtpUsePassive.Checked;
                InfoIs.FtpInfo.UserId     = txtFtpId.Text.Trim();
                InfoIs.FtpInfo.Password   = txtFtpPassword.Text.Trim();
            }

            if ((InfoIs.aRootFolderDest.Length == 0) && (InfoIs.FtpInfo == null))
            {
                ErrMsgIs = "Both of Destination Folder and FTP Info is empty.";
                return(false);
            }
            else if ((InfoIs.aRootFolderDest.Length != 0) && (InfoIs.FtpInfo != null))
            {
                ErrMsgIs = "Both of Destination Folder and FTP Info is not empty.";
                return(false);
            }

            InfoIs.IntervalMinutes        = Convert.ToInt32(nudIntervalMinutes.Value);
            InfoIs.SyncType               = CEnum.GetValueByName <SyncTypes>((string)cboSyncType.SelectedValue);
            InfoIs.MinifyJs               = chkMinifyJs.Checked;
            InfoIs.EmptyFolderHasNoFile   = chkEmptyFolderHasNoFile.Checked;
            InfoIs.aFullPathReferencingJs = txtFullPathReferencingJs.Text.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            InfoIs.aJsFullPathRefered     = txtJsFullPathRefered.Text.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            InfoIs.DateTimeAfter          = dtpDateTimeAfter.Value;
            InfoIs.DisallowedExt          = txtDisallowedExt.Text.Trim();
            InfoIs.AllowedOnlyExt         = txtAllowedOnlyExt.Text.Trim();
            InfoIs.DisallowedFolder       = txtDisallowedFolder.Text.Trim();
            InfoIs.AllowedOnlyFolder      = txtAllowedOnlyFolder.Text.Trim();

            InfoIs.LogFolder = txtLogFolder.Text.Trim();
            if (InfoIs.LogFolder == "")
            {
                ErrMsgIs = "Log Folder not entered.";
                return(false);
            }
            if (!Directory.Exists(InfoIs.LogFolder))
            {
                ErrMsgIs = "Log Folder: " + InfoIs.LogFolder + " is not exists.";
                return(false);
            }

            return(true);
        }
コード例 #13
0
 public ActionResult(CEnum errcode, T data, string errdesc)
 {
     ErrCode = errcode;
     Data    = data;
     ErrDesc = errdesc;
 }