本文整理汇总了C#中TypedObject类的典型用法代码示例。如果您正苦于以下问题:C# TypedObject类的具体用法?C# TypedObject怎么用?C# TypedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypedObject类属于命名空间,在下文中一共展示了TypedObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Alter
public void Alter()
{
var testObj = new TypedObject();
var dict = new DynamicAdapter(testObj, new MapOptions {
CanAlterProperties = false
});
dynamic dyn = dict;
Assert.Throws<InvalidOperationException>(() =>
{
dyn.newprop = "newdata";
}, "Can't add a prop");
Assert.Throws<InvalidOperationException>(() =>
{
dict.Remove("Stringprop");
}, "Can't rmove a prop");
// we can update with just CanAlterProprerties=false but IsReadOnly=true
dyn.stringprop = "stringdata";
dict.Options.CanAlterProperties = true;
dyn.newprop = "newdata";
Assert.AreEqual("newdata",dict["Newprop"]);
Assert.IsTrue(dict.ContainsKey("stringprop"));
dict.Remove("Stringprop");
Assert.IsFalse(dict.ContainsKey("stringprop"));
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:32,代码来源:DynamicAdapter.cs
示例2: DecodeConnect
public TypedObject DecodeConnect(byte[] data)
{
Reset();
dataBuffer = data;
dataPos = 0;
TypedObject result = new TypedObject("Invoke");
result.Add("result", DecodeAMF0());
result.Add("invokeId", DecodeAMF0());
result.Add("serviceCall", DecodeAMF0());
result.Add("data", DecodeAMF0());
if (dataPos != dataBuffer.Length)
{
for (int i = dataPos; i < data.Length; i++)
{
if (ReadByte() != '\0')
throw new Exception("There is other data in the buffer!");
}
}
if (dataPos != dataBuffer.Length)
throw new Exception("Did not consume entire buffer: " + dataPos + " of " + dataBuffer.Length);
return result;
}
开发者ID:BraveStarr1,项目名称:LegendaryClient,代码行数:25,代码来源:RTMPSDecoder.cs
示例3: DecodeInvoke
public TypedObject DecodeInvoke(byte[] data)
{
Reset();
dataBuffer = data;
dataPos = 0;
TypedObject result = new TypedObject("Invoke");
if (dataBuffer[0] == 0x00)
{
dataPos++;
result.Add("version", 0x00);
}
result.Add("result", DecodeAMF0());
result.Add("invokeId", DecodeAMF0());
result.Add("serviceCall", DecodeAMF0());
result.Add("data", DecodeAMF0());
if (dataPos != dataBuffer.Length)
throw new Exception("Did not consume entire buffer: " + dataPos + " of " + dataBuffer.Length);
string[] typeNames = new string[classDefinitions.Count];
for (int i = 0; i < classDefinitions.Count; i++)
{
typeNames[i] = classDefinitions[i].type;
}
return result;
}
开发者ID:NitroXenon,项目名称:PVPNetConnect,代码行数:29,代码来源:RTMPSDecoder.cs
示例4: Alter
public void Alter()
{
//var dict2 = new Dictionary<string, object>();
//var x = dict2["abc"];
var testObj = new TypedObject();
var dict = new PropertyDictionaryAdapter(testObj);
dict.Options.CanAlterProperties = false;
Assert.Throws<InvalidOperationException>(() =>
{
dict["newprop"] = "newdata";
}, "Can't add a prop");
Assert.Throws<InvalidOperationException>(() =>
{
dict.Remove("Stringprop");
}, "Can't add a prop");
// These are OK to do
dict["stringprop"] = "stringdata";
dict.Options.CanAlterProperties = true;
dict["newprop"] = "newdata";
Assert.AreEqual("newdata",dict["Newprop"]);
Assert.IsTrue(dict.ContainsKey("stringprop"));
dict.Remove("Stringprop");
Assert.IsFalse(dict.ContainsKey("stringprop"));
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:31,代码来源:PropertyDictionaryAdapter.cs
示例5: Contains
public void Contains()
{
var testObj = new TypedObject();
var dict = new PropertyDictionaryAdapter(testObj);
var intArray = new int[] {1,2,3};
testObj.IntArray = intArray;
Assert.IsTrue(dict.Contains(new KeyValuePair<string,object>("IntArray",intArray)));
Assert.IsFalse(dict.Contains(new KeyValuePair<string,object>("IntArray",new int[] {1,2,3})));
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:10,代码来源:DynamicAdapter.cs
示例6: Clear
public void Clear()
{
var testObj = new TypedObject();
var dict = new PropertyDictionaryAdapter(testObj);
testObj.StringField = "changed";
Assert.AreEqual("changed", dict["stringfield"],"Propert of underlying object affected by a change to dict");
dict.Clear();
Assert.AreEqual(0, dict.Count);
dict["stringfield"] = "string data";
Assert.AreEqual("changed", testObj.StringField,"Same-named property no longer affects object after a clear");
Assert.AreEqual("string data", dict["stringfield"], "Same-named property no longer affects object after a clear");
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:15,代码来源:PropertyDictionaryAdapter.cs
示例7: Add
public void Add()
{
var testObj = new TypedObject();
var dict = new PropertyDictionaryAdapter(testObj);
Assert.AreEqual(13, dict.Count);
dict["stringfield"] = "New string data";
Assert.AreEqual(13, dict.Count);
Assert.AreEqual("New string data", dict["Stringfield"]);
Assert.AreEqual("New string data", testObj.StringField);
dict["MyNewProp"] = "added data";
Assert.AreEqual(14, dict.Count);
Assert.AreEqual("added data", dict["mynewprop"]);
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:16,代码来源:PropertyDictionaryAdapter.cs
示例8: EncodeConnect
public byte[] EncodeConnect(Dictionary<string, object> paramaters)
{
startTime = (long)DateTime.Now.TimeOfDay.TotalMilliseconds;
List<Byte> result = new List<Byte>();
WriteStringAMF0(result, "connect");
WriteIntAMF0(result, 1); // invokeId
// Write params
result.Add((byte)0x11); // AMF3 object
result.Add((byte)0x09); // Array
WriteAssociativeArray(result, paramaters);
// Write service call args
result.Add((byte)0x01);
result.Add((byte)0x00); // false
WriteStringAMF0(result, "nil"); // "nil"
WriteStringAMF0(result, ""); // ""
// Set up CommandMessage
TypedObject cm = new TypedObject("flex.messaging.messages.CommandMessage");
cm.Add("operation", 5);
cm.Add("correlationId", "");
cm.Add("timestamp", 0);
cm.Add("messageId", RandomUID());
cm.Add("body", new TypedObject(null));
cm.Add("destination", "");
Dictionary<string, object> headers = new Dictionary<string, object>();
headers.Add("DSMessagingVersion", 1.0);
headers.Add("DSId", "my-rtmps");
cm.Add("headers", headers);
cm.Add("clientId", null);
cm.Add("timeToLive", 0);
// Write CommandMessage
result.Add((byte)0x11); // AMF3 object
Encode(result, cm);
byte[] ret = new byte[result.Count];
for (int i = 0; i < ret.Length; i++)
ret[i] = result[i];
ret = AddHeaders(ret);
ret[7] = (byte)0x14; // Change message type
return ret;
}
开发者ID:phanminh22,项目名称:ChallengerBot_WebControl,代码行数:47,代码来源:RTMPSEncoder.cs
示例9: Add
public void Add()
{
var testObj = new TypedObject();
var dict = new DynamicAdapter(testObj);
dict.Options.CanAlterProperties = true;
dynamic dyn = dict;
Assert.AreEqual(13, dict.Count);
dyn.stringfield = "New string data";
Assert.AreEqual(13, dict.Count);
Assert.AreEqual("New string data", dyn.Stringfield);
Assert.AreEqual("New string data", testObj.StringField);
dyn.MyNewProp = "added data";
Assert.AreEqual(14, dict.Count);
Assert.AreEqual("added data", dyn.mynewprop);
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:18,代码来源:DynamicAdapter.cs
示例10: encodeConnect
/// <summary>
/// Encodes the given parameters as a val packet
/// </summary>
/// <param name="parameters">The connection parameters.</param>
/// <returns>The val packet.</returns>
public byte[] encodeConnect(Dictionary<string, object> parameters)
{
var result = new List<byte>();
writestringAMFO(result, "val");
// Write invokeid
writeIntAMFO(result, 1);
// Write params
result.Add(0x11); // AMF3 object
result.Add(0x09); // Array
writeAssociativeArray(result, parameters);
// Write service call args
result.Add(0x01);
result.Add(0x00); // False
writestringAMFO(result, "nil");
writestringAMFO(result, "");
// Set up CommandMessage
var cm = new TypedObject("flex.messaging.messages.CommandMessage");
cm.Add("messageRefType", null);
cm.Add("operation", 5);
cm.Add("correlationId", "");
cm.Add("clientId", null);
cm.Add("destination", "");
cm.Add("messageId", randomUID());
cm.Add("timestamp", 0d);
cm.Add("timeToLive", 0d);
cm.Add("body", new TypedObject(null));
var headers = new Dictionary<string, object>();
headers.Add("DSMessagingVersion", 1d);
headers.Add("DSId", "my-rtmps");
cm.Add("headers", headers);
// Write CommandMessage
result.Add(0x11); // AMF3 object
encode(result, cm);
return AddHeaders(result.ToArray());
}
开发者ID:ResQue1980,项目名称:libopenpvp.net,代码行数:47,代码来源:AMF3Encoder.cs
示例11: DecodeInvoke
public TypedObject DecodeInvoke(byte[] data)
{
Reset();
dataBuffer = data;
dataPos = 0;
TypedObject result = new TypedObject("Invoke");
if (dataBuffer[0] == 0x00)
{
dataPos++;
result.Add("version", 0x00);
}
result.Add("result", DecodeAMF0());
result.Add("invokeId", DecodeAMF0());
result.Add("serviceCall", DecodeAMF0());
result.Add("data", DecodeAMF0());
if (dataPos != dataBuffer.Length)
throw new Exception("Did not consume entire buffer: " + dataPos + " of " + dataBuffer.Length);
return result;
}
开发者ID:42696c62616f,项目名称:LoLAutoQueue,代码行数:24,代码来源:RTMPSDecoder.cs
示例12: Inviter
public Inviter(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:phanminh22,项目名称:ChallengerBot_WebControl,代码行数:4,代码来源:Inviter.cs
示例13: SummonerLeaguesDTO
public SummonerLeaguesDTO(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:honomoa,项目名称:PVPNetConnect,代码行数:4,代码来源:SummonerLeaguesDTO.cs
示例14: MasteryBookDTO
public MasteryBookDTO(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:ResQue1980,项目名称:LegendaryClient,代码行数:4,代码来源:MasteryBookDTO.cs
示例15: LoginDataPacket
public LoginDataPacket(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:42696c62616f,项目名称:LoLAutoQueue,代码行数:4,代码来源:LoginDataPacket.cs
示例16: WriteObject
private void WriteObject(List<byte> ret, TypedObject val)
{
if (val.type == null || val.type.Equals(""))
{
ret.Add((byte)0x0B); // Dynamic class
ret.Add((byte)0x01); // No class name
foreach (string key in val.Keys)
{
WriteString(ret, key);
Encode(ret, val[key]);
}
ret.Add((byte)0x01); // End of dynamic
}
else if (val.type.Equals("flex.messaging.io.ArrayCollection"))
{
ret.Add((byte)0x07); // Externalizable
WriteString(ret, val.type);
Encode(ret, val["array"]);
}
else if (val.type.Equals("DSK"))
{
WriteInt(ret, (val.Count << 4) | 3); // Inline + member count
WriteString(ret, val.type);
byte[] flag1 = new byte[8];
byte[] flag2 = new byte[8];
if (val["body"] != null)
flag1[0] = 1;
if (val["clientId"] != null)
flag1[1] = 1;
if (val["destination"] != null)
flag1[2] = 1;
if (val["headers"] != null)
flag1[3] = 1;
if (val["messageId"] != null && val["clientId"] != null)
flag1[4] = 1;
if (val["timestamp"] != null && val["destination"] != null)
flag1[5] = 1;
if (val["timeToLive"] != null && val["headers"] != null)
flag1[6] = 1;
if (val["clientIdBytes"] != null)
flag2[0] = 1;
if (val["messageIdBytes"] != null)
flag2[1] = 1;
WriteObject(ret, val.GetTO("data"));
}
else
{
WriteInt(ret, (val.Count << 4) | 3); // Inline + member count
WriteString(ret, val.type);
List<String> keyOrder = new List<String>();
foreach (string key in val.Keys)
{
WriteString(ret, key);
keyOrder.Add(key);
}
foreach (string key in keyOrder)
Encode(ret, val[key]);
}
}
开发者ID:phanminh22,项目名称:ChallengerBot_WebControl,代码行数:65,代码来源:RTMPSEncoder.cs
示例17: Updating
public void Updating()
{
var testObj = new TypedObject();
var dict = new PropertyDictionaryAdapter(testObj);
Assert.AreEqual(0d, testObj.DoubleProp);
dict["doubleprop"] = 3.14;
Assert.AreEqual(3.14, testObj.DoubleProp);
Assert.Throws<InvalidCastException>(() =>
{
dict["doubleprop"] = "abc";
}, "Can't assign bad data type");
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:14,代码来源:PropertyDictionaryAdapter.cs
示例18: WrapperBasic
public void WrapperBasic()
{
var testObj = new TypedObject
{
StringProp="quick brown fox",
IntArray =new int[] { 1, 2, 4, 8 },
DoubleProp = 3.14,
StringList = new List<string> { "a","b","c" }
};
var dict = new PropertyDictionaryAdapter(testObj);
Assert.AreEqual("quick brown fox", dict["StringProp"]);
Assert.AreEqual(4, ((int[])dict["IntArray"])[2]);
Assert.AreEqual(3.14, dict["DoubleProp"]);
Assert.AreEqual("b", ((IList<string>)dict["StringList"])[1]);
}
开发者ID:jamietre,项目名称:IQObjectMapper,代码行数:17,代码来源:PropertyDictionaryAdapter.cs
示例19: TeamStatDetail
public TeamStatDetail(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:BraveStarr1,项目名称:LegendaryClient,代码行数:4,代码来源:TeamStatDetail.cs
示例20: TeamMemberInfoDTO
public TeamMemberInfoDTO(TypedObject result)
{
base.SetFields(this, result);
}
开发者ID:NitroXenon,项目名称:PVPNetConnect,代码行数:4,代码来源:TeamMemberInfoDTO.cs
注:本文中的TypedObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论