コード例 #1
0
                //[Variation(Priority = 2, Desc = "Annotation on document without omit - None", Params = new object[] { typeof(XDocument), "Simple.xml", SaveOptions.None })]
                //[Variation(Priority = 2, Desc = "Annotation on document without omit - DisableFormating", Params = new object[] { typeof(XDocument), "Simple.xml", SaveOptions.DisableFormatting })]
                //[Variation(Priority = 2, Desc = "Annotation on element without omit - None", Params = new object[] { typeof(XElement), "Simple.xml", SaveOptions.None })]
                //[Variation(Priority = 2, Desc = "Annotation on element without omit - DisableFormating", Params = new object[] { typeof(XElement), "Simple.xml", SaveOptions.DisableFormatting })]
                public void AnnotationWithoutTheOmitDuplicates()
                {
                    Type        t        = CurrentChild.Params[0] as Type;
                    string      fileName = Path.Combine(s_MyPath, CurrentChild.Params[1] as string);
                    SaveOptions so       = (SaveOptions)CurrentChild.Params[2];

                    using (XmlReader r1 = XmlReader.Create(FilePathUtil.getStream(fileName), new XmlReaderSettings()
                    {
                        IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Ignore
                    }))
                    {
                        XContainer doc = GetContainer(fileName, t);
                        doc.AddAnnotation(so);
                        using (XmlReader r2 = doc.CreateReader())
                        {
                            ReaderDiff.Compare(r1, r2);
                        }
                    }
                }
コード例 #2
0
                //[Variation(Priority = 0, Desc = "No annotation - element", Params = new object[] { typeof(XElement), "Simple.xml" })]
                //[Variation(Priority = 0, Desc = "No annotation - document", Params = new object[] { typeof(XDocument), "Simple.xml" })]
                public void NoAnnotation()
                {
                    Type   t        = CurrentChild.Params[0] as Type;
                    string fileName = Path.Combine(s_MyPath, CurrentChild.Params[1] as string);

                    // create normal reader for comparison
                    using (XmlReader r1 = XmlReader.Create(FilePathUtil.getStream(fileName), new XmlReaderSettings()
                    {
                        IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Ignore
                    }))
                    {
                        // create reader from Xlinq
                        XContainer c = GetContainer(fileName, t);
                        using (XmlReader r2 = c.CreateReader())
                        {
                            ReaderDiff.Compare(r1, r2);
                        }
                    }
                }
コード例 #3
0
        public void Element_ElementsXName()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument           doc      = XDocument.Load(FilePathUtil.getStream(Path.Combine("TestData", "XLinq", "Books.xml")), LoadOptions.PreserveWhitespace);
            IEnumerable <XNode> toRemove = doc.Root.Elements(@"{http://www.books.com/}book").OfType <XNode>();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #4
0
        //[Variation(Priority = 2, Desc = "XDocument.Descendants")]
        public void Document_Descendants()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument           doc      = XDocument.Load(FilePathUtil.getStream(Path.Combine(@"TestData", "XLinq", "Books.xml")), LoadOptions.PreserveWhitespace);
            IEnumerable <XNode> toRemove = doc.Descendants().OfType <XNode>();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = doc.Elements().Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #5
0
        public override int Init(object objParam)
        {
            baselinePath1 = Path.Combine(FilePathUtil.GetTestDataPath(), @"XmlWriter2\");
            string temp = FilePathUtil.GetVariableValue("WriterType").ToUpperInvariant();

            switch (temp)
            {
            case "UTF8WRITER":
                writerType1 = WriterType.UTF8Writer;
                break;

            case "UNICODEWRITER":
                writerType1 = WriterType.UnicodeWriter;
                break;

            case "CUSTOMWRITER":
                writerType1 = WriterType.CustomWriter;
                break;

            case "UTF8WRITERINDENT":
                writerType1 = WriterType.UTF8WriterIndent;
                break;

            case "UNICODEWRITERINDENT":
                writerType1 = WriterType.UnicodeWriterIndent;
                break;

            case "CHARCHECKINGWRITER":
                writerType1 = WriterType.CharCheckingWriter;
                break;

            case "WRAPPEDWRITER":
                writerType1 = WriterType.WrappedWriter;
                break;

            default:
                throw new Exception("Unknown writer type: " + temp);
            }

            writerFactory1 = new XmlCoreTest.Common.WriterFactory(writerType1);
            return(base.Init(objParam));
        }
コード例 #6
0
                //[Variation(Priority = 2, Desc = "On other node types - attributes", Param = typeof(XElement))]
                public void OnOtherNodesAttrs()
                {
                    string fileName = Path.Combine(s_MyPath, "attributes.xml");

                    TestLog.WriteLineIgnore("Loading: .... " + fileName);
                    XElement reF = XElement.Load(FilePathUtil.getStream(fileName));
                    XElement e   = XElement.Load(FilePathUtil.getStream(fileName));

                    e.AddAnnotation(SaveOptions.OmitDuplicateNamespaces);

                    XAttribute[] refAttrs = reF.DescendantsAndSelf().Attributes().ToArray();
                    XAttribute[] eAttrs   = e.DescendantsAndSelf().Attributes().ToArray();

                    for (int i = 0; i < refAttrs.Length; i++)
                    {
                        TestLog.Compare(refAttrs[i].ToString(), eAttrs[i].ToString(), "without annotation on attribute");
                        eAttrs[i].AddAnnotation(SaveOptions.OmitDuplicateNamespaces);
                        TestLog.Compare(refAttrs[i].ToString(), eAttrs[i].ToString(), "with annotation on attribute");
                    }
                }
コード例 #7
0
        public static void CreateNamespaceTestFile(string strFileName)
        {
            Stream     s  = new MemoryStream();
            TextWriter tw = new StreamWriter(s);

            tw.WriteLine("<DOCNAMESPACE>");
            tw.WriteLine("<NAMESPACE0 xmlns:bar=\"1\"><bar:check>Namespace=1</bar:check></NAMESPACE0>");
            tw.WriteLine("<NAMESPACE1 xmlns:bar=\"1\"><a><b><c><d><bar:check>Namespace=1</bar:check></d></c></b></a></NAMESPACE1>");
            tw.WriteLine("<NONAMESPACE>Namespace=\"\"</NONAMESPACE>");
            tw.WriteLine("<EMPTY_NAMESPACE bar:Attr0=\"0\" xmlns:bar=\"1\" />");
            tw.WriteLine("<EMPTY_NAMESPACE1 Attr0=\"0\" xmlns=\"14\" />");
            tw.WriteLine("<NAMESPACE2 xmlns:bar=\"1\"><a><b><c xmlns:bar=\"2\"><d><bar:check>Namespace=2</bar:check></d></c></b></a></NAMESPACE2>");
            tw.WriteLine("<NAMESPACE3 xmlns=\"1\"><a xmlns:a=\"2\" xmlns:b=\"3\" xmlns:c=\"4\"><b xmlns:d=\"5\" xmlns:e=\"6\" xmlns:f='7'><c xmlns:d=\"8\" xmlns:e=\"9\" xmlns:f=\"10\">");
            tw.WriteLine("<d xmlns:g=\"11\" xmlns:h=\"12\"><check>Namespace=1</check><testns xmlns=\"100\"><check100>Namespace=100</check100></testns><check1>Namespace=1</check1><d:check8>Namespace=8</d:check8></d></c><d:check5>Namespace=5</d:check5></b></a>");
            tw.WriteLine("<a13 a:check=\"Namespace=13\" xmlns:a=\"13\" /><check14 xmlns=\"14\">Namespace=14</check14></NAMESPACE3>");
            tw.WriteLine("<NONAMESPACE>Namespace=\"\"</NONAMESPACE>");
            tw.WriteLine("</DOCNAMESPACE>");
            tw.Flush();
            FilePathUtil.addStream(strFileName, s);
        }
コード例 #8
0
        public int SkipAfterReadAttributeValueAndReadValueChunkDoesNotThrow()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Ignore;

            XmlReader reader = XmlReader.Create(FilePathUtil.getStream(this.StandardPath + @"\XML10\ms_xml\vs084.xml"), settings);

            reader.ReadToFollowing("a");
            reader.MoveToNextAttribute();
            reader.ReadAttributeValue();
            reader.ReadValueChunk(new char[3], 0, 3); //<< removing this line works fine.
            reader.Skip();
            CError.Compare(reader.NodeType, XmlNodeType.Whitespace, "NT");
            reader.Read();
            CError.Compare(reader.NodeType, XmlNodeType.Element, "NT1");
            CError.Compare(reader.Name, "a", "Name");

            return(TEST_PASS);
        }
コード例 #9
0
ファイル: ReadBinHex.cs プロジェクト: yang73137/corefx
        //[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "1000000" })]
        //[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "10000000" })]
        public int TestReadBinHex_105376()
        {
            int totalfilesize = Convert.ToInt32(CurVariation.Params[0].ToString());

            CError.WriteLine(" totalfilesize = " + totalfilesize);

            string ascii = new string('c', totalfilesize);

            byte[] bits = Encoding.Unicode.GetBytes(ascii);
            CError.WriteLineIgnore("Count = " + bits.Length);
            string base64str = Convert.ToBase64String(bits);

            string       fileName = "bug105376c_" + CurVariation.Params[0].ToString() + ".xml";
            MemoryStream mems     = new MemoryStream();
            StreamWriter sw       = new StreamWriter(mems);

            sw.Write("<root><base64>");
            sw.Write(base64str);
            sw.Write("</base64></root>");
            sw.Flush();//sw.Close();
            FilePathUtil.addStream(fileName, mems);
            ReloadSource(fileName);

            int SIZE   = (totalfilesize - 30);
            int SIZE64 = SIZE * 3 / 4;

            DataReader.PositionOnElement("base64");
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }
            byte[] base64 = new byte[SIZE64];

            try
            {
                DataReader.ReadElementContentAsBinHex(base64, 0, 4096);
                return(TEST_FAIL);
            }
            catch (XmlException) { DataReader.Close(); return(TEST_PASS); }
            finally { DataReader.Close(); }
        }
コード例 #10
0
        public static async Task RoundtripSyncAsyncMatches_Stream(bool document, LoadOptions loadOptions, SaveOptions saveOptions)
        {
            // Roundtrip XML using synchronous and Stream
            MemoryStream syncOutput = new MemoryStream();

            using (Stream syncStream = FilePathUtil.getStream(GetTestFileName()))
            {
                if (document)
                {
                    XDocument syncDoc = XDocument.Load(syncStream, loadOptions);
                    syncDoc.Save(syncOutput, saveOptions);
                }
                else
                {
                    XElement syncElement = XElement.Load(syncStream, loadOptions);
                    syncElement.Save(syncOutput, saveOptions);
                }
            }

            // Roundtrip XML using asynchronous and Stream
            MemoryStream asyncOutput = new MemoryStream();

            using (Stream asyncStream = FilePathUtil.getStream(GetTestFileName()))
            {
                if (document)
                {
                    XDocument asyncDoc = await XDocument.LoadAsync(asyncStream, loadOptions, CancellationToken.None);

                    await asyncDoc.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
                }
                else
                {
                    XElement asyncElement = await XElement.LoadAsync(asyncStream, loadOptions, CancellationToken.None);

                    await asyncElement.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
                }
            }

            // Compare to make sure the synchronous and asynchronous results are the same
            Assert.Equal(syncOutput.ToArray(), asyncOutput.ToArray());
        }
コード例 #11
0
        public static void CreateBigElementTestFile(string strFileName)
        {
            Stream     s  = new MemoryStream();
            TextWriter tw = new StreamWriter(s);

            string str = new String('Z', (1 << 20) - 1);

            tw.WriteLine("<Root>");
            tw.Write("<");
            tw.Write(str);
            tw.WriteLine("X />");
            tw.Flush();

            tw.Write("<");
            tw.Write(str);
            tw.WriteLine("Y />");
            tw.WriteLine("</Root>");

            tw.Flush();
            FilePathUtil.addStream(strFileName, s);
        }
コード例 #12
0
        public int LineNumberAndLinePositionAreCorrect()
        {
            XmlReaderSettings rs = new XmlReaderSettings();
            Stream            fs = FilePathUtil.getStream(TestData + "Common\\Bug297091.xsl");

            {
                XmlReader DataReader = ReaderHelper.Create(fs, rs, TestData + "Common\\Bug297091.xsl");

                DataReader.Read();
                if (DataReader.NodeType != XmlNodeType.Element || ((IXmlLineInfo)DataReader).LineNumber != 1 || ((IXmlLineInfo)DataReader).LinePosition != 2)
                {
                    CError.Compare(false, "Failed");
                }

                DataReader.Read();
                if (DataReader.NodeType != XmlNodeType.Whitespace || ((IXmlLineInfo)DataReader).LineNumber != 4 || ((IXmlLineInfo)DataReader).LinePosition != 2)
                {
                    CError.Compare(false, "Failed");
                }

                DataReader.Read();
                if (DataReader.NodeType != XmlNodeType.Element || ((IXmlLineInfo)DataReader).LineNumber != 5 || ((IXmlLineInfo)DataReader).LinePosition != 3)
                {
                    CError.Compare(false, "Failed");
                }

                DataReader.Read();
                if (DataReader.NodeType != XmlNodeType.Whitespace || ((IXmlLineInfo)DataReader).LineNumber != 5 || ((IXmlLineInfo)DataReader).LinePosition != 28)
                {
                    CError.Compare(false, "Failed");
                }

                DataReader.Read();
                if (DataReader.NodeType != XmlNodeType.EndElement || ((IXmlLineInfo)DataReader).LineNumber != 6 || ((IXmlLineInfo)DataReader).LinePosition != 3)
                {
                    CError.Compare(false, "Failed");
                }
            }
            return(TEST_PASS);
        }
コード例 #13
0
        public void OnXElement3()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            var      filename = (string)Variation.Param;
            XElement e1       = XElement.Load(FilePathUtil.getStream(filename));

            foreach (XElement e in e1.Elements())
            {
                if (_runWithEvents)
                {
                    _eHelper = new EventsHelper(e);
                    count    = e.Nodes().Count();
                }
                VerifyRemoveNodes(e);
                if (_runWithEvents)
                {
                    _eHelper.Verify(XObjectChange.Remove, count);
                }
            }
        }
コード例 #14
0
        //[Variation(Priority = 1, Desc = "XNode.Ancestors(XName)")]
        public void XNodeAncestorsXName()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument doc = XDocument.Load(FilePathUtil.getStream(@"testdata\xlinq\books.xml"), LoadOptions.PreserveWhitespace);
            XElement  e   = doc.Descendants("last.name").Where(x => x.Value == "Marsh").First();

            TestLog.Compare(e != null, "TEST_FAILED: wrong starting position");
            IEnumerable <XNode> toRemove = e.Ancestors("author").OfType <XNode>();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(e.Ancestors("author"));
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #15
0
        public void XElementsAfterSelfXName()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument doc = XDocument.Load(FilePathUtil.getStream(@"testdata\xlinq\books.xml"), LoadOptions.PreserveWhitespace);
            XElement  e   = doc.Descendants("magazine").Where(x => x.Element("title").Value == "PC Week").First();

            TestLog.Compare(e != null, "TEST_FAILED: wrong starting position");
            IEnumerable <XNode> toRemove = e.ElementsAfterSelf(@"{http://www.books.com/}book").OfType <XNode>();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #16
0
        public void XNodesBeforeSelf()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument doc = XDocument.Load(FilePathUtil.getStream(Path.Combine("TestData", "XLinq", "Books.xml")), LoadOptions.PreserveWhitespace);
            XElement  e   = doc.Descendants("magazine").Where(x => x.Element("title").Value == "PC Week").First();

            TestLog.Compare(e != null, "TEST_FAILED: wrong starting position");
            IEnumerable <XNode> toRemove = e.NodesBeforeSelf();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #17
0
ファイル: SimpleLogger.cs プロジェクト: ithanshui/Common-2
        private void LogToExceptionFile(List <LogInfo> exceptions)
        {
            StringBuilder sb = new StringBuilder();

            foreach (LogInfo logInfo in exceptions)
            {
                sb.AppendFormat("{0}\t{1}\t{2}\t\r\n{3}\r\n", logInfo.LogTime, logInfo.ThreadId, ((Exception)logInfo.Message).Message, ((Exception)logInfo.Message).StackTrace);
            }
            if (_exceptionWriter == null)
            {
                string file =
                    FilePathUtil.GetMapPath("/log/" + DateTime.Now.ToString("yyyyMMdd") + "ex." +
                                            LogFileExtendName);
                FileInfo fileInfo = new FileInfo(file);
                if (!fileInfo.Directory.Exists)
                {
                    fileInfo.Directory.Create();
                }
                _exceptionWriter = new System.IO.StreamWriter(file, true, Encoding.UTF8);
            }
            _exceptionWriter.Write(sb.ToString());
        }
コード例 #18
0
        public void Element_Elements()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument doc = XDocument.Load(FilePathUtil.getStream(Path.Combine("TestData", "XLinq", "Books.xml")), LoadOptions.PreserveWhitespace);
            XElement  e   = doc.Descendants(@"{http://www.books.com/}book").Where(x => x.Element("title").Value == "XQL The Golden Years").First();

            TestLog.Compare(e != null, "TEST_FAILING: wrong starting position");
            IEnumerable <XNode> toRemove = e.Elements().OfType <XNode>();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
コード例 #19
0
        private void SaveWithTextWriter(object doc)
        {
            string file0 = GenerateTestFileName(0);
            string file1 = GenerateTestFileName(1);
            string file2 = GenerateTestFileName(2);

            foreach (Encoding encoding in GetEncodings())
            {
                using (TextWriter w0 = new StreamWriter(FilePathUtil.getStream(file0)))
                    using (TextWriter w1 = new StreamWriter(FilePathUtil.getStream(file1)))
                        using (TextWriter w2 = new StreamWriter(FilePathUtil.getStream(file2)))
                        {
                            if (doc is XDocument)
                            {
                                ((XDocument)doc).Save(w0);
                                ((XDocument)doc).Save(w1, SaveOptions.DisableFormatting);
                                ((XDocument)doc).Save(w2, SaveOptions.None);
                            }
                            else if (doc is XElement)
                            {
                                ((XElement)doc).Save(w0);
                                ((XElement)doc).Save(w1, SaveOptions.DisableFormatting);
                                ((XElement)doc).Save(w2, SaveOptions.None);
                            }
                            else
                            {
                                TestLog.Compare(false, "Wrong object");
                            }

                            w0.Dispose();
                            w1.Dispose();
                            w2.Dispose();

                            TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file0)), "TextWriter failed:encoding " + encoding);
                            TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file1)), "TextWriter(preserveWhtsp=true) failed:encoding " + encoding);
                            TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file2)), "TextWriter(preserveWhtsp=false) failed:encoding " + encoding);
                        }
            }
        }
コード例 #20
0
    public static void BuildLua()
    {
        ToLuaMenu.ClearLuaFilesFromSrcPath();
        ToLuaMenu.CopyLuaFilesToSrcPath();

        string[] allPath = Directory.GetFiles(FilePathUtil.resPath + "Lua/", "*.*", SearchOption.AllDirectories);

        //剔除.meta文件;
        List <string> allLuaAsset = new List <string>();

        foreach (string tempPath in allPath)
        {
            string path = tempPath.Replace("\\", "/");
            if (Path.GetExtension(path) == ".meta")
            {
                continue;
            }
            allLuaAsset.Add(path);
        }
        int index = 0;

        foreach (string tempPath in allLuaAsset)
        {
            index++;
            EditorUtility.DisplayProgressBar("Set Asset AssetBundle Name", "AssetBundle Name Setting Progress", (index / allLuaAsset.Count));
            AssetImporter importer = AssetImporter.GetAtPath(tempPath);
            if (importer != null)
            {
                importer.assetBundleName = FilePathUtil.GetAssetBundleFileName(AssetType.Lua, "Lua");
                AssetDatabase.ImportAsset(tempPath);
            }
        }
        EditorUtility.ClearProgressBar();

        //tips:Unity5.x Scripts not need to build AssetBundle
        //analysiser.BuildAllScripts();
        BuildAssetBundle();
    }
コード例 #21
0
                //[Variation("Skip after ReadAttributeValue/ReadValueChunk")]
                public void bug340158()
                {
                    XmlReaderSettings settings = new XmlReaderSettings();

                    settings.DtdProcessing = DtdProcessing.Ignore;
                    XmlReader r      = XmlReader.Create(FilePathUtil.getStream(Path.Combine("StandardTests", "XML10", "ms_xml", "vs084.xml")), settings);
                    XmlReader reader = GetReader(r);

                    reader.ReadToFollowing("a");
                    reader.MoveToNextAttribute();
                    reader.ReadAttributeValue();
                    try
                    {
                        reader.ReadValueChunk(new char[3], 0, 3);
                        throw new TestException(TestResult.Failed, "");
                    }
                    catch (NotSupportedException) { }
                    reader.Skip();
                    TestLog.Compare(reader.NodeType, XmlNodeType.Text, "NT");
                    reader.Read();
                    TestLog.Compare(reader.NodeType, XmlNodeType.Element, "NT1");
                    TestLog.Compare(reader.Name, "a", "Name");
                }
コード例 #22
0
        /// <summary>
        /// 保存先ディレクトリパス設定を更新する。
        /// </summary>
        /// <param name="path">ディレクトリパス。</param>
        private void UpdateSaveDirectoryPath(string path)
        {
            // パスが正常かチェック
            var status = FilePathUtil.CheckPathStatus(path, pathIsFile: false);

            // 正常でなければステータス更新のみ
            if (status.StatusType != AppStatusType.None)
            {
                this.LastStatus.Value = status;
                return;
            }

            // フルパスにして設定
            this.Config.Value.SaveDirectoryPath = Path.GetFullPath(path);

            // 成功ステータス設定
            this.SetLastStatus(
                AppStatusType.Success,
                @"保存先フォルダーを設定しました。",
                subStatusText: @"保存先フォルダーを開く",
                subStatusCommand: new ProcessStartCommand(path),
                subStatusCommandTip: path);
        }
コード例 #23
0
    /// <summary>
    /// AssetBundle异步加载;
    /// </summary>
    /// <param name="type">资源类型</param>
    /// <param name="assetName">资源名字</param>
    /// <param name="action">AssetBundle回调</param>
    /// <param name="progress">progress回调</param>
    /// <returns></returns>
    public IEnumerator LoadAssetBundleAsync(AssetType type, string assetName, Action <AssetBundle> action, Action <float> progress)
    {
        if (type == AssetType.Non || string.IsNullOrEmpty(assetName))
        {
            yield break;
        }
        string assetBundlePath = FilePathUtil.GetAssetBundlePath(type, assetName);

        if (assetBundlePath == null)
        {
            yield break;
        }
        string assetBundleName = FilePathUtil.GetAssetBundleFileName(type, assetName);

        //先加载依赖的AssetBundle;
        string[] DependentAssetBundle = Manifest.GetAllDependencies(assetBundleName);
        foreach (string tempAssetBundle in DependentAssetBundle)
        {
            if (tempAssetBundle == FilePathUtil.GetAssetBundleFileName(AssetType.Shader, "Shader"))
            {
                continue;
            }
            string      tempPtah = FilePathUtil.assetBundlePath + tempAssetBundle;
            IEnumerator itor     = LoadSingleAssetBundleAsync(tempPtah, null, null);
            while (itor.MoveNext())
            {
                yield return(null);
            }
        }
        //加载目标AssetBundle;
        IEnumerator itorTarget = LoadSingleAssetBundleAsync(assetBundlePath, action, progress);

        while (itorTarget.MoveNext())
        {
            yield return(null);
        }
    }
コード例 #24
0
ファイル: InheritedCases.cs プロジェクト: yang73137/corefx
        public override XmlReader Create(MyDict <string, object> options)
        {
            string tcDesc = (string)options[ReaderFactory.HT_CURDESC];
            string tcVar  = (string)options[ReaderFactory.HT_CURVAR];

            CError.Compare(tcDesc == "charcheckingreader", "Invalid testcase");

            XmlReaderSettings rs         = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
            Stream            stream     = (Stream)options[ReaderFactory.HT_STREAM];
            string            filename   = (string)options[ReaderFactory.HT_FILENAME];
            object            readerType = options[ReaderFactory.HT_READERTYPE];
            object            vt         = options[ReaderFactory.HT_VALIDATIONTYPE];
            string            fragment   = (string)options[ReaderFactory.HT_FRAGMENT];
            StringReader      sr         = (StringReader)options[ReaderFactory.HT_STRINGREADER];

            if (rs == null)
            {
                rs = new XmlReaderSettings();
            }

            rs.DtdProcessing   = DtdProcessing.Ignore;
            rs.CheckCharacters = false;

            XmlReaderSettings wrs = new XmlReaderSettings();

            wrs.DtdProcessing    = DtdProcessing.Ignore;
            wrs.CheckCharacters  = true;
            wrs.ConformanceLevel = ConformanceLevel.Auto;

            if (sr != null)
            {
                CError.WriteLine("CharCheckingReader String");
                XmlReader r  = ReaderHelper.Create(sr, rs, string.Empty);
                XmlReader wr = ReaderHelper.Create(r, wrs);
                return(wr);
            }

            if (stream != null)
            {
                CError.WriteLine("CharCheckingReader Stream");
                XmlReader r  = ReaderHelper.Create(stream, rs, filename);
                XmlReader wr = ReaderHelper.Create(r, wrs);
                return(wr);
            }

            if (fragment != null)
            {
                CError.WriteLine("CharCheckingReader Fragment");
                rs.ConformanceLevel = ConformanceLevel.Fragment;
                StringReader tr = new StringReader(fragment);
                XmlReader    r  = ReaderHelper.Create(tr, rs, (string)null);
                XmlReader    wr = ReaderHelper.Create(r, wrs);
                return(wr);
            }

            if (filename != null)
            {
                CError.WriteLine("CharCheckingReader Filename");
                Stream    fs = FilePathUtil.getStream(filename);
                XmlReader r  = ReaderHelper.Create(fs, rs, filename);
                XmlReader wr = ReaderHelper.Create(r, wrs);
                return(wr);
            }
            return(null);
        }
コード例 #25
0
ファイル: MaxSettings.cs プロジェクト: shandan1/CollectionRef
 public OneByteStream(string fileName)
 {
     _inner = FilePathUtil.getStream(fileName);
 }
コード例 #26
0
        private void SaveWithFile(object doc)
        {
            string file0 = GenerateTestFileName(0);
            string file1 = GenerateTestFileName(1);
            string file2 = GenerateTestFileName(2);

            foreach (Encoding encoding in GetEncodings())
            {
                if (doc is XDocument)
                {
                    ((XDocument)doc).Save(FilePathUtil.getStream(file0));
                    ((XDocument)doc).Save(FilePathUtil.getStream(file1), SaveOptions.DisableFormatting);
                    ((XDocument)doc).Save(FilePathUtil.getStream(file2), SaveOptions.None);
                }
                else if (doc is XElement)
                {
                    ((XElement)doc).Save(FilePathUtil.getStream(file0));
                    ((XElement)doc).Save(FilePathUtil.getStream(file1), SaveOptions.DisableFormatting);
                    ((XElement)doc).Save(FilePathUtil.getStream(file2), SaveOptions.None);
                }
                else
                {
                    TestLog.Compare(false, "Wrong object");
                }
                TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file0)), "Save failed:encoding " + encoding);
                TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file1)), "Save(preserveWhitespace true) failed:encoding " + encoding);
                TestLog.Compare(_diff.Compare(FilePathUtil.getStream(BaseSaveFileName), FilePathUtil.getStream(file2)), "Save(preserveWhitespace false) " + encoding);
            }
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: yzwbrian/fy_update
        //入口
        static void Main(string[] args)
        {
#if DEBUG
            HostConfig.Init(FilePathUtil.GetAbsolutePath("Test\\" + HostConfig.DEFAULT_NAME));
#else
            HostConfig.Init(args == null || args.Length < 1 || string.IsNullOrEmpty(args[0]) ? FilePathUtil.GetAbsolutePath(HostConfig.DEFAULT_NAME) : args[0]);
            //必须从临时目录启动
            if (!AppConfig.ExecutablePath.Equals(AppConfig.ExpectExecutablePath, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    File.Copy(AppConfig.ExecutablePath, AppConfig.ExpectExecutablePath, true);
                    ProcessUtil.Start(AppConfig.ExpectExecutablePath, HostConfig.ExecutablePath);
                }
                catch (Exception e)
                {
                    MessageBoxUtil.Error(e.Message);
                }
                return;
            }
#endif
            //运行
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmUpdate());
        }
コード例 #28
0
ファイル: InheritedCases.cs プロジェクト: yang73137/corefx
        public override XmlReader Create(MyDict <string, object> options)
        {
            string tcDesc = (string)options[ReaderFactory.HT_CURDESC];
            string tcVar  = (string)options[ReaderFactory.HT_CURVAR];

            CError.Compare(tcDesc == "subtreereader", "Invalid testcase");

            XmlReaderSettings rs         = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
            Stream            stream     = (Stream)options[ReaderFactory.HT_STREAM];
            string            filename   = (string)options[ReaderFactory.HT_FILENAME];
            object            readerType = options[ReaderFactory.HT_READERTYPE];
            object            vt         = options[ReaderFactory.HT_VALIDATIONTYPE];
            string            fragment   = (string)options[ReaderFactory.HT_FRAGMENT];
            StringReader      sr         = (StringReader)options[ReaderFactory.HT_STRINGREADER];

            if (rs == null)
            {
                rs = new XmlReaderSettings();
            }

            rs.DtdProcessing = DtdProcessing.Ignore;
            if (sr != null)
            {
                CError.WriteLine("SubtreeReader String");

                XmlReader r = ReaderHelper.Create(sr, rs, string.Empty);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (stream != null)
            {
                CError.WriteLine("SubtreeReader Stream");

                XmlReader r = ReaderHelper.Create(stream, rs, filename);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (fragment != null)
            {
                CError.WriteLine("SubtreeReader Fragment");
                rs.ConformanceLevel = ConformanceLevel.Fragment;
                StringReader tr = new StringReader(fragment);

                XmlReader r = ReaderHelper.Create(tr, rs, (string)null);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (filename != null)
            {
                CError.WriteLine("SubtreeReader Filename");

                Stream    fs = FilePathUtil.getStream(filename);
                XmlReader r  = ReaderHelper.Create(fs, rs, filename);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            throw new CTestFailedException("SubtreeReader not created");
        }
コード例 #29
0
        public static void CreateBinHexTestFile(string strFileName)
        {
            byte[] Wbinhex    = new byte[2000];
            int    Wbinhexlen = 0;

            byte[] WNumOnly    = new byte[2000];
            int    WNumOnlylen = 0;

            byte[] WTextOnly    = new byte[2000];
            int    WTextOnlylen = 0;
            int    i            = 0;

            for (i = 0; i < strBinHex.Length; i++)
            {
                WriteToBuffer(ref Wbinhex, ref Wbinhexlen, System.BitConverter.GetBytes(strBinHex[i]));
            }

            for (i = 0; i < 10; i++)
            {
                WriteToBuffer(ref WNumOnly, ref WNumOnlylen, System.BitConverter.GetBytes(strBinHex[i]));
            }

            for (i = 10; i < strBinHex.Length; i++)
            {
                WriteToBuffer(ref WTextOnly, ref WTextOnlylen, System.BitConverter.GetBytes(strBinHex[i]));
            }
            MemoryStream mems = new MemoryStream();

            XmlWriter w = XmlWriter.Create(mems);

            w.WriteStartElement("Root");
            w.WriteStartElement("ElemAll");
            w.WriteBinHex(Wbinhex, 0, (int)Wbinhexlen);
            w.WriteEndElement();
            w.Flush();

            w.WriteStartElement("ElemEmpty");
            w.WriteString(String.Empty);
            w.WriteEndElement();

            w.WriteStartElement("ElemNum");
            w.WriteBinHex(WNumOnly, 0, (int)WNumOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemText");
            w.WriteBinHex(WTextOnly, 0, (int)WTextOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemNumText");
            w.WriteBinHex(WNumOnly, 0, (int)WNumOnlylen);
            w.WriteBinHex(WTextOnly, 0, (int)WTextOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemLong");
            for (i = 0; i < 10; i++)
            {
                w.WriteBinHex(Wbinhex, 0, (int)Wbinhexlen);
            }
            w.WriteEndElement();

            w.WriteElementString("ElemErr", "a&A2A3");

            w.WriteEndElement();
            w.Flush();
            FilePathUtil.addStream(strFileName, mems);
        }
コード例 #30
0
        public static void CreateBase64TestFile(string strFileName)
        {
            byte[] Wbase64    = new byte[2048];
            int    Wbase64len = 0;

            byte[] WNumOnly    = new byte[1024];
            int    WNumOnlylen = 0;

            byte[] WTextOnly    = new byte[1024];
            int    WTextOnlylen = 0;
            int    i            = 0;

            for (i = 0; i < strBase64.Length; i++)
            {
                WriteToBuffer(ref Wbase64, ref Wbase64len, System.BitConverter.GetBytes(strBase64[i]));
            }

            for (i = 52; i < strBase64.Length; i++)
            {
                WriteToBuffer(ref WNumOnly, ref WNumOnlylen, System.BitConverter.GetBytes(strBase64[i]));
            }

            for (i = 0; i < strBase64.Length - 12; i++)
            {
                WriteToBuffer(ref WTextOnly, ref WTextOnlylen, System.BitConverter.GetBytes(strBase64[i]));
            }
            MemoryStream mems = new MemoryStream();
            XmlWriter    w    = XmlWriter.Create(mems, null);

            w.WriteStartDocument();
            w.WriteStartElement("Root");
            w.WriteStartElement("ElemAll");
            w.WriteBase64(Wbase64, 0, (int)Wbase64len);
            w.WriteEndElement();

            w.WriteStartElement("ElemEmpty");
            w.WriteString(String.Empty);
            w.WriteEndElement();

            w.WriteStartElement("ElemNum");
            w.WriteBase64(WNumOnly, 0, (int)WNumOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemText");
            w.WriteBase64(WTextOnly, 0, (int)WTextOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemNumText");
            w.WriteBase64(WTextOnly, 0, (int)WTextOnlylen);
            w.WriteBase64(WNumOnly, 0, (int)WNumOnlylen);
            w.WriteEndElement();

            w.WriteStartElement("ElemLong");
            for (i = 0; i < 10; i++)
            {
                w.WriteBase64(Wbase64, 0, (int)Wbase64len);
            }
            w.WriteEndElement();

            w.WriteElementString("ElemErr", "a&AQID");

            w.WriteStartElement("ElemMixed");
            w.WriteRaw("D2BAa<MIX></MIX>AQID");
            w.WriteEndElement();
            w.WriteEndElement();
            w.Flush();
            FilePathUtil.addStream(strFileName, mems);
        }