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


C# Variant类代码示例

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


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

示例1: TestStreams

                public void TestStreams()
                {
                    Variant dict = new Variant(Variant.EnumType.Dictionary);
                    dict.Add("key1", new Variant("value1"));
                    dict.Add("key2", new Variant("value2"));

                    Variant input = new Variant(Variant.EnumType.List);
                    for (int i = 0; i < 10000; ++i)
                    {
                        input.Add(dict);
                    }

                    System.IO.MemoryStream istream = new System.IO.MemoryStream();
                    using(BinaryWriter writer = new BinaryWriter(istream))
                    {
                        writer.Write(input);
                    }

                    Variant output;
                    System.IO.MemoryStream ostream = new System.IO.MemoryStream(istream.GetBuffer());
                    using (BinaryReader reader = new BinaryReader(ostream))
                    {
                        output = reader.Read();
                    }

                    Assert.True(input.Equals(output));
                }
开发者ID:rokstrnisa,项目名称:protean,代码行数:27,代码来源:TestBinaryStreams.cs

示例2: TestComparison

        public void TestComparison()
        {
            TypedArray a1 = new TypedArray(Variant.EnumType.Double, 2);
            a1[0] = 1.0;
            a1[1] = 2.0;

            Variant v1 = new Variant(a1);

            TypedArray a2 = new TypedArray(Variant.EnumType.Double, 2);
            a2[0] = 1.0;
            a2[1] = 2.0;

            Variant v2 = new Variant(a2);

            TypedArray a3 = new TypedArray(Variant.EnumType.Double, 2);
            a3[0] = 2.0;
            a3[1] = 1.0;

            Variant v3 = new Variant(a3);

            Assert.IsTrue(v1.Equals(v2));
            Assert.IsFalse(v1.Equals(v3));

            Assert.AreEqual(0, v1.CompareTo(v2));
            Assert.AreEqual(-1, v2.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v2));
        }
开发者ID:proteanic,项目名称:protean,代码行数:27,代码来源:TestArray.cs

示例3: ConvertToNamedValueList

    public static List<NamedValue> ConvertToNamedValueList(IntPtr pXmlSection)
    {
      if (IntPtr.Zero == pXmlSection)
        return null;

      List<Rhino.Render.NamedValue> list = new List<NamedValue>();

      IntPtr pIterator = UnsafeNativeMethods.Rdk_XmlSection_GetIterator(pXmlSection);

      //Fill the property list from the XML section
      if (pIterator != IntPtr.Zero)
      {
        while (true)
        {
          using (var sh = new StringHolder())
          {
            Variant variant = new Variant();

            if (1 == UnsafeNativeMethods.Rdk_XmlSection_NextParam(pXmlSection, pIterator, sh.ConstPointer(), variant.ConstPointer()))
            {
              NamedValue nv = new NamedValue(sh.ToString(), variant.AsObject());
              list.Add(nv);
            }
            else
              break;
          }
        }

        UnsafeNativeMethods.Rdk_XmlSection_DeleteIterator(pIterator);
      }

      return list;
    }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:33,代码来源:rdk_variant.cs

示例4: NewName

 public static Variant NewName(BlockBase parent, string name)
 {
     var ret = new Variant();
     ret.Parent = parent;
     ret.name = name;
     return ret;
 }
开发者ID:7shi,项目名称:LLPML,代码行数:7,代码来源:Variant.cs

示例5: Npc

 public Npc(Variant config)
 {
     ID = config.GetStringOrDefault("_id");
     NpcType = config.GetStringOrDefault("SubType");
     Name = config.GetStringOrDefault("Name");
     m_value = config.GetVariantOrDefault("Value");
     if (m_value != null)
     {
         m_task = m_value.GetVariantOrDefault("Task");
         SceneID = m_value.GetStringOrDefault("SceneID");
         X = m_value.GetIntOrDefault("X");
         Y = m_value.GetIntOrDefault("Y");
         object lev;
         if (m_value.TryGetValueT("MustKill", out lev))
         {
             if (lev is bool)
             {
                 if ((bool)lev)
                 {
                     m_killLev = 1;
                 }
             }
             else if (lev != null)
             {
                 int.TryParse(lev.ToString(), out m_killLev);
             }
         }
     }
 }
开发者ID:abel,项目名称:sinan,代码行数:29,代码来源:NPC.cs

示例6: TestDictionaryEnumerator

                public void TestDictionaryEnumerator()
                {
                    Variant dict = new Variant(Variant.EnumType.Dictionary);

                    for (int i = 0; i < 1; ++i)
                    {
                        dict.Add(i.ToString(), new Variant(i));
                    }

                    // Generic enumerator
                    int count = 0;
                    foreach (VariantItem item in dict)
                    {
                        Assert.True(item.Value.AsInt32().Equals(count));
                        Assert.True(item.Key.Equals(count.ToString()));
                        Assert.Throws(typeof(VariantException),
                            delegate { DateTime time = item.Time; }
                        );
                        ++count;
                    }

                    // Non-generic enumerator
                    count = 0;
                    foreach (var item in dict)
                    {
                        Assert.True(item.Value.AsInt32().Equals(count));
                        Assert.True(item.Key.Equals(count.ToString()));
                        Assert.Throws(typeof(VariantException),
                            delegate { DateTime time = item.Time; }
                        );
                        ++count;
                    }
                }
开发者ID:rokstrnisa,项目名称:protean,代码行数:33,代码来源:TestEnumerator.cs

示例7: TestString

                public void TestString()
                {
                    String s = "hello";
                    Variant v = new Variant(s);

                    Assert.AreEqual(s, v.AsString());
                }
开发者ID:rokstrnisa,项目名称:protean,代码行数:7,代码来源:TestTypes.cs

示例8: TestStringAsDouble

                public void TestStringAsDouble()
                {
                    String s = "hello";
                    Variant v = new Variant(s);

                    v.AsDouble();
                }
开发者ID:rokstrnisa,项目名称:protean,代码行数:7,代码来源:TestTypes.cs

示例9: Broadcast

 public override void Broadcast(uint appId, BaseProtocol pFrom, Variant invokeInfo)
 {
     foreach (var inboundClusterProtocol in InboundClusters.Where(inboundClusterProtocol => pFrom != inboundClusterProtocol))
     {
         inboundClusterProtocol.Broadcast(appId, pFrom, invokeInfo);
     }
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:7,代码来源:MasterClusterAppProtocolHandler.cs

示例10: UpdateList

        /// <summary>
        /// Updates the list control.
        /// </summary>
        private void UpdateList(Session session, Argument[] arguments, string browseName)
        {
            for (int ii = 0; ii < arguments.Length; ii++)
            {
                Argument argument = arguments[ii];
                Variant defaultValue = new Variant(TypeInfo.GetDefaultValue(argument.DataType, argument.ValueRank));

                ListViewItem item = new ListViewItem(arguments[ii].Name);

                if (browseName == BrowseNames.InputArguments)
                {
                    item.SubItems.Add("IN");
                    m_firstOutputArgument++;
                }
                else
                {
                    item.SubItems.Add("OUT");
                }

                string dataType = session.NodeCache.GetDisplayText(arguments[ii].DataType);

                if (arguments[ii].ValueRank >= 0)
                {
                    dataType += "[]";
                }

                item.SubItems.Add(defaultValue.ToString());
                item.SubItems.Add(dataType);
                item.SubItems.Add(Utils.Format("{0}", arguments[ii].Description));
                item.Tag = defaultValue;

                ArgumentsLV.Items.Add(item);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:37,代码来源:CallMethodDlg.cs

示例11: GenerateVariants

 private static IEnumerable<Variant> GenerateVariants(Variant variant, Potter aBook, IEnumerable<Variant> alreadyGenerated)
 {
     return variant.Piles
         .Where(pile => !pile.Contains(aBook))
         .Select(pile => CreateNewVariant(variant, pile, aBook))
         .Where(newVariant => alreadyGenerated.All(v => !v.Equals(newVariant)));
 }
开发者ID:darkiri,项目名称:Kata,代码行数:7,代码来源:ExpansivePriceCalculator.cs

示例12: SO

 public SO(BaseClientApplication app,string name, bool persistent)
 {
     Name = name;
     Application = app;
     IsPersistent = persistent;
     Version = 1;
     if (persistent)
     {
         _filePath = app.SOPath + Name + ".so";
         if (File.Exists(_filePath))
         {
             Variant.DeserializeFromFile(_filePath, out Payload);
         }
         else
         {
             Payload = Variant.Get();
             //File.Create(_filePath).Close();
         }
     }
     else
     {
         Payload = Variant.Get();
     }
     if (ClientApplicationManager.ClusterApplication != null)
         ClientApplicationManager.ClusterApplication.GetProtocolHandler<BaseClusterAppProtocolHandler>().OnSOCreated(this);
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:26,代码来源:SO.cs

示例13: ProcessSharedObjectPrimitive

 private bool ProcessSharedObjectPrimitive(BaseRTMPProtocol pFrom, SO pSO, string name, Variant request,
     int primitiveId)
 {
     var primitive = request[Defines.RM_SHAREDOBJECT,Defines.RM_SHAREDOBJECT_PRIMITIVES][ primitiveId];
     switch ((byte)primitive[Defines.RM_SHAREDOBJECTPRIMITIVE_TYPE])
     {
         case Defines.SOT_CS_CONNECT:
             pSO.RegisterProtocol(pFrom);
             return true;
         case Defines.SOT_CS_DISCONNECT:
             UnRegisterProtocol(pFrom);
             return true;
         case Defines.SOT_CSC_DELETE_DATA:
             pSO.UnSet(primitive[Defines.RM_SHAREDOBJECTPRIMITIVE_PAYLOAD],pFrom);
             return true;
         case Defines.SOT_CS_SET_ATTRIBUTE:
             if (pSO == null)
             {
                 Logger.FATAL("SO is null");
                 return false;
             }
             foreach (KeyValuePair<string,Variant> item in primitive [Defines.RM_SHAREDOBJECTPRIMITIVE_PAYLOAD])
             {
                 pSO.Set(item.Key, item.Value.Clone(), pFrom);
             }
             return true;
         case Defines.SOT_BW_SEND_MESSAGE:
             pSO?.Send(primitive, pFrom);
             return true;
         default:
             Logger.FATAL("SO primitive not allowed here");
             return false;
     }
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:34,代码来源:SOManager.cs

示例14: TestConstruction

        public void TestConstruction()
        {
            TestObject1 obj1 = new TestObject1("some value");

            Variant v1 = new Variant(obj1);
            Assert.AreEqual(v1.Type, Variant.EnumType.Object);

            TestObject1 obj2 = v1.AsObject<TestObject1>();
            Assert.AreEqual(obj1, obj2);

            Assert.Throws<VariantException>(delegate { v1.AsObject<TestObject2>(); });
            Assert.Throws<VariantException>(delegate { v1.AsObject<VariantObjectProxy>(); });

            VariantObjectProxy obj3 = new VariantObjectProxy(obj1.Class);
            obj3.Inflate(obj2.Deflate(), obj2.Version);

            Assert.AreEqual(obj3.Class, "TestObject1");
            Assert.AreEqual(obj3.Version, 1);
            Assert.AreEqual(obj3.Deflate().Type, Variant.EnumType.Dictionary);

            Variant v2 = new Variant(obj3);

            Assert.IsInstanceOf<VariantObjectProxy>(v2.AsObject());

            Assert.Throws<VariantException>(delegate { v1.AsObject<TestObject2>(); });

            TestObject1 obj5 = v2.AsObject<TestObject1>();
            Assert.AreEqual(obj5.Class, "TestObject1");
            Assert.AreEqual(obj5.Version, 1);

            Assert.IsInstanceOf<TestObject1>(v2.AsObject());
        }
开发者ID:proteanic,项目名称:protean,代码行数:32,代码来源:TestObject.cs

示例15: TestBasic

 public void TestBasic()
 {
     Variant v = new Variant(new byte[] { 0x01, 0x02, 0x03 });
     Assert.AreEqual(v.Type, Variant.EnumType.Buffer);
     Assert.IsTrue(v.Is(Variant.EnumType.Buffer));
     Assert.IsTrue(SequenceComparer.Compare(v.AsBuffer(), new byte[] { 0x01, 0x02, 0x03 })==0);
 }
开发者ID:proteanic,项目名称:protean,代码行数:7,代码来源:TestBuffer.cs


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