示例#1
0
        private DefineAttribute GetEnumApprove(string key)
        {
            var defineAttributes = DefineManager.GetLookupByName <EnumApprove>();

            Enum.TryParse(key, out EnumApprove value);
            return(defineAttributes[value.ToString()]);
        }
 protected override void DrawGUI()
 {
     DrawList();
     if (GUILayout.Button("Write Tags to disk", GUILayout.Height(32)))
     {
         WriteDataFile();
         DefineManager.Init();
         Init();
     }
 }
示例#3
0
        public static void MDefineMnaager()
        {
            DefineManager window = EditorWindow.GetWindow <DefineManager>(false, StringsUEME.NOMBRE_MENU_MDEFINE, true);

            if (window != null)
            {
                window.position = new Rect(200, 200, 515, 300);
                window.minSize  = new Vector2(515f, 200f);
            }
        }
        protected override void DrawGUI()
        {
            GUILayout.Label("Please note it is not recomended to change entries you yourself did not add.", EditorStyles.boldLabel);

            DrawTags();
            if (GUILayout.Button("Write defines to disk", GUILayout.Height(32)))
            {
                WriteDataFile();
                DefineManager.Init();
                Init();
            }
        }
示例#5
0
        public void EF_Select_Mapping()
        {
            var expected = new[]
            {
                new
                {
                    IsTransform          = "N",
                    TransformDescription = "未轉換",
                    Status            = "10",
                    StatusDescription = "已開立"
                },
                new
                {
                    IsTransform          = "Y",
                    TransformDescription = "已轉換",
                    Status            = "99",
                    StatusDescription = "已核准"
                }
            };

            using (var dbContext = new LabDbContext())
            {
                var orders = dbContext.Orders
                             .AsNoTracking()
                             .ToList()
                             .Select(p => new
                {
                    p.Id,
                    p.IsTransform,
                    TransformDescription =
                        DefineManager.GetLookupByName <EnumTransfer>()[p.IsTransform]
                        .Description,
                    p.Status,
                    StatusDescription = this.GetEnumApprove(p.Status).Description
                })
                             .ToList()
                ;
                orders.Should()
                .BeEquivalentTo(expected, option =>
                {
                    option.WithoutStrictOrdering();
                    return(option);
                });
            }
        }
示例#6
0
文件: WixFiles.cs 项目: xwiz/WixEdit
        public void LoadWxsFile()
        {
            if (wxsDocument == null)
            {
                wxsDocument = new XmlDocument();
            }

            FileMode mode = FileMode.Open;
            using (FileStream fs = new FileStream(wxsFile.FullName, mode, FileAccess.Read, FileShare.Read))
            {
                wxsDocument.Load(fs);
                fs.Close();
            }

            if (wxsDocument.DocumentElement.GetAttribute("xmlns").ToLower() != WixNamespaceUri.ToLower())
            {
                string errorMessage = String.Format("\"{0}\" has the wrong namespace!\r\n\r\nFound namespace \"{1}\",\r\nbut WiX binaries version \"{2}\" require \"{3}\".\r\n\r\nYou can either convert the WiX source file to use the correct namespace (use WixCop.exe for upgrading from 2.0 to 3.0), or configure the correct version of the WiX binaries in the WixEdit settings.", wxsFile.Name, wxsDocument.DocumentElement.GetAttribute("xmlns"), WixEditSettings.Instance.WixBinariesVersion, WixNamespaceUri);
                throw new WixEditException(errorMessage);
            }

            if (ReadOnly())
            {
                MessageBox.Show(String.Format("\"{0}\" is read-only.", wxsFile.Name), "Read Only!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            XmlNode possibleComment = wxsDocument.FirstChild;
            if (possibleComment.NodeType == XmlNodeType.XmlDeclaration)
            {
                possibleComment = wxsDocument.FirstChild.NextSibling;
            }
            if (possibleComment != null && possibleComment.Name == "#comment")
            {
                string comment = possibleComment.Value;

                string candleArgs = String.Empty;
                string lightArgs = String.Empty;
                bool foundArg = false;
                foreach (string fullLine in comment.Split('\r', '\n'))
                {
                    string line = fullLine.Trim();
                    if (line.Length == 0)
                    {
                        continue;
                    }

                    string candleStart = "candleargs:";
                    if (line.ToLower().StartsWith(candleStart))
                    {
                        candleArgs = line.Remove(0, candleStart.Length);
                        foundArg = true;
                    }

                    string lightStart = "lightargs:";
                    if (line.ToLower().StartsWith(lightStart))
                    {
                        lightArgs = line.Remove(0, lightStart.Length);
                        foundArg = true;
                    }
                }

                if (foundArg == true)
                {
                    wxsDocument.RemoveChild(possibleComment);
                }

                projectSettings = new ProjectSettings(candleArgs.Trim(), lightArgs.Trim());
            }
            else
            {
                projectSettings = new ProjectSettings(String.Empty, String.Empty);
            }

            xsdExtensionPrefixesMap = new Hashtable();
            xsdExtensionPrefixesReverseMap = new Hashtable();
            foreach (XmlAttribute att in wxsDocument.DocumentElement.Attributes)
            {
                string attName = att.Name;
                if (attName.StartsWith("xmlns:"))
                {
                    if (xsdExtensionTargetNamespacesReverseMap.ContainsKey(att.Value))
                    {
                        string existingNamespaceName = (string)xsdExtensionTargetNamespacesReverseMap[att.Value];
                        string namespaceName = attName.Substring(6);
                        if (namespaceName != existingNamespaceName)
                        {
                            xsdExtensionPrefixesMap.Add(namespaceName, existingNamespaceName);
                            xsdExtensionPrefixesReverseMap.Add(existingNamespaceName, namespaceName);
                        }
                    }
                }
            }

            foreach (DictionaryEntry entry in xsdExtensionTargetNamespaces)
            {
                if (xsdExtensionPrefixesMap.ContainsValue(entry.Key) == false)
                {
                    xsdExtensionPrefixesMap.Add(entry.Key, entry.Key);
                    xsdExtensionPrefixesReverseMap.Add(entry.Key, entry.Key);

                    wxsDocument.DocumentElement.SetAttribute("xmlns:" + (string)entry.Key, (string)entry.Value);
                }
            }

            wxsDocument.LoadXml(wxsDocument.OuterXml);

            wxsNsmgr = new XmlNamespaceManager(wxsDocument.NameTable);
            wxsNsmgr.AddNamespace("wix", wxsDocument.DocumentElement.NamespaceURI);
            foreach (DictionaryEntry entry in xsdExtensionTargetNamespaces)
            {
                wxsNsmgr.AddNamespace(LookupExtensionNameReverse((string)entry.Key), (string)entry.Value);
            }

            //init define manager to allow include manager to add dynamic includes
            defineManager = new DefineManager(this, wxsDocument);

            // Init IncludeManager after all doc.LoadXml(doc.OuterXml), because all references to nodes would dissapear!
            includeManager = new IncludeManager(this, wxsDocument);

            //re-init define manager using final includes
            defineManager = new DefineManager(this, wxsDocument);
        }
示例#7
0
        public void GetLookupByName_EnumTransfer_Y()
        {
            var description = DefineManager.GetLookupByName <EnumTransfer>("Y").Description;

            Assert.AreEqual("已轉換", description);
        }
示例#8
0
        public void GetLookupByName_EnumTransfer_N()
        {
            var description = DefineManager.GetLookupByName(typeof(EnumTransfer), "N").Description;

            Assert.AreEqual("未轉換", description);
        }
示例#9
0
        public void GetLookupByName_EnumApprove_Open()
        {
            var description = DefineManager.GetLookupByName <EnumApprove>()["Open"].Description;

            Assert.AreEqual("已開立", description);
        }
示例#10
0
        public void GetLookupByName_EnumApprove_Approve()
        {
            var description = DefineManager.GetLookupByName(typeof(EnumApprove), "Approve").Description;

            Assert.AreEqual("已核准", description);
        }
示例#11
0
        public void GetLookup_By_TransferStatus_Y()
        {
            var description = DefineManager.GetLookup <TransferStatus>()["Y"].Description;

            Assert.AreEqual("已轉換", description);
        }
示例#12
0
        public void GetLookup_By_ApproveStatus_Open()
        {
            var description = DefineManager.GetLookup <ApproveStatus>()["10"].Description;

            Assert.AreEqual("已開立", description);
        }