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 'mscorlib.<020000f3Array\+ConvertToString>.ConvertToString(Int32[])' to access method '<>f__AnonymousType4d`2<System.Int32,System.__Canon>..ctor(Int32, System.__Canon)' failed.] //mscorlib.<020000f3Array\+ConvertToString>.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 }
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 'mscorlib.<020000f3Array\+ConvertToString>.ConvertToString(Int32[])' to access method '<>f__AnonymousType4d`2<System.Int32,System.__Canon>..ctor(Int32, System.__Canon)' failed.] //mscorlib.<020000f3Array\+ConvertToString>.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); }
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 'mscorlib.<020000f3Array\+ConvertToString>.ConvertToString(Int32[])' to access method '<>f__AnonymousType4d`2<System.Int32,System.__Canon>..ctor(Int32, System.__Canon)' failed.] //mscorlib.<020000f3Array\+ConvertToString>.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 }