Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportComponentBase"/> class with default settings.
 /// </summary>
 public ReportComponentBase()
 {
     border             = new Border();
     fill               = new SolidFill();
     hyperlink          = new Hyperlink(this);
     bookmark           = "";
     exportable         = true;
     flagUseFill        = true;
     flagUseBorder      = true;
     flagPreviewVisible = true;
     flagSerializeStyle = true;
     shiftMode          = ShiftMode.Always;
     style              = "";
     evenStyle          = "";
     hoverStyle         = "";
     printOn            = PrintOn.FirstPage | PrintOn.LastPage | PrintOn.OddPages | PrintOn.EvenPages | PrintOn.RepeatedBand | PrintOn.SinglePage;
     beforePrintEvent   = "";
     afterPrintEvent    = "";
     afterDataEvent     = "";
     clickEvent         = "";
     cursor             = Cursors.Default;
     mouseMoveEvent     = "";
     mouseUpEvent       = "";
     mouseDownEvent     = "";
     mouseEnterEvent    = "";
     mouseLeaveEvent    = "";
     backlight          = false;
     SetFlags(Flags.CanGroup, true);
     if (BaseName.EndsWith("Object"))
     {
         BaseName = ClassName.Substring(0, ClassName.Length - 6);
     }
 }
Пример #2
0
        public override string ToString()
        {
            string typ = ClassName.Equals("LcRevitCollection")
        ? ClassDisplayName
        : ClassName.Substring(7);

            return(typ + " " + DisplayName);
        }
Пример #3
0
        private void CompareWMIClasses()
        {
            Dictionary <string, string> CatagoryPairs = new Dictionary <string, string>
            {
                { "ccm", "CCM" },
                { "cim", "CIM" },
                { "hp", "HP" },
                { "msft", "MSFT" },
                { "office2013", "Office2013" },
                { "sms", "SMS" },
                { "win32", "Win32" },
                { "win32reg", "Win32Reg" }
            };

            foreach (string ClassName in ClassNames)
            {
                int FoundClass = WMIClasses.Where(x => x.Name == ClassName).Count();

                if (FoundClass == 0)
                {
                    string category = string.Empty;
                    if (ClassName.StartsWith("_"))
                    {
                        category = "Internal";
                    }
                    else if (ClassName.Contains("perf"))
                    {
                        category = "Perf";
                    }
                    else
                    {
                        int underscore = ClassName.IndexOf('_');
                        if (underscore > 0)
                        {
                            if (CatagoryPairs.ContainsKey(ClassName.Substring(0, underscore).ToLower()))
                            {
                                category = CatagoryPairs[ClassName.Substring(0, underscore).ToLower()];
                            }
                            else
                            {
                                category = "unknown";
                            }
                        }
                    }
                    WMIClasses.Add(new WMIClass {
                        Name     = ClassName,
                        Catagory = category,
                        Status   = "Unknown"
                    });
                }
            }
        }
Пример #4
0
        public ResourcesManager(ISettings settings,
                                ProjectItem projectItem, IDocumentsManager documentManager)
        {
            TextDocument        = documentManager.GetTextDocument(projectItem);
            ProjectItemFileName = projectItem.Properties.Item(Constants.FULL_PATH).Value.ToString();
            Window           = documentManager.OpenWindow(ProjectItemFileName);
            Settings         = settings;
            ProjectExtension = System.IO.Path.GetExtension(Window.Project.FullName).Substring(1);

            ResourcesFile = GetResourceFile();
            ResxFileName  = ResourcesFile.Document.FullName;
            Namespace     = GetNamespace();
            CloseResourcesDocuemnt();

            ClassName = System.IO.Path.GetFileNameWithoutExtension(ResxFileName).Replace('.', '_');
            AliasName = ClassName.Substring(0, ClassName.Length - 6);

            IsGlobalResourceFile        = Settings.IsUseGlobalResourceFile && string.IsNullOrEmpty(Settings.GlobalResourceFileName);
            IsDontUseResourceUsingAlias = Settings.IsUseGlobalResourceFile && Settings.IsDontUseResourceAlias;
        }
        public override void InitFromSnippetsParms(SnippetsParms snippetsParms)
        {
            ClassName = snippetsParms.GetParmStr(ClassNameParm);
            GenerateReportController = snippetsParms.GetParmBool(GenerateReportControllerParm);
            GenerateReportDP         = snippetsParms.GetParmBool(GenerateReportDPParm);
            ReportDPTableName        = snippetsParms.GetParmStr(ReportDPTableNameParm);
            if (String.IsNullOrWhiteSpace(ReportDPTableName))
            {
                ReportDPTableName = "TableTemDB";
            }
            ReportDPTableVarName = AxHelper.GetVarNameFromType(ReportDPTableName);
            string baseStr = ClassName;

            if (ClassName.ToLower().EndsWith("contract"))
            {
                baseStr = ClassName.Substring(0, ClassName.Length - "contract".Length);
            }
            ClassNameDP         = $"{baseStr}DP";
            ClassNameController = $"{baseStr}Controller";

            List <List <string> > parmList = snippetsParms.GetParmListSeparated(ParametersParmName);

            FieldsList = new List <DataContractBuilderVar>();
            GroupsList = new List <DataContractBuilderVar>();
            int groupNum = 0;

            IsAnyMandatory = false;

            Dictionary <string, int> groutPosDict = new Dictionary <string, int>();

            foreach (List <string> subList in parmList)
            {
                DataContractBuilderVar builderVar = new DataContractBuilderVar();

                string item = subList[0];
                if (item[item.Length - 1] == MandatoryPropertySym)//check mandatory
                {
                    builderVar.IsMandatory = true;
                    builderVar.Type        = item.Remove(item.Length - 1).Trim();
                }
                else
                {
                    builderVar.IsMandatory = false;
                    builderVar.Type        = item;
                }

                if (String.IsNullOrEmpty(builderVar.Type))
                {
                    throw new Exception("Type should be specified");
                }

                if (subList.Count > 1 && !String.IsNullOrWhiteSpace(subList[1]))  //check var name
                {
                    builderVar.Name = subList[1];
                }
                else
                {
                    builderVar.Name = AxHelper.GetVarNameFromType(builderVar.Type);
                }
                if (subList.Count > 2 && !String.IsNullOrWhiteSpace(subList[2]))
                {
                    builderVar.Label = subList[2];
                }
                if (subList.Count > 3 && !String.IsNullOrWhiteSpace(subList[3]))
                {
                    builderVar.LabelHelp = subList[3];
                }
                if (subList.Count > 4 && !String.IsNullOrWhiteSpace(subList[4]))
                {
                    builderVar.GroupName = subList[4];
                }
                if (subList.Count > 5 && !String.IsNullOrWhiteSpace(subList[5]))
                {
                    builderVar.GroupLabel = subList[5];
                }

                //calculate
                if (!groutPosDict.ContainsKey(builderVar.GroupName))
                {
                    groutPosDict.Add(builderVar.GroupName, 0);
                    if (!String.IsNullOrWhiteSpace(builderVar.GroupName))
                    {
                        groupNum++;
                        var varGr = new DataContractBuilderVar
                        {
                            GroupName       = builderVar.GroupName,
                            GroupLabel      = builderVar.GroupLabel,
                            PositionInGroup = groupNum
                        };
                        GroupsList.Add(varGr);
                    }
                }
                groutPosDict[builderVar.GroupName]++;
                if (builderVar.IsMandatory)
                {
                    IsAnyMandatory = true;
                }

                builderVar.PositionInGroup = groutPosDict[builderVar.GroupName];

                FieldsList.Add(builderVar);
            }
        }
Пример #6
0
        //解析代码
        void parse()
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            if (code_model_ == null)
            {
                throw new Exception("代码模型不能为空");
            }

            CodeElements codes = code_model_.CodeElements;

            //查找命名空间,只支持第一命名空间
            CodeNamespace codeNamespace = null;

            for (int i = 1; i <= codes.Count; i++)
            {
                if (codes.Item(i).Kind == vsCMElement.vsCMElementNamespace)
                {
                    codeNamespace = codes.Item(i) as CodeNamespace;
                    break;
                }
            }
            if (codeNamespace == null)
            {
                throw new Exception("未找到命名空间定义");
            }
            NamespaceName = codeNamespace.Name;

            //查找类或定义,只支持第一个类或接口定义
            CodeClass     codeClass     = null;
            CodeInterface codeInterface = null;

            for (int i = 1; i <= codeNamespace.Members.Count; i++)
            {
                if (codeNamespace.Members.Item(i).Kind == vsCMElement.vsCMElementClass)
                {
                    codeClass = codeNamespace.Members.Item(i) as CodeClass;
                    break;
                }
                else if (codeNamespace.Members.Item(i).Kind == vsCMElement.vsCMElementInterface)
                {
                    codeInterface = codeNamespace.Members.Item(i) as CodeInterface;
                    break;
                }
            }
            if (codeClass == null)
            {
                throw new Exception("未找到类或接口定义");
            }
            if (codeClass != null)
            {
                ShortClassName = codeClass.Name;
                ClassName      = codeClass.FullName.Replace($"{this.NamespaceName}.", "");
                IsAbstract     = codeClass.IsAbstract;
                if (ClassName.IndexOf("<") != -1)
                {
                    var s = ClassName.IndexOf("<") + 1;
                    var l = ClassName.Length - s - 1;
                    GenericTypeArguments = ClassName.Substring(s, l).Split(',').Select(it => it.Trim()).ToList();
                }
                parse_body(codeClass);
            }
            //else
            //{
            //    ClassName = codeInterface.Name;
            //    parse_body(codeInterface);
            //}
        }
        private void GenerateGetWithIDTestCode(string TypeName, string TypeNameLower, List <Type> types, StringBuilder sb)
        {
            sb.AppendLine($@"        #region Tests Generated for Get{ TypeName }With{ TypeName }ID({ TypeNameLower }.{ TypeName }ID)");
            sb.AppendLine(@"        [TestMethod]");
            sb.AppendLine($@"        public void Get{ TypeName }With{ TypeName }ID__{ TypeNameLower }_{ TypeName }ID__Test()");
            sb.AppendLine(@"        {");
            sb.AppendLine(@"            foreach (CultureInfo culture in AllowableCulture)");
            sb.AppendLine(@"            {");
            sb.AppendLine(@"                ChangeCulture(culture);");
            sb.AppendLine(@"");
            sb.AppendLine(@"                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))");
            sb.AppendLine(@"                {");
            sb.AppendLine($@"                    { TypeName }Service { TypeNameLower }Service = new { TypeName }Service(new Query() {{ Lang = culture.TwoLetterISOLanguageName }}, dbTestDB, ContactID);");
            if (TypeName == "Address")
            {
                sb.AppendLine($@"                    { TypeName } { TypeNameLower } = (from c in dbTestDB.{ TypeName }es select c).FirstOrDefault();");
            }
            else
            {
                sb.AppendLine($@"                    { TypeName } { TypeNameLower } = (from c in dbTestDB.{ TypeName }s select c).FirstOrDefault();");
            }
            sb.AppendLine($@"                    Assert.IsNotNull({ TypeNameLower });");
            sb.AppendLine(@"");
            sb.AppendLine(@"                    foreach (string extra in new List<string>() { null, ""A"", ""B"", ""C"", ""D"", ""E"" })");
            sb.AppendLine(@"                    {");
            sb.AppendLine($@"                        { TypeNameLower }Service.Query.Extra = extra;");
            sb.AppendLine(@"");
            sb.AppendLine(@"                        if (string.IsNullOrWhiteSpace(extra))");
            sb.AppendLine(@"                        {");
            sb.AppendLine($@"                            { TypeName } { TypeNameLower }Ret = { TypeNameLower }Service.Get{ TypeName }With{ TypeName }ID({ TypeNameLower }.{ TypeName }ID);");
            sb.AppendLine($@"                            Check{ TypeName }Fields(new List<{ TypeName }>() {{ { TypeNameLower }Ret }});");
            sb.AppendLine($@"                            Assert.AreEqual({ TypeNameLower }.{ TypeName }ID, { TypeNameLower }Ret.{ TypeName }ID);");
            sb.AppendLine(@"                        }");
            List <string> ClassNameList = new List <string>()
            {
                "ExtraA", "ExtraB", "ExtraC", "ExtraD", "ExtraE"
            };

            foreach (string ClassName in ClassNameList)
            {
                Type currentType = null;

                foreach (Type TempType in types)
                {
                    if (TempType.Name == $"{ TypeName }{ ClassName }")
                    {
                        currentType = TempType;
                        break;
                    }
                }

                if (currentType == null)
                {
                    continue;
                }

                sb.AppendLine($@"                        else if (extra == ""{ ClassName.Substring(ClassName.Length - 1) }"")");
                sb.AppendLine(@"                        {");
                sb.AppendLine($@"                            { TypeName }{ ClassName } { TypeNameLower }{ ClassName }Ret = { TypeNameLower }Service.Get{ TypeName }{ ClassName }With{ TypeName }ID({ TypeNameLower }.{ TypeName }ID);");
                sb.AppendLine($@"                            Check{ TypeName }{ ClassName }Fields(new List<{ TypeName }{ ClassName }>() {{ { TypeNameLower }{ ClassName }Ret }});");
                sb.AppendLine($@"                            Assert.AreEqual({ TypeNameLower }.{ TypeName }ID, { TypeNameLower }{ ClassName }Ret.{ TypeName }ID);");
                sb.AppendLine(@"                        }");
            }
            sb.AppendLine(@"                        else");
            sb.AppendLine(@"                        {");
            sb.AppendLine(@"                            //Assert.AreEqual(true, false);");
            sb.AppendLine(@"                        }"); sb.AppendLine(@"                    }");
            sb.AppendLine(@"                }");
            sb.AppendLine(@"            }");
            sb.AppendLine(@"        }");
            sb.AppendLine($@"        #endregion Tests Generated for Get{ TypeName }With{ TypeName }ID({ TypeNameLower }.{ TypeName }ID)");
            sb.AppendLine(@"");
        }
        //HINT: Methods following are copied from TreePanel.cs, ensure to update those if TreePanel.cs changes!
        private D.DifferenceNode _AddClassRecurs(D.DifferenceNode parent, string path, P.Property prop, out string out_title)
        {
            string classname, fullname, label;

            D.DifferenceNode class_item;

            string ClassName, PathName;

            if (prop is P.Actor)
            {
                P.Actor actor = prop as P.Actor;
                ClassName = actor.ClassName.ToString();
                PathName  = actor.PathName.ToString();
            }
            else if (prop is P.Object)
            {
                P.Object obj = prop as P.Object;
                ClassName = obj.ClassName.ToString();
                PathName  = obj.PathName.ToString();
            }
            else
            {
                out_title = null;
                return(null);
            }

            string remain = ClassName.Substring(path.Length);

            if (remain.Contains('/'))
            {
                classname  = remain.Split('/')[0];
                fullname   = path + classname + "/";
                class_item = _AddOrGetClass(parent, fullname, classname);
                return(_AddClassRecurs(class_item, fullname, prop, out out_title));
            }
            if (remain.Contains('.'))
            {
                string[] classnames = remain.Split('.');
                if (classnames.Length == 2)
                {
                    label = PathName;
                    label = label.Substring(label.LastIndexOf('.') + 1);

                    // Before adding more sub-classes, check for both BP_... and FG... condition
                    if ("BP_" + label != classnames[0] && "FG_" + label != classnames[0])
                    {
                        fullname   = path + classnames[0] + ".";
                        class_item = _AddOrGetClass(parent, fullname, classnames[0]);

                        // Ignore [1] or add both?
                        if (classnames[0] + "_C" != classnames[1])
                        {
                            fullname  += classnames[1];
                            class_item = _AddOrGetClass(class_item, fullname, classnames[1]);
                        }

                        // To collect things following into a sub node ('BP_PlayerState_C_0' with data below):
                        //		.PathName = str:'Persistent_Level:PersistentLevel.BP_PlayerState_C_0.FGRecipeShortcut_#'
                        // with # = [0,9]
                        // Or following ('Char_Player_C_0' with data below):
                        //		.PathName = str:'Persistent_Level:PersistentLevel.Char_Player_C_0.BackSlot'
                        //		.PathName = str:'Persistent_Level:PersistentLevel.Char_Player_C_0.ArmSlot'
                        // Will also take care of showing actual entity in case we're showing
                        // something like an inventory:
                        //		.PathName = str:'Persistent_Level:PersistentLevel.Char_Player_C_0.inventory'
                        string[] labels = PathName.Split('.');
                        if (labels.Length == 3)
                        {
                            fullname  += "." + labels[1];
                            class_item = _AddOrGetClass(class_item, fullname, labels[1]);
                        }
                    }
                    else
                    {
                        class_item = parent;
                    }

                    //return _AddItem(class_item, label, null, null);
                    out_title = label;
                    return(class_item);
                }
                Log.Warning("AddClassRecurs: What to do with '{0}'?", ClassName);
            }

            // At the end of our path, add property
            label = PathName;
            label = label.Substring(label.IndexOf('.') + 1);
            //return _AddItem(parent, label, null, null);
            out_title = label;
            return(parent);
        }