Example #1
0
 static void Main(string[] args)
 {
     Type guyType = typeof(Guy);
     Console.WriteLine("{0} extends {1}",
     guyType.FullName,
     guyType.BaseType.FullName);
     // output: TypeExamples.Guy extends System.Object
     Type nestedClassType = typeof(NestedClass.DoubleNestedClass);
     Console.WriteLine(nestedClassType.FullName);
     // output: TypeExamples.Program+NestedClass+DoubleNestedClass
     List<Guy> guyList = new List<Guy>();
     Console.WriteLine(guyList.GetType().Name);
     // output: List`1
     Dictionary<string, Guy> guyDictionary = new Dictionary<string, Guy>();
     Console.WriteLine(guyDictionary.GetType().Name);
     // output: Dictionary`2
     Type t = typeof(Program);
     Console.WriteLine(t.FullName);
     // output: TypeExamples.Program
     Type intType = typeof(int);
     Type int32Type = typeof(Int32);
     Console.WriteLine("{0} - {1}", intType.FullName, int32Type.FullName);
     // System.Int32 - System.Int32
     Console.WriteLine("{0} {1}", float.MinValue, float.MaxValue);
     // output:-3.402823E+38 3.402823E+38
     Console.WriteLine("{0} {1}", int.MinValue, int.MaxValue);
     // output:-2147483648 2147483647
     Console.WriteLine("{0} {1}", DateTime.MinValue, DateTime.MaxValue);
     // output: 1/1/0001 12:00:00 AM 12/31/9999 11:59:59 PM
     Console.WriteLine(12345.GetType().FullName);
     // output: System.Int32
     Console.ReadKey();
 }
        public void Write_BuiltsXmlNode_IfAGenericDictionary()
        {
            var parentNode = NewMock<INodeWriter>();
            var dictNode = CreateXmlNode("topNode");
            var itemsNode = CreateXmlNode("dictionary");

            var value = new Dictionary<string, int>();
            value.Add("first key", 11);

            StubTypeMapper();

            Expect.Once.On(valuesCache).Method("Add").With(value).Will(Return.Value(7));

            Expect.Once.On(ownerDocument).Method("CreateTypedElement").With("dict", value.GetType().ToString(),
                                                                            parentNode).Will(
                Return.Value(dictNode));
            Expect.Once.On(dictNode).Method("AddAttribute").With("ID", "7");
            Expect.Once.On(dictNode).Method("Dispose").WithNoArguments();
            Expect.Once.On(itemsNode).Method("Dispose").WithNoArguments();

            Expect.Once.On(ownerDocument).Method("CreateElement").With("items", dictNode).Will(Return.Value(itemsNode));

            Expect.Once.On(objectWriter).Method("Write").With("first key", itemsNode, typeof (string));
            Expect.Once.On(objectWriter).Method("Write").With(11, itemsNode, typeof (Int32));

            Expect.Once.On(itemsNode).Method("AddAttribute").With("count", 1);

            writer.Write(value, parentNode, value.GetType());
        }
        private void RegisterClick(object sender, RoutedEventArgs e)
        {
            if (UsernameField.Text == "" || PasswordField.Password == "" || ConfirmPasswordField.Password == "")
            {
                ErrorField.Text = "All fields are mandatory.";
                return;
            }
            if (PasswordField.Password != ConfirmPasswordField.Password)
            {
                ErrorField.Text = "Password and Confirmation don't match.";
                return;
            }

            ErrorField.Text = "";

            APIRequest request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.Register, "register");

            Dictionary<string, string> dict = new Dictionary<string, string>()
            {
                {"username", UsernameField.Text},
                {"password", PasswordField.Password}
            };
            var serializer = new DataContractJsonSerializer(dict.GetType(), new DataContractJsonSerializerSettings()
            {
                UseSimpleDictionaryFormat = true
            });
            MemoryStream stream = new MemoryStream();
            serializer.WriteObject(stream, dict);
            byte[] bytes = stream.ToArray();
            string content = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            request.Execute(null, content);
        }
 public void GetDictionaryType_StringInt()
 {
     var dsi = new Dictionary<string, int>();
     Type keyType, valueType;
     ReflectionHelper.GetDictionaryType(dsi.GetType(), out keyType, out valueType);
     Assert.AreEqual(typeof(string), keyType);
     Assert.AreEqual(typeof(int), valueType);
 }
 public void GetDictionaryType_DoubleDateTime()
 {
     var dsi = new Dictionary<double, DateTime>();
     Type keyType, valueType;
     ReflectionHelper.GetDictionaryType(dsi.GetType(), out keyType, out valueType);
     Assert.AreEqual(typeof(double), keyType);
     Assert.AreEqual(typeof(DateTime), valueType);
 }
Example #6
0
        public void checkifgenericdictionary()
        {
            var dict = new Dictionary<string, object>();
            //Debug.WriteLine(IsGenericDictionary(dict.GetType(), dict));
            Type contextType = dict.GetType();

            if (contextType.GetInterface("IDictionary`2") != null)
            {

            }
        }
        public void GetGenericArgumentCount_WhenGivenNonGenericArguments_ReturnsTwo()
        {
            // ARRANGE
            var item = new Dictionary<int, string>();
            var type = item.GetType();

            // ACT
            var actual = type.GetGeneGetGenricArgumentCount();

            // ASSERT
            Assert.AreEqual(2, actual);
        }
		public void WriteTypeRegularTest()
		{
			Dictionary<string, IEnumerable<DateTime>[]> o = new Dictionary<string, IEnumerable<DateTime>[]>();
			Type t = o.GetType();

			TypeWriter writer = new TypeWriter();

			Console.WriteLine(writer.WriteType(t));
			Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

			Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Collections.Generic.IEnumerable`1[[System.DateTime, mscorlib]][], mscorlib]], mscorlib", writer.WriteType(t));
			Assert.AreEqual("System.Collections.Generic.Dictionary`2, mscorlib", writer.WriteType(t.GetGenericTypeDefinition()));
		}
		public void WriteTypeMinimalTest()
		{
			Dictionary<string, IEnumerable<DateTime>[]> o = new Dictionary<string, IEnumerable<DateTime>[]>();
			Type t = o.GetType();

			TypeWriter writer = new TypeWriter();
			writer.WithAssembly = false;

			Console.WriteLine(writer.WriteType(t));
			Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

			Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String],[System.Collections.Generic.IEnumerable`1[[System.DateTime]][]]]", writer.WriteType(t));
			Assert.AreEqual("System.Collections.Generic.Dictionary`2", writer.WriteType(t.GetGenericTypeDefinition()));
		}
Example #10
0
 public static string GetAllHints(string etid)
 {
     List<DJ_Workers> ListGw= new BLLDJTourGroup().GetTourGroupByTeId(int.Parse(etid)).ToList();
     Dictionary<string, string> data = new Dictionary<string, string>();
     foreach (DJ_Workers item in ListGw)
     {
         data.Add(Guid.NewGuid().ToString(), item.Name + "/" + item.IDCard.Substring(0, 6) + "********" + item.IDCard.Substring(14));
     }
     DataContractJsonSerializer serializer = new DataContractJsonSerializer(data.GetType());
     using (MemoryStream ms = new MemoryStream())
     {
         serializer.WriteObject(ms, data);
         return System.Text.Encoding.UTF8.GetString(ms.ToArray());
     }
 }
		public void WriteAndReadTypeTest()
		{
			Dictionary<string, IEnumerable<DateTime>[]> o = new Dictionary<string, IEnumerable<DateTime>[]>();
			Type t = o.GetType();

			TypeWriter writer = new TypeWriter();

			Console.WriteLine(writer.WriteType(t));
			Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

			Type t1 = Type.GetType(writer.WriteType(t));
			Type t2 = Type.GetType(writer.WriteType(t.GetGenericTypeDefinition()));

			Assert.AreEqual(t, t1);
			Assert.AreEqual(t.GetGenericTypeDefinition(), t2);
		}
		public void WriteTypeFullTest()
		{
			Dictionary<string, IEnumerable<DateTime>[]> o = new Dictionary<string, IEnumerable<DateTime>[]>();
			Type t = o.GetType();

			TypeWriter writer = new TypeWriter();
			writer.WithVersion = true;
			writer.WithCulture = true;
			writer.WithPublicKeyToken = true;

			Console.WriteLine(writer.WriteType(t));
			Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

			Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.IEnumerable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", writer.WriteType(t));
			Assert.AreEqual("System.Collections.Generic.Dictionary`2, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", writer.WriteType(t.GetGenericTypeDefinition()));
		}
Example #13
0
 public void TestDataBindingDictionary()
 {
     var dict = new Dictionary<string, double>
                    {
                        {"zero", 3},
                        {"one", 3.1},
                        {"two", 3.14}
                    };
     var collectionInfo = CollectionInfo.ForType(dict.GetType());
     CollectionAssert.AreEqual(dict.Keys, collectionInfo.GetKeys(dict).Cast<string>().ToArray());
     CollectionAssert.AreEqual(dict, collectionInfo.GetItems(dict).Cast<KeyValuePair<string,double>>().ToArray());
     foreach (var key in collectionInfo.GetKeys(dict))
     {
         var kvp = (KeyValuePair<string, double>) collectionInfo.GetItemFromKey(dict, key);
         Assert.AreEqual(key, kvp.Key);
         Assert.AreEqual(dict[(string)key], kvp.Value);
     }
 }
Example #14
0
        public void Execute()
        {
            var theList = new List<int> {1, 2, 3, 4, 5};
            var theDictionary = new Dictionary<int, string> {{1, "hoge"}, {2, "hehe"}};

            //
            // Genericなオブジェクトの型引数の型を取得するには、System.Typeクラスの以下のメソッドを利用する。
            //
            //   ・GetGenericArguments()
            //
            // GetGenericArgumentsメソッドは、System.Typeの配列を返すので、これを利用して型引数の型を判別する。
            //
            var genericArgTypes = theList.GetType().GetGenericArguments();
            Output.WriteLine("=============== List<int>の場合 =================");
            Output.WriteLine("型引数の数={0}, 型引数の型=({1})", genericArgTypes.Count(), string.Join(",", genericArgTypes.Select(item => item.Name)));

            genericArgTypes = theDictionary.GetType().GetGenericArguments();
            Output.WriteLine("=============== Dictionary<int, string>の場合 =================");
            Output.WriteLine("型引数の数={0}, 型引数の型=({1})", genericArgTypes.Count(), string.Join(",", genericArgTypes.Select(item => item.Name)));
        }
Example #15
0
        public static string GetAllHints()
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("苹果4代iphone正品", "21782");
            data.Add("苹果4代 手机套", "238061");
            data.Add("苹果4", "838360");
            data.Add("苹果皮", "242721");
            data.Add("苹果笔记本", "63348");
            data.Add("苹果4s", "24030");
            data.Add("戴尔笔记本", "110105");
            data.Add("戴尔手机", "18870");
            data.Add("戴尔键盘", "30367");

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(data.GetType());

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.WriteObject(ms, data);
                return System.Text.Encoding.UTF8.GetString(ms.ToArray());
            }
        }
Example #16
0
        public static string SerializeDict(Dictionary<string, int> d)
        {

            // serialize the dictionary
            DataContractSerializer serializer = new DataContractSerializer(d.GetType());

            using (StringWriter sw = new StringWriter())
            {
                using (XmlTextWriter writer = new XmlTextWriter(sw))
                {
                    // add formatting so the XML is easy to read in the log
                    writer.Formatting = Formatting.Indented;

                    serializer.WriteObject(writer, d);

                    writer.Flush();

                    return sw.ToString();
                }
            }
        }
Example #17
0
        public void TestWriteInt8KeyMap()
        {
            var name = "test";
            var value = new Dictionary<byte, dynamic>()
            {
                {1, "0"},
                {2, "1"}
            };
            var attribute = XFireAttributeFactory.Instance.GetAttribute(value.GetType());

            using (var ms = new MemoryStream())
            {
                using (var writer = new BinaryWriter(ms))
                {
                    attribute.WriteAll(writer, name, value);
                }

                var expected = new byte[] { 0x04, 0x74, 0x65, 0x73, 0x74, 0x09, 0x02, 0x01, 0x01, 0x01, 0x00, 0x030,
                                                                                      0x02, 0x01, 0x01, 0x00, 0x31 };
                Assert.IsTrue(ms.ToArray().SequenceEqual(expected));
            }
        }
Example #18
0
        public void Should_render_include_with_untyped_model()
        {
            var model = new Dictionary<string, object>();
            model.Add("Name", "Joe");

            RegisterTemplate("person", SyntaxTree.Block(
                SyntaxTree.WriteExpression(SyntaxTreeExpression.LateBound("Name"))
            ));
            var template = SyntaxTree.Block(
                SyntaxTree.WriteString("Hello "),
                SyntaxTree.Include("person", SyntaxTreeExpression.Self(model.GetType()))
            );

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("Hello Joe"));
        }
Example #19
0
 private Dictionary<string, string> SerializeSettings(string json)
 {
     // TODO: PROTECT THIS WITH TRY/CATCH
       Dictionary<string, string> o = new Dictionary<string,string>();
       using (Stream stream = new MemoryStream())
       {
     byte[] data = System.Text.Encoding.UTF8.GetBytes(json);
     stream.Write(data, 0, data.Length);
     stream.Position = 0;
     DataContractJsonSerializer deserializer = new DataContractJsonSerializer(o.GetType());
     o = (Dictionary<string, string>)deserializer.ReadObject(stream);
     textBoxProject.Text = o["Project"];
     textBoxVersion.Text = o["Version"];
     textBoxLocation.Text = o["Location"];
     return o;
       }
 }
Example #20
0
 private string DeserializeSettings()
 {
     Dictionary<string, string> o = new Dictionary<string,string>();
       o["Project"] = textBoxProject.Text;
       o["Version"] = textBoxVersion.Text;
       o["Location"] = textBoxLocation.Text;
       using (MemoryStream memoryStream = new MemoryStream())
       using (StreamReader reader = new StreamReader(memoryStream))
       {
     DataContractJsonSerializer serializer = new DataContractJsonSerializer(o.GetType());
     serializer.WriteObject(memoryStream, o);
     memoryStream.Position = 0;
     return reader.ReadToEnd();
       }
 }
        public void IsGenericTypeWithFirstDynamicTypeArgument_WhenGivenGenericTypeWithMoreThanOneGenericType_ReturnsFalse()
        {
            // ARRANGE
            var item = new Dictionary<int, string>();
            var type = item.GetType();

            // ACT
            var actual = type.IsGenericTypeWithFirstDynamicTypeArgument();

            // ASSERT
            Assert.IsFalse(actual);
        }
        /// <summary>
        /// This method can be used for serialize a token without have the connection opened :-)
        /// </summary>
        /// <param name="token"></param>
        /// <param name="configurationType"></param>
        /// <param name="additionalMetaData"></param>
        /// <returns></returns>
        public Stream SerializeSecurityTokenEx(ICloudStorageAccessToken token, Type configurationType, Dictionary<String, String> additionalMetaData)
        {
            var items = new Dictionary<String, String>();
            var stream = new MemoryStream();
            var serializer = new DataContractSerializer(items.GetType());

            // add the metadata 
            if (additionalMetaData != null)
            {
                foreach (KeyValuePair<String, string> kvp in additionalMetaData)
                {
                    items.Add(TokenMetadataPrefix + kvp.Key, kvp.Value);
                }
            }

            // save the token into our list
            StoreToken(items, token, configurationType);

            // write the data to stream
            serializer.WriteObject(stream, items);

            // go to start
            stream.Seek(0, SeekOrigin.Begin);

            // go ahead
            return stream;
        }
Example #23
0
        public void Apply(Form form, Localization localization)
        {
            FieldInfo messages_field;
            Dictionary<string, string> dict;
            dict = localization.langFile.getSectionKeys(form.Name + ".Text");
            foreach(KeyValuePair<string, string> entry in dict) {
                Control[] controls = form.Controls.Find(entry.Key, true);
                foreach(Control control in controls) {
                    if(!(control is ComboBox))
                        control.Text = entry.Value;
                }
            }

            messages_field = form.GetType().GetField("strings");
            Dictionary<string, string> messages = new Dictionary<string, string>();
            if(messages_field != null && messages_field.FieldType == messages.GetType()) {
                messages = messages_field.GetValue(form) as Dictionary<string, string>;
                ApplyStrings(form.Name, messages, localization);
            }

            messages_field = form.GetType().GetField("tooltip_messages");
            Dictionary<string, string[]> tips = new Dictionary<string, string[]>();
            if(messages_field != null && messages_field.FieldType == tips.GetType()) {
                tips = messages_field.GetValue(form) as Dictionary<string, string[]>;
                messages_field = form.GetType().GetField("toolTip");
                ToolTip toolTip = messages_field.GetValue(form) as ToolTip;
                dict = localization.langFile.getSectionKeys(form.Name + ".ToolTips");
                foreach (KeyValuePair<string, string> entry in dict) {
                    if (tips.ContainsKey(entry.Key)) {
                        foreach(string controlName in tips[entry.Key]) {
                            Control[] controls = form.Controls.Find(controlName, true);
                            foreach(Control control in controls)
                                toolTip.SetToolTip(control, entry.Value);
                        }
                    }
                    else {
                        Control[] controls = form.Controls.Find(entry.Key, true);
                        foreach(Control control in controls) {
                            if(control is TabPage)
                                (control as TabPage).ToolTipText = entry.Value;
                        }
                    }
                }
            }
        }
 public void CanWrite_IsTrue_IfAGenericDictionary()
 {
     var value = new Dictionary<string, int>();
     Assert.IsTrue(writer.CanWrite(value, value.GetType()));
 }
        public void DictionaryToListTest()
        {
            Serializer s = new Serializer(typeof(Dictionary<string, SimpleObject>));
            DictionaryToListConverter converter = new DictionaryToListConverter();
            converter.Context = "StringValue";
            s.Config.RegisterTypeConverter(typeof(Dictionary<string, SimpleObject>), converter);
            Dictionary<string, SimpleObject> dictionary = new Dictionary<string, SimpleObject>();
            dictionary["One"] = new SimpleObject();
            dictionary["One"].StringValue = "One";
            dictionary["One"].IntValue = 1;

            dictionary["Two"] = new SimpleObject();
            dictionary["Two"].StringValue = "Two";
            dictionary["Two"].IntValue = 2;

            object list = converter.ConvertFrom(dictionary, s.Context);
            Assert.IsTrue(s.Config.TypeHandlerFactory[list.GetType()].IsCollection(), "Converted list is not a collection");

            Dictionary<string, SimpleObject> targetDictionary = (Dictionary<string, SimpleObject>) converter.ConvertTo(list, dictionary.GetType(), s.Context);
            Assert.AreEqual(2, targetDictionary.Count, "Wrong number of items");
            Assert.IsTrue(targetDictionary.ContainsKey("One"), "Key (One) not in converted dictionary");
            Assert.IsTrue(targetDictionary.ContainsKey("Two"), "Key (Two) not in converted dictionary");

            Assert.AreEqual(1, targetDictionary["One"].IntValue, "One Value wrong");
            Assert.AreEqual(2, targetDictionary["Two"].IntValue, "Two Value wrong");
        }
        public void ClearLimit(object sender, RoutedEventArgs routedEventArgs)
        {
            APIRequest request = null;

            if((string)((Button)sender).Tag == "ClearUp") 
                request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.ClearLimitUp, "portfolio/setlimitup");
            else if((string)((Button)sender).Tag == "ClearDown")
                request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.ClearLimitDown, "portfolio/setlimitdown");

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            var token = localSettings.Values["token"];


            Dictionary<string, string> dict = new Dictionary<string, string>()
            {
                {"symbol", Symbol},
                {"limit", null}
            };
            var serializer = new DataContractJsonSerializer(dict.GetType(), new DataContractJsonSerializerSettings()
            {
                UseSimpleDictionaryFormat = true
            });
            MemoryStream stream = new MemoryStream();
            serializer.WriteObject(stream, dict);
            byte[] bytes = stream.ToArray();
            string content = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            request.Execute((string)token, content);
        }
        public void MainClick(object sender, RoutedEventArgs routedEventArgs)
        {
            if (Favorite == false)
            {
                APIRequest request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.Favorite, "portfolio/favorite");
                Dictionary<string, string> dict = new Dictionary<string, string>()
                {
                    {"symbol", Symbol}
                };
                var serializer = new DataContractJsonSerializer(dict.GetType(), new DataContractJsonSerializerSettings()
                {
                    UseSimpleDictionaryFormat = true
                });
                MemoryStream stream = new MemoryStream();
                serializer.WriteObject(stream, dict);
                byte[] bytes = stream.ToArray();
                string content = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                var token = localSettings.Values["token"];

                request.Execute((string) token, content);
            }
            else
            {
                APIRequest request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.Unfavorite, "portfolio/unfavorite");

                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                var token = localSettings.Values["token"];

                request.Execute((string)token, null);
            }

        }
Example #28
0
 private System.CodeDom.Compiler.CodeDomProvider SafeGetCSharpVersion3Compiler()
 {
     System.CodeDom.Compiler.CodeDomProvider provider = null;
     foreach (ConstructorInfo info in typeof(CSharpCodeProvider).GetConstructors())
     {
         ParameterInfo[] parameters = info.GetParameters();
         if (parameters.Length == 1)
         {
             Dictionary<string, string> dictionary = new Dictionary<string, string>();
             dictionary["CompilerVersion"] = "v3.5";
             if (parameters[0].ParameterType.IsAssignableFrom(dictionary.GetType()))
             {
                 provider = (System.CodeDom.Compiler.CodeDomProvider) info.Invoke(new object[] { dictionary });
                 break;
             }
         }
     }
     if (provider == null)
     {
         throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, AddTypeStrings.SpecialNetVersionRequired, new object[] { Microsoft.PowerShell.Commands.Language.CSharpVersion3.ToString(), "3.5" }));
     }
     return provider;
 }
        public void DeleteShare()
        {
            APIRequest request = request = new APIRequest(APIRequest.POST, this, APIRequest.requestCodeType.PortfolioRemove, "portfolio/remove");

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            var token = localSettings.Values["token"];
            
            Dictionary<string, string> dict = new Dictionary<string, string>()
            {
                {"symbol", Symbol}
            };
            var serializer = new DataContractJsonSerializer(dict.GetType(), new DataContractJsonSerializerSettings()
            {
                UseSimpleDictionaryFormat = true
            });
            MemoryStream stream = new MemoryStream();
            serializer.WriteObject(stream, dict);
            byte[] bytes = stream.ToArray();
            string content = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            request.Execute((string)token, content);
        }
Example #30
0
        public void ShouldAssingMapWithArrayKeysToNativeArrayKeyDictionary()
        {
            var arrayKeyDictionary = new Dictionary<int[], string>{
                {new int[]{1}, "test"}
            };

            SinTDArray keyArray = new SinTDArray();
            keyArray.elementType = SinTDInstance.GetSinTDType("i32");
            SinTDMap SinTDMap = new SinTDMap();

            SinTDMap.keyType = keyArray;
            SinTDMap.elementType = SinTDInstance.GetSinTDType("string");
            Dictionary<int[], string> nativeDictionary = (Dictionary<int[], string>)SinTDMap
                .AssignValuesToNativeType(arrayKeyDictionary, arrayKeyDictionary.GetType());
            Assert.AreEqual(arrayKeyDictionary.Keys, nativeDictionary.Keys);
            Assert.AreEqual(arrayKeyDictionary.Values, nativeDictionary.Values);
        }