Ejemplo n.º 1
0
            public static string ConvertListOfElementTypeToString(List <StringConversions__ElementType> ee)
            {
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140517
                // X:\jsc.svn\examples\javascript\test\TestWebMethodTaskOfIEnumerable\TestWebMethodTaskOfIEnumerable\ApplicationWebService.cs
                //return ConvertElementTypeArrayToString(e.ToArray());


                //Unable to cast object of type 'System.Int32[]' to type 'System.Object[]'.

                //Console.WriteLine("enter ConvertElementTypeArrayToString");

                #region return inline ConvertElementTypeArrayToString
                if (ee == null)
                {
                    return(null);
                }

                //var o = (object[])e;

                var e = ee.ToArray();

                var xml = new XElement("enumerable");

                var Length = e.Length;

                xml.Add(new XAttribute("c", "" + Length));

                for (int i = 0; i < Length; i++)
                {
                    // ldelem.ref ?
                    var item = e[i];

                    //                 [MethodAccessException: Attempt by method &#39;mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[])&#39; to access method &#39;&lt;&gt;f__AnonymousType4d`2&lt;System.Int32,System.__Canon&gt;..ctor(Int32, System.__Canon)&#39; failed.]
                    //mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[] ) +305


                    //Console.WriteLine("i: " + i + ", item: " + item);

                    xml.Add(new XElement("i" + i, ToString((StringConversions__ElementType)item)));
                }

                var value = StringConversions.ConvertXElementToString(xml);

                //Console.WriteLine("value: " + value);

                return(value);

                #endregion
            }
Ejemplo n.º 2
0
            public static string ConvertElementTypeArrayToString(StringConversions__ElementType[] e)
            {
                //Unable to cast object of type 'System.Int32[]' to type 'System.Object[]'.

                //Console.WriteLine("enter ConvertElementTypeArrayToString");

                if (e == null)
                {
                    return(null);
                }

                //var o = (object[])e;


                var xml = new XElement("array");

                var Length = e.Length;

                xml.Add(new XAttribute("c", "" + Length));

                for (int i = 0; i < Length; i++)
                {
                    // ldelem.ref ?
                    var item = e[i];

                    //                 [MethodAccessException: Attempt by method &#39;mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[])&#39; to access method &#39;&lt;&gt;f__AnonymousType4d`2&lt;System.Int32,System.__Canon&gt;..ctor(Int32, System.__Canon)&#39; failed.]
                    //mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[] ) +305


                    //Console.WriteLine("i: " + i + ", item: " + item);

                    xml.Add(new XElement("i" + i, ToString((StringConversions__ElementType)item)));
                }

                var value = StringConversions.ConvertXElementToString(xml);

                //Console.WriteLine("value: " + value);

                return(value);
            }
Ejemplo n.º 3
0
            public static string ConvertElementTypeEnumerableToString(IEnumerable <StringConversions__ElementType> ee)
            {
                //0:10325ms WebServiceForJavaScript.WriteMethod { Name = foo }
                //0:10325ms enter ConvertElementTypeArrayToString ee:[object Object]

                //Console.WriteLine("enter ConvertElementTypeArrayToString " + new { ee });
                //Console.WriteLine("enter ConvertElementTypeArrayToString ee:" + ee);

                // X:\jsc.svn\examples\javascript\Test\TestIEnumerableForService\TestIEnumerableForService\ApplicationWebService.cs
                // X:\jsc.svn\examples\javascript\test\TestWebMethodTaskOfIEnumerable\TestWebMethodTaskOfIEnumerable\ApplicationWebService.cs
                //return ConvertElementTypeArrayToString(e.ToArray());


                //Unable to cast object of type 'System.Int32[]' to type 'System.Object[]'.


                #region return inline ConvertElementTypeArrayToString
                if (ee == null)
                {
                    //Console.WriteLine("enter ConvertElementTypeArrayToString ee is null");

                    //                 at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
                    //at mscorlib.< 02000005IEnumerable\.ConvertToString >.ConvertToString(IEnumerable`1)
                    //at TestIEnumerableForService.Global.Invoke(InternalWebMethodInfo)
                    //at ScriptCoreLib.Ultra.WebService.InternalGlobalExtensions.<> c__DisplayClass0.< InternalApplication_BeginRequest > b__12(WebServiceScriptApplication app)
                    //at ScriptCoreLib.Ultra.WebService.InternalGlobalExtensions.InternalApplication_BeginRequest(InternalGlobal g)
                    //at TestIEnumerableForService.Global.Application_BeginRequest(Object, EventArgs)
                    //at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
                    //at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean & completedSynchronously)

                    return(null);
                }

                //var o = (object[])e;

                var e = ee.ToArray();

                var xml = new XElement("enumerable");

                var Length = e.Length;

                //Console.WriteLine("ConvertElementTypeArrayToString " + new { Length });
                //Console.WriteLine("ConvertElementTypeArrayToString Length: " + Length);

                xml.Add(new XAttribute("c", "" + Length));

                for (int i = 0; i < Length; i++)
                {
                    // ldelem.ref ?
                    var item = e[i];

                    //                 [MethodAccessException: Attempt by method &#39;mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[])&#39; to access method &#39;&lt;&gt;f__AnonymousType4d`2&lt;System.Int32,System.__Canon&gt;..ctor(Int32, System.__Canon)&#39; failed.]
                    //mscorlib.&lt;020000f3Array\+ConvertToString&gt;.ConvertToString(Int32[] ) +305


                    //Console.WriteLine("i: " + i + ", item: " + item);

                    xml.Add(new XElement("i" + i, ToString((StringConversions__ElementType)item)));
                }

                var value = StringConversions.ConvertXElementToString(xml);

                //Console.WriteLine("ConvertElementTypeArrayToString " + new { value });
                //Console.WriteLine("ConvertElementTypeArrayToString value: " + value);

                return(value);

                #endregion
            }