本文整理汇总了C#中TypedObject类的典型用法代码示例。如果您正苦于以下问题:C# TypedObject类的具体用法?C# TypedObject怎么用?C# TypedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypedObject类属于命名空间,在下文中一共展示了TypedObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"));
}
示例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;
}
示例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;
}
示例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"));
}
示例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})));
}
示例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");
}
示例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"]);
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
示例12: Inviter
public Inviter(TypedObject result)
{
base.SetFields(this, result);
}
示例13: SummonerLeaguesDTO
public SummonerLeaguesDTO(TypedObject result)
{
base.SetFields(this, result);
}
示例14: MasteryBookDTO
public MasteryBookDTO(TypedObject result)
{
base.SetFields(this, result);
}
示例15: LoginDataPacket
public LoginDataPacket(TypedObject result)
{
base.SetFields(this, result);
}