当前位置: 首页>>代码示例>>C#>>正文


C# ObjectWriter类代码示例

本文整理汇总了C#中ObjectWriter的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter类的具体用法?C# ObjectWriter怎么用?C# ObjectWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectWriter类属于命名空间,在下文中一共展示了ObjectWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteChild

		protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
		{
			if (writer.Format == FileFormat.Glade || Type == ButtonType.Custom)
				return base.WriteChild (writer, wrapper);
			else
				return null;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:Button.cs

示例2: WriteChild

		protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
		{
			XmlElement child_elem = base.WriteChild (writer, wrapper);
			if (tabs.Contains (wrapper.Wrapped))
				GladeUtils.SetChildProperty (child_elem, "type", "tab");
			return child_elem;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:Notebook.cs

示例3: WriteTo

            public override void WriteTo(Encoding encoding, ObjectWriter writer, CancellationToken cancellationToken)
            {
                if (encoding == null)
                {
                    base.WriteTo(encoding, writer, cancellationToken);
                    return;
                }

                cancellationToken.ThrowIfCancellationRequested();

                writer.WriteByte(EncodingSerialization);

                byte[] value;
                if (!s_encodingCache.TryGetValue(encoding, out value))
                {
                    // we don't have cache, cache it
                    var formatter = new BinaryFormatter();
                    using (var stream = SerializableBytes.CreateWritableStream())
                    {
                        // unfortunately, this is only way to properly clone encoding
                        formatter.Serialize(stream, encoding);
                        value = stream.ToArray();

                        // add if not already exist. otherwise, noop
                        s_encodingCache.TryAdd(encoding, value);
                    }
                }

                // write data out
                writer.WriteValue(value);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:31,代码来源:DesktopReferenceSerializationServiceFactory.cs

示例4: WriteChild

		protected override XmlElement WriteChild (ObjectWriter writer, Widget wrapper)
		{
			XmlElement child_elem = base.WriteChild (writer, wrapper);
			if (wrapper.Wrapped == expander.LabelWidget)
				GladeUtils.SetChildProperty (child_elem, "type", "label_item");
			return child_elem;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:Expander.cs

示例5: TestStringFragment

 /// <exception cref="System.Exception"></exception>
 public virtual void TestStringFragment()
 {
     string fragment = "01234567890";
     ObjectWriter mapper = new ObjectWriter();
     byte[] json = mapper.WriteValueAsBytes(fragment);
     JsonDocument jsdoc = new JsonDocument(json);
     NUnit.Framework.Assert.AreEqual(fragment, jsdoc.JsonObject());
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:9,代码来源:JsonDocumentTest.cs

示例6: WriteProperties

		protected override XmlElement WriteProperties (ObjectWriter writer)
		{
			XmlElement elem = base.WriteProperties (writer);
			string group = GroupManager.GladeGroupName (Wrapped);
			if (group != Wrapped.Name)
				GladeUtils.SetProperty (elem, "group", group);
			return elem;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:RadioToolButton.cs

示例7: Write

 public void Write(ObjectWriter writer)
 {
     writer.PrimitiveWriter.Write(Name);
     writer.PrimitiveWriter.Write(Version);
     writer.PrimitiveWriter.Write(CultureName);
     writer.PrimitiveWriter.Write((byte)Token.Length);
     writer.PrimitiveWriter.Write(Token);
 }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:8,代码来源:AssemblyDescriptor.cs

示例8: Main

        static void Main(string[] args)
        {
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Loopback, 4040);
            Socket ss = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            var productos = new ObservableCollection<Producto>();
            for (int i = 0; i < 20; i++)
            {
                productos.Add(new Producto()
                {
                    ProductId = i,
                    Nombre = "Producto servidor" + i,
                    Precio = (decimal)i,
                    CantidadDisponible = i * 10,
                    Descripcion = "The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. Usually it is best to"
                });
            }

            try
            {
                ss.Bind(localEndPoint);
                ss.Listen(10);
                while (true)
                {
                    Console.WriteLine("Servidor escuchando por conexiones");
                    Socket cliente = ss.Accept();
                    string descCliente = cliente.LocalEndPoint.ToString();
                    Console.WriteLine("Conexion aceptada " + descCliente);
                    ObjectWriter w = new ObjectWriter(cliente);
                    ObjectReader r = new ObjectReader(cliente);

                    Transacciones transaccion = (Transacciones)r.ReadInt32();
                    switch (transaccion)
                    {
                        case Transacciones.SolicitarCarrito:
                            Console.WriteLine("\tSolicitud de carrito por: " + descCliente);
                            w.WriteInt32(productos.Count);
                            for (int i = 0; i < productos.Count; i++)
                            {
                                w.WriteObject<Producto>(productos[i]);
                            }
                            break;
                        case Transacciones.RealizarCompra:
                            Console.WriteLine("\tOrden de compra de " + descCliente);
                            Orden o = r.ReadObject<Orden>();
                            productos[o.ProductId].CantidadDisponible -= o.Cantidad;
                            break;
                    }
                    Console.WriteLine("Conexion terminada " + descCliente);
                    cliente.Shutdown(SocketShutdown.Both);
                    cliente.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
开发者ID:rokerdan,项目名称:aplicaciones-redes,代码行数:58,代码来源:Program.cs

示例9: WriteProperties

		protected override XmlElement WriteProperties (ObjectWriter writer)
		{
			XmlElement elem = base.WriteProperties (writer);
			if (menuInfo != null)
				elem.AppendChild (writer.XmlDocument.ImportNode (menuInfo, true));
			else
				elem.AppendChild (actionTree.Write (writer.XmlDocument, writer.Format));
			return elem;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:MenuBar.cs

示例10: Write

		public override XmlElement Write (ObjectWriter writer)
		{
			XmlElement group = writer.XmlDocument.CreateElement ("action-group");
			group.SetAttribute ("name", name);
			if (writer.CreateUndoInfo)
				group.SetAttribute ("undoId", UndoId);
			foreach (Action ac in actions) {
				if (ac.Name.Length > 0)
					group.AppendChild (writer.WriteObject (ac));
			}
			return group;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:12,代码来源:ActionGroup.cs

示例11: Load

 private object Load(XamlXmlReader reader)
 {
     XamlObjectWriter writer = new ObjectWriter();
     while (reader.Read())
     {
         writer.WriteNode(reader);
     }
     writer.Close();
     reader.Close();
     if (writer.Result is DependencyObject && !(writer is INameScope))
         ((DependencyObject)writer.Result).SetValue(NameScope.NameScopeProperty, writer.RootNameScope);
     return writer.Result;
 }
开发者ID:Kation,项目名称:WebPresentation,代码行数:13,代码来源:XamlReader.cs

示例12: TestJsonArray

 /// <exception cref="System.Exception"></exception>
 public virtual void TestJsonArray()
 {
     IList<object> array = new AList<object>();
     array.AddItem("01234567890");
     array.AddItem("bar");
     array.AddItem(5);
     array.AddItem(3.5);
     array.AddItem(true);
     array.AddItem(new DateTime().ToString());
     ObjectWriter mapper = new ObjectWriter();
     byte[] json = mapper.WriteValueAsBytes(array);
     JsonDocument jsdoc = new JsonDocument(json);
     NUnit.Framework.Assert.AreEqual(array, jsdoc.JsonObject());
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:15,代码来源:JsonDocumentTest.cs

示例13: TestJsonObject

 /// <exception cref="System.Exception"></exception>
 public virtual void TestJsonObject()
 {
     IDictionary<string, object> dict = new Dictionary<string, object>();
     dict.Put("id", "01234567890");
     dict.Put("foo", "bar");
     dict.Put("int", 5);
     dict.Put("double", 3.5);
     dict.Put("bool", true);
     dict.Put("date", new DateTime().ToString());
     ObjectWriter mapper = new ObjectWriter();
     byte[] json = mapper.WriteValueAsBytes(dict);
     JsonDocument jsdoc = new JsonDocument(json);
     NUnit.Framework.Assert.AreEqual(dict, jsdoc.JsonObject());
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:15,代码来源:JsonDocumentTest.cs

示例14: Encode

 // create the same JSON encoding used by TouchDB
 // this lets us test comparisons as they would be encoded
 public virtual string Encode(object obj)
 {
     ObjectWriter mapper = new ObjectWriter();
     try
     {
         byte[] bytes = mapper.WriteValueAsBytes(obj);
         string result = Sharpen.Runtime.GetStringForBytes(bytes);
         return result;
     }
     catch (Exception e)
     {
         Log.E(Tag, "Error encoding JSON", e);
         return null;
     }
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:17,代码来源:CollationTest.cs

示例15: RealizaCompra

        public int RealizaCompra(int productId, int cantidad)
        {
            IPEndPoint remotePoint = new IPEndPoint(IPAddress.Loopback, 4040);
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            s.Connect(remotePoint);
            ObjectReader r = new ObjectReader(s);
            ObjectWriter w = new ObjectWriter(s);

            w.WriteInt32((int)Transacciones.RealizarCompra);
            Orden o = new Orden { ProductId = productId, Cantidad = cantidad };
            w.WriteObject<Orden>(o);
            s.Shutdown(SocketShutdown.Both);
            s.Close();
            return 1;
        }
开发者ID:rokerdan,项目名称:aplicaciones-redes,代码行数:15,代码来源:CarritoModel.cs


注:本文中的ObjectWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。