Exemplo n.º 1
0
    public void ToText(int iteration)
    {
        Console.WriteLine("ToText go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("DataContractHelper ToText", iteration,
                                      () => DataContractHelper.ToXml(_testModel)));
        Console.WriteLine(Runner.Time("JilHelper ToText", iteration,
                                      () => JilHelper.ToJson(_testModel)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper ToText", iteration,
                                      () => NewtonsoftJsonHelper.ToJson(_testModel)));
        Console.WriteLine(Runner.Time("SharpYamlHelper ToText", iteration,
                                      () => SharpYamlHelper.ToYaml(_testModel)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper ToText", iteration,
                                      () => SystemTextJsonHelper.ToJson(_testModel)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper ToText", iteration,
                                      () => Utf8JsonHelper.ToJson(_testModel)));
        Console.WriteLine(Runner.Time("XmlHelper ToText", iteration,
                                      () => XmlHelper.ToXml(_testModel)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper ToText", iteration,
                                      () => YamlDotNetHelper.ToYaml(_testModel)));

        Console.WriteLine("\r\nToText complete!\r\n");
    }
Exemplo n.º 2
0
 public XElement SaveToXml(XElement xParent)
 {
     xParent.Add(new XElement("DisplayName", this.DisplayName));
     xParent.Add(XElement.Parse(DataContractHelper.SaveToString(this.Mobius)));
     xParent.Add(new XElement("ViewReflected", this.ViewReflected));
     return(m_twists.SaveToXml(xParent));
 }
Exemplo n.º 3
0
        /// <summary>
        /// The process class.
        /// </summary>
        /// <param name="classType">
        /// The class type.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        /// <exception cref="ArgumentException">
        /// </exception>
        private static IEnumerable <Type> ProcessClass(Type classType)
        {
            if (classType == null)
            {
                throw new ArgumentNullException("classType");
            }

            if (!classType.IsClass)
            {
                throw new ArgumentException(string.Format("Type '{0}' is not class.", classType), "classType");
            }

            IEnumerable <Type> properties = from property in DataContractHelper.GetContractProperties(classType)
                                            select property.Value.PropertyType;
            var types = properties.ToList();

            // Handle complex types
            for (int i = 0; i < types.Count; i++)
            {
                Type type = types[i];

                // Type is an array
                if (type.IsArray && type.HasElementType)
                {
                    types[i] = type.GetElementType();
                }
            }

            return(types);
        }
Exemplo n.º 4
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_メソッド名(MuParameterValue muParameter)
        { //メソッド引数にBaseParameterValueの派生の型を定義可能。
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            muReturn.Bean    = new Informations("");
            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DataTable dt = DataContractHelper.ToDataTable(((Informations)muParameter.Bean).DicList);

            // ↓業務処理-----------------------------------------------------

            // 個別Dao
            LayerD_mu myDao = new LayerD_mu(this.GetDam());
            //myDao.xxxx(muParameter.ActionType, dtts, muReturn);

            // 共通Dao
            CmnDao cmnDao = new CmnDao(this.GetDam());

            cmnDao.ExecSelectScalar();

            // 戻り値をマーシャリングして設定
            muReturn.Bean = new Informations("");
            muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

            // ↑業務処理-----------------------------------------------------
        }
Exemplo n.º 5
0
    public void FromText(int iteration)
    {
        var dataContractXml    = DataContractHelper.ToXml(_testModel);
        var jilJson            = JilHelper.ToJson(_testModel);
        var newtonsoftJsonJson = NewtonsoftJsonHelper.ToJson(_testModel);
        var sharpYamlText      = SharpYamlHelper.ToYaml(_testModel);
        var systemTextJsonJson = SystemTextJsonHelper.ToJson(_testModel);
        var utf8JsonJson       = Utf8JsonHelper.ToJson(_testModel);
        var xml            = XmlHelper.ToXml(_testModel);
        var yamlDotNetText = YamlDotNetHelper.ToYaml(_testModel);

        Console.WriteLine("FromText go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("DataContractHelper FromText", iteration,
                                      () => DataContractHelper.FromXml <TestModel>(dataContractXml)));
        Console.WriteLine(Runner.Time("JilHelper FromText", iteration,
                                      () => JilHelper.FromJson <TestModel>(jilJson)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromText", iteration,
                                      () => NewtonsoftJsonHelper.FromJson <TestModel>(newtonsoftJsonJson)));
        Console.WriteLine(Runner.Time("SharpYamlHelper FromText", iteration,
                                      () => SharpYamlHelper.FromYaml <TestModel>(sharpYamlText)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper FromText", iteration,
                                      () => SystemTextJsonHelper.FromJson <TestModel>(systemTextJsonJson)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper FromText", iteration,
                                      () => Utf8JsonHelper.FromJson <TestModel>(utf8JsonJson)));
        Console.WriteLine(Runner.Time("XmlHelper FromText", iteration,
                                      () => XmlHelper.FromXml <TestModel>(xml)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper FromText", iteration,
                                      () => YamlDotNetHelper.FromYaml <TestModel>(yamlDotNetText)));

        Console.WriteLine("\r\nFromText complete!\r\n");
    }
Exemplo n.º 6
0
 public static void Save(Settings settings)
 {
     try
     {
         DataContractHelper.SaveToXml(settings, StandardPaths.SettingsFile);
     }
     catch (System.Exception e)
     {
         string message = string.Format("Failed to save settings.\n{0}", e.Message);
         Log.Error(message);
     }
 }
Exemplo n.º 7
0
    public void FromStream(int iteration)
    {
#pragma warning disable CS0618
        var binaryStream = BinaryHelper.ToStream(_testModel);
#pragma warning restore CS0618
        var dataContractStream   = DataContractHelper.ToStream(_testModel);
        var jilStream            = JilHelper.ToStream(_testModel);
        var messagePackStream    = MessagePackHelper.ToStream(_testModel);
        var msgPackStream        = MsgPackHelper.ToStream(_testModel);
        var newtonsoftJsonStream = NewtonsoftJsonHelper.ToStream(_testModel);
        var protobufStream       = ProtobufHelper.ToStream(_testModel);
        var sharpYamlStream      = SharpYamlHelper.ToStream(_testModel);
        var systemTextJsonStream = SystemTextJsonHelper.ToStream(_testModel);
        var utf8JsonStream       = Utf8JsonHelper.ToStream(_testModel);
        var xmlStream            = XmlHelper.ToStream(_testModel);
        var yamlDotNetStream     = YamlDotNetHelper.ToStream(_testModel);
        var zeroFormatterStream  = ZeroFormatterHelper.ToStream(_testModel);

        Console.WriteLine("FromStream go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("BinaryHelper FromStream", iteration,
#pragma warning disable CS0618
                                      () => BinaryHelper.FromStream <TestModel>(binaryStream)));
#pragma warning restore CS0618
        Console.WriteLine(Runner.Time("DataContractHelper FromStream", iteration,
                                      () => DataContractHelper.FromStream <TestModel>(dataContractStream)));
        Console.WriteLine(Runner.Time("JilHelper FromStream", iteration,
                                      () => JilHelper.FromStream <TestModel>(jilStream)));
        Console.WriteLine(Runner.Time("MessagePackHelper FromStream", iteration,
                                      () => MessagePackHelper.FromStream <TestModel>(messagePackStream)));
        Console.WriteLine(Runner.Time("MsgPackHelper FromStream", iteration,
                                      () => MsgPackHelper.FromStream <TestModel>(msgPackStream)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromStream", iteration,
                                      () => NewtonsoftJsonHelper.FromStream <TestModel>(newtonsoftJsonStream)));
        Console.WriteLine(Runner.Time("ProtobufHelper FromStream", iteration,
                                      () => ProtobufHelper.FromStream <TestModel>(protobufStream)));
        Console.WriteLine(Runner.Time("SharpYamlHelper FromStream", iteration,
                                      () => SharpYamlHelper.FromStream <TestModel>(sharpYamlStream)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper FromStream", iteration,
                                      () => SystemTextJsonHelper.FromStream <TestModel>(systemTextJsonStream)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper FromStream", iteration,
                                      () => Utf8JsonHelper.FromStream <TestModel>(utf8JsonStream)));
        Console.WriteLine(Runner.Time("XmlHelper FromStream", iteration,
                                      () => XmlHelper.FromStream <TestModel>(xmlStream)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper FromStream", iteration,
                                      () => YamlDotNetHelper.FromStream <TestModel>(yamlDotNetStream)));
        Console.WriteLine(Runner.Time("ZeroFormatterHelper FromStream", iteration,
                                      () => ZeroFormatterHelper.FromStream <TestModel>(zeroFormatterStream)));

        Console.WriteLine("\r\nFromStream complete!\r\n");
    }
Exemplo n.º 8
0
 /// <summary>
 /// NOTE: filePath is relative to the base puzzle directory.
 /// </summary>
 public static void Save(PuzzleConfig config, string filePath)
 {
     try
     {
         string fullPath = Path.GetFullPath(Path.Combine(StandardPaths.ConfigDir, filePath));
         Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
         DataContractHelper.SaveToXml(config, fullPath);
     }
     catch (System.Exception e)
     {
         string message = string.Format("Failed to save puzzle config.\n{0}", e.Message);
         Log.Error(message);
     }
 }
Exemplo n.º 9
0
        public void LoadFromXml(XElement xElement, List <IdentifiedTwistData> allTwistData)
        {
            this.DisplayName = xElement.Element("DisplayName").Value;
            XElement xIsometry = xElement.Element("Mobius");

            this.Mobius = (Mobius)DataContractHelper.LoadFromString(typeof(Mobius), xIsometry.ToString());
            XElement xViewReflected = xElement.Element("ViewReflected");

            if (xViewReflected != null)
            {
                this.ViewReflected = bool.Parse(xViewReflected.Value);
            }
            m_twists.LoadFromXml(xElement, allTwistData);
        }
Exemplo n.º 10
0
        public static Settings Load()
        {
            try
            {
                return((Settings)DataContractHelper.LoadFromXml(typeof(Settings), StandardPaths.SettingsFile));
            }
            catch (System.Exception e)
            {
                string message = string.Format("Failed to load settings.\n{0}", e.Message);
                Log.Error(message);

                return(new Settings());
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// NOTE: filePath is relative to the base puzzle directory.
        /// </summary>
        public static PuzzleConfig Load(string filePath)
        {
            try
            {
                string fullPath = Path.GetFullPath(Path.Combine(StandardPaths.ConfigDir, filePath));
                return((PuzzleConfig)DataContractHelper.LoadFromXml(typeof(PuzzleConfig), fullPath));
            }
            catch (System.Exception e)
            {
                string message = string.Format("Failed to load puzzle config.\n{0}", e.Message);
                Log.Error(message);

                return(new PuzzleConfig());
            }
        }
Exemplo n.º 12
0
        public void LoadFromFile(System.Action <PuzzleConfig, System.Action <Puzzle> > buildPuzzle)
        {
            string fileName = GetLoadFileNameInternal();

            if (!File.Exists(fileName))
            {
                return;
            }

            XDocument    xDocument = XDocument.Load(fileName);
            XElement     xConfig   = xDocument.Root.Element("PuzzleConfig");
            PuzzleConfig config    = (PuzzleConfig)DataContractHelper.LoadFromString(typeof(PuzzleConfig), xConfig.ToString());

            SetVersionOnConfig(config, xDocument.Root);
            System.Action <Puzzle> finishLoad = p => LoadStateAndHistoryAndMacros(xDocument, p);
            buildPuzzle(config, finishLoad);
        }
Exemplo n.º 13
0
        public string CreateExcelWithRJson(string jsonStr)
        {
            RM4ExcelData excelData  = DataContractHelper.FromJsonTo <RM4ExcelData>(jsonStr);
            DataTable    exceltable = CreateMyExcel(excelData);

            strHeaderText = excelData.Title;

            string paths = HttpContext.Current.Server.MapPath("~");

            strFileName   = paths + "\\upload\\excel";
            strHeaderText = GetFieldName(strHeaderText);
            string filename = GetFileName(strHeaderText);

            strFileName = strFileName + "\\" + filename;

            StartCreateExcel(exceltable, strHeaderText, strFileName);
            return(filename);
        }
        public void ImmutableList_SerializeAndDeserialize_CorrectResult()
        {
            // ARRANGE
            var objectUnderTest = new Test();

            objectUnderTest.List = objectUnderTest.List.Add(1);
            objectUnderTest.List = objectUnderTest.List.Add(2);
            objectUnderTest.List = objectUnderTest.List.Add(3);

            // ACT
            var serialized = DataContractHelper.Serialize <Test>(objectUnderTest);
            var result     = DataContractHelper.Deserialize <Test>(serialized);

            // ASSERT
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.List);
            Assert.IsInstanceOfType(result.List, typeof(ImmutableList <int>));
            CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, result.List);
        }
Exemplo n.º 15
0
 private ISerializer GetXmlSerializer(Type type)
 {
     if (DataContractHelper.IsDataContractType(type))
     {
         return(new Utilities.DataContractSerializer(type));
     }
     if (type == typeof(DynamicXml))
     {
         return(new DynamicXmlSerializer());
     }
     if (typeof(IDictionary <object, object>).IsAssignableFrom(type))
     {
         return(new XmlDictionarySerializer("data"));
     }
     else
     {
         return(new XmlSerializer(type));
     }
 }
        public void ImmutableDictionary_SerializeAndDeserialize_CorrectResult()
        {
            // ARRANGE
            var objectUnderTest = new Test();

            objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(1, "one");
            objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(2, "two");
            objectUnderTest.Dictionary = objectUnderTest.Dictionary.Add(3, "three");

            // ACT
            var serialized = DataContractHelper.Serialize <Test>(objectUnderTest);
            var result     = DataContractHelper.Deserialize <Test>(serialized);

            // ASSERT
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Dictionary);
            Assert.IsInstanceOfType(result.Dictionary, typeof(ImmutableDictionary <int, string>));
            Assert.AreEqual("one", result.Dictionary[1]);
            Assert.AreEqual("two", result.Dictionary[2]);
            Assert.AreEqual("three", result.Dictionary[3]);
        }
Exemplo n.º 17
0
    public void ToStream(int iteration)
    {
        Console.WriteLine("ToStream go!");

        Runner.Initialize();

        Console.WriteLine(Runner.Time("BinaryHelper ToStream", iteration,
#pragma warning disable CS0618
                                      () => BinaryHelper.ToStream(_testModel)));
#pragma warning restore CS0618
        Console.WriteLine(Runner.Time("DataContractHelper ToStream", iteration,
                                      () => DataContractHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("JilHelper ToStream", iteration,
                                      () => JilHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("MessagePackHelper ToStream", iteration,
                                      () => MessagePackHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("MsgPackHelper ToStream", iteration,
                                      () => MsgPackHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("NewtonsoftJsonHelper ToStream", iteration,
                                      () => NewtonsoftJsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("ProtobufHelper ToStream", iteration,
                                      () => ProtobufHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("SharpYamlHelper ToStream", iteration,
                                      () => SharpYamlHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("SystemTextJsonHelper ToStream", iteration,
                                      () => SystemTextJsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("Utf8JsonHelper ToStream", iteration,
                                      () => Utf8JsonHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("XmlHelper ToStream", iteration,
                                      () => XmlHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("YamlDotNetHelper ToStream", iteration,
                                      () => YamlDotNetHelper.ToStream(_testModel)));
        Console.WriteLine(Runner.Time("ZeroFormatterHelper ToStream", iteration,
                                      () => ZeroFormatterHelper.ToStream(_testModel)));

        Console.WriteLine("\r\nToStream complete!\r\n");
    }
Exemplo n.º 18
0
        private IEnumerable <Type> ProcessClass(Type classType)
        {
            if (classType == null)
            {
                throw new ArgumentNullException("classType");
            }
            if (!classType.IsClass)
            {
                throw new ArgumentException();
            }

            var types = new List <Type>();

            var properties = from property in DataContractHelper.GetContractProperties(classType)
                             select property.Value.PropertyType;

            types.AddRange(properties);

            var fields = from field in DataContractHelper.GetContractFields(classType)
                         select field.Value.FieldType;

            types.AddRange(fields);

            //Handle complex types
            for (var i = 0; i < types.Count; i++)
            {
                var type = types[i];

                //Type is an array
                if (type.IsArray && type.HasElementType)
                {
                    types[i] = type.GetElementType();
                }
            }

            return(types);
        }
Exemplo n.º 19
0
 public static void PackBy(this Stream?stream, Type type, object?value) =>
 DataContractHelper.Pack(type, value, stream);
Exemplo n.º 20
0
 public static void PackBy <TValue>(this Stream?stream, TValue?value) =>
 DataContractHelper.Pack(value, stream);
 public static object?FromBytes(this byte[]?bytes, Type type) =>
 DataContractHelper.FromBytes(type, bytes);
 public static TValue?FromBytes <TValue>(this byte[]?bytes) =>
 DataContractHelper.FromBytes <TValue>(bytes);
 public static object?ReadXml(this XmlDictionaryReader?xmlDictionaryReader, Type type) =>
 DataContractHelper.Deserialize(type, xmlDictionaryReader);
Exemplo n.º 24
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_SelectAll_DS(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            muReturn.Bean    = new Informations("");
            this.ReturnValue = muReturn;

            // ↓業務処理-----------------------------------------------------
            DataSet ds = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLText = "SELECT * FROM Shippers";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><ROOT>SELECT * FROM Shippers</ROOT>";
                    break;
                }

                // 戻り値 ds
                ds = new DataSet();

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DS(ds);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(ds.Tables[0]));

                break;

            case "generate":     // 自動生成Daoを使用する。

                // 自動生成Daoを生成
                DaoShippers genDao = new DaoShippers(this.GetDam());

                // 戻り値 ds
                ds = new DataSet();
                ds.Tables.Add(new DataTable("rtn"));

                // 自動生成Daoを実行
                genDao.D2_Select(ds.Tables[0]);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(ds.Tables[0]));

                break;

            default:     // 個別Daoを使用する。

                // 個別Daoを実行
                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.SelectAll_DS(muParameter.ActionType, out ds);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(ds.Tables[0]));

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
Exemplo n.º 25
0
 public static TValue?FromXml <TValue>(this string?xml) =>
 DataContractHelper.FromXml <TValue>(xml);
Exemplo n.º 26
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_SelectAll_DSQL(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            muReturn.Bean    = new Informations("");
            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            Dictionary <string, string> dic = ((Informations)muParameter.Bean).Dictionary;

            // ↓業務処理-----------------------------------------------------
            DataTable dt = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelectOrder.sql";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelectOrder.xml";
                    break;
                }

                // ユーザ定義パラメタに対して、動的に値を設定する。
                string orderColumn   = "";
                string orderSequence = "";

                if (dic["OrderColumn"].ToString() == "c1")
                {
                    orderColumn = "ShipperID";
                }
                else if (dic["OrderColumn"].ToString() == "c2")
                {
                    orderColumn = "CompanyName";
                }
                else if (dic["OrderColumn"].ToString() == "c3")
                {
                    orderColumn = "Phone";
                }
                else
                {
                }

                if (dic["OrderSequence"].ToString() == "A")
                {
                    orderSequence = "ASC";
                }
                else if (dic["OrderSequence"].ToString() == "D")
                {
                    orderSequence = "DESC";
                }
                else
                {
                }

                // パラメタ ライズド クエリのパラメタに対して、動的に値を設定する。
                cmnDao.SetParameter("P1", "test");

                // ユーザ入力は指定しない。
                // ※ 動的SQLのVALタグは、前後の空白をつめることが有るので、
                //    必要であれば、前後の空白を明示的に指定する必要がある。
                cmnDao.SetUserParameter("COLUMN", " " + orderColumn + " ");
                cmnDao.SetUserParameter("SEQUENCE", " " + orderSequence + " ");

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DT(dt);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

                break;

            //case "generate": // 自動生成Daoを使用する。
            //    // 当該SQLなし
            //    break;

            default:     // 個別Daoを使用する。

                // 個別Daoを実行
                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.SelectAll_DSQL(
                    muParameter.ActionType,
                    dic["OrderColumn"].ToString(),
                    dic["OrderSequence"].ToString(), out dt);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
Exemplo n.º 27
0
 public static object?FromXml(this string?xml, Type type) =>
 DataContractHelper.FromXml(type, xml);
 public static void WriteXml <TValue>(this XmlWriter?xmlWriter, TValue?value) =>
 DataContractHelper.Serialize(xmlWriter, value);
Exemplo n.º 29
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_SelectAll_DR(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            muReturn.Bean    = new Informations("");
            this.ReturnValue = muReturn;

            // ↓業務処理-----------------------------------------------------
            DataTable dt = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLText = "SELECT * FROM Shippers";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><ROOT>SELECT * FROM Shippers</ROOT>";
                    break;
                }

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 3列生成
                dt.Columns.Add("ShipperID", System.Type.GetType("System.String"));
                dt.Columns.Add("CompanyName", System.Type.GetType("System.String"));
                dt.Columns.Add("Phone", System.Type.GetType("System.String"));

                // 共通Daoを実行
                IDataReader idr = cmnDao.ExecSelect_DR();

                while (idr.Read())
                {
                    // DRから読む
                    object[] objArray = new object[3];
                    idr.GetValues(objArray);

                    // DTに設定する。
                    DataRow dr = dt.NewRow();
                    dr.ItemArray = objArray;
                    dt.Rows.Add(dr);
                }

                // 終了したらクローズ
                idr.Close();

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

                break;

            case "generate":     // 自動生成Daoを使用する。

                // DRのI/Fなし

                // 自動生成Daoを生成
                DaoShippers genDao = new DaoShippers(this.GetDam());

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 自動生成Daoを実行
                genDao.D2_Select(dt);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

                break;

            default:     // 個別Daoを使用する。

                // 個別Daoを実行
                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.SelectAll_DR(muParameter.ActionType, out dt);

                // 戻り値をマーシャリングして設定
                muReturn.Bean = new Informations(DataContractHelper.ToList(dt));

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
 public static void WriteXml(this XmlWriter?xmlWriter, Type type, object?value) =>
 DataContractHelper.Serialize(type, xmlWriter, value);