本文整理汇总了C#中PropertyBag类的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag类的具体用法?C# PropertyBag怎么用?C# PropertyBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyBag类属于命名空间,在下文中一共展示了PropertyBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetElement
protected void ResetElement(PropertyBag bag, XmlElement parent)
{
foreach (XmlElement element in parent.ChildNodes)
{
XmlAttribute attri = element.Attributes["ID"];
if (attri == null) continue;
PropertySpec item = FindElement(bag, attri.Value);
if (item == null) continue;
int value = 0;
attri = element.Attributes["Subscribe"];
if (attri != null) value += Int32.Parse(attri.Value);
attri = element.Attributes["UnSubscribe"];
if (attri != null) value += Int32.Parse(attri.Value);
attri = element.Attributes["Other"];
if (attri != null) value += Int32.Parse(attri.Value);
item.Value = value;
}
PropertyGrid.SelectedObject = bag;
}
示例2: WritePropertyValueToXml
/// <summary>
/// Writes to XML.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="propertyBag">The property bag.</param>
/// <param name="isUpdateOperation">Indicates whether the context is an update operation.</param>
internal override void WritePropertyValueToXml(
EwsServiceXmlWriter writer,
PropertyBag propertyBag,
bool isUpdateOperation)
{
object value = propertyBag[this];
if (value != null)
{
if (writer.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1)
{
ExchangeService service = writer.Service as ExchangeService;
if (service != null && service.Exchange2007CompatibilityMode == false)
{
MeetingTimeZone meetingTimeZone = new MeetingTimeZone((TimeZoneInfo)value);
meetingTimeZone.WriteToXml(writer, XmlElementNames.MeetingTimeZone);
}
}
else
{
base.WritePropertyValueToXml(
writer,
propertyBag,
isUpdateOperation);
}
}
}
示例3: Process
public void Process(Crawler crawler, PropertyBag propertyBag)
{
if (propertyBag.StatusCode != HttpStatusCode.OK)
{
return;
}
string extension = MapContentTypeToExtension(propertyBag.ContentType);
if (extension.IsNullOrEmpty())
{
return;
}
propertyBag.Title = propertyBag.Step.Uri.PathAndQuery;
using (TempFile temp = new TempFile())
{
temp.FileName += "." + extension;
using (FileStream fs = new FileStream(temp.FileName, FileMode.Create, FileAccess.Write, FileShare.Read, 0x1000))
using (Stream input = propertyBag.GetResponse())
{
input.CopyToStream(fs);
}
using (FilterReader filterReader = new FilterReader(temp.FileName))
{
string content = filterReader.ReadToEnd();
propertyBag.Text = content.Trim();
}
}
}
示例4: Process
public void Process(Crawler crawler, PropertyBag propertyBag)
{
string textContent = propertyBag.Text; // Filtered text content
// Here you can send downloaded filtered content to an index, database, filesystem or whatever
Console.Out.WriteLine(textContent);
}
示例5: NodeHttpResponse
public NodeHttpResponse(NodeHttpRequest nodeHttpRequest, Task<HttpResponseMessage> resp)
: base(null)
{
// TODO: Complete member initialization
_nodeHttpRequest = nodeHttpRequest;
_resp = resp;
if (!resp.IsFaulted)
{
statusCode = (int)resp.Result.StatusCode;
headers = new PropertyBag();
foreach (var kvp in resp.Result.Headers)
{
headers[kvp.Key] = kvp.Value.FirstOrDefault();
}
if (resp.Result.Content != null)
{
foreach (var kvp in resp.Result.Content.Headers)
{
headers[kvp.Key] = kvp.Value.FirstOrDefault();
}
}
}
}
示例6: ReturnsTrueForRegisteredPropertyName
public void ReturnsTrueForRegisteredPropertyName()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("MyProperty", 1);
Assert.IsTrue(propertyBag.IsPropertyAvailable("MyProperty"));
}
示例7: ReturnsDefaultValueForNonRegisteredProperty
public void ReturnsDefaultValueForNonRegisteredProperty()
{
var propertyBag = new PropertyBag();
Assert.AreEqual(null, propertyBag.GetPropertyValue<string>("StringProperty"));
Assert.AreEqual(0, propertyBag.GetPropertyValue<int>("IntProperty"));
}
示例8: Prepare
/// <summary>
/// Prepares an insert query.
/// </summary>
/// <param name="context"></param>
/// <param name="connection">The connection.</param>
/// <param name="transaction">The transaction.</param>
/// <param name="sourceNode"></param>
/// <param name="targetParentNode"></param>
/// <returns></returns>
public void Prepare(IMansionContext context, SqlConnection connection, SqlTransaction transaction, Node sourceNode, Node targetParentNode)
{
// validate arguments
if (connection == null)
throw new ArgumentNullException("connection");
if (transaction == null)
throw new ArgumentNullException("transaction");
if (sourceNode == null)
throw new ArgumentNullException("sourceNode");
if (targetParentNode == null)
throw new ArgumentNullException("targetParentNode");
// get the properties of the new node
var newProperties = new PropertyBag(sourceNode);
// if the target pointer is the same as the parent of the source node, generate a new name to distinguish between the two.
if (sourceNode.Pointer.Parent == targetParentNode.Pointer)
{
// get the name of the node
var name = sourceNode.Get<string>(context, "name");
// change the name to indicate the copied node
newProperties.Set("name", name + CopyPostfix);
}
// create an insert query
command = context.Nucleus.CreateInstance<InsertNodeCommand>();
command.Prepare(context, connection, transaction, targetParentNode.Pointer, newProperties);
}
示例9: NamespaceNode
public NamespaceNode(string @namespace, string text)
: base(@namespace, text)
{
CheckState = System.Windows.Forms.CheckState.Checked;
CodeElement = Reflector.WrapNamespace(@namespace);
Metadata = new PropertyBag();
}
示例10: UIItem
public UIItem(String Name, Shape Shape, PropertyBag settings)
{
this.Name = Name;
if (settings != null) Properties.Add(new UIItemProperties(null, settings));
this.Shape = Shape;
Hover = false;
}
示例11: DoExecute
/// <summary>
/// Executes the tag.
/// </summary>
/// <param name="context">The application context.</param>
protected override void DoExecute(IMansionContext context)
{
try
{
ExecuteChildTags(context);
}
catch (ThreadAbortException)
{
// thread is aborted, so don't throw any new exceptions
}
catch (Exception ex)
{
// get the catch tag
CatchTag catchTag;
if (!TryGetAlternativeChildTag(out catchTag))
throw new ScriptTagException(this, ex);
// get the exception details
var exceptionDetails = new PropertyBag
{
{"type", ex.GetType().FullName},
{"message", ex.Message},
{"stacktrace", ex.StackTrace}
};
// push error to the stack
using (context.Stack.Push("Exception", exceptionDetails, false))
catchTag.Execute(context);
}
}
示例12: Template
public Template()
{
Properties = new PropertyBag();
Stats = new StatBag();
Scripts = new List<uint>();
GameObjectType = GOT.None;
}
示例13: Test
private void Test()
{
Game g = new Game();
PropertyBag p = new PropertyBag();
g.Properties = p;
g.Owner = -1;
TurnedGameServerGame tg = new TurnedGameServerGame(g);
string msg ="";
CharacterInfo ci1 = new CharacterInfo();
ci1.ID = 1;
ci1.CharacterName = "Alpha";
ServerCharacterInfo t1 = new ServerCharacterInfo(ci1);
tg.AddPlayer(t1, ref msg);
CharacterInfo ci2 = new CharacterInfo();
ci2.ID = 2;
ci2.CharacterName = "Bravo";
ServerCharacterInfo t2 = new ServerCharacterInfo(ci2);
tg.AddPlayer(t2, ref msg);
CharacterInfo ci3 = new CharacterInfo();
ci3.ID = 3;
ci3.CharacterName = "Charly";
ServerCharacterInfo t3 = new ServerCharacterInfo(ci3);
tg.AddPlayer(t3, ref msg);
string msg2 ="";
tg.StartGame(ref msg2, true);
}
示例14: Process
public async Task<bool> Process(ICrawler crawler, PropertyBag propertyBag)
{
FlurlClient client = propertyBag.Step.Uri.ToString()
.ConfigureHttpClient(httpClient => { });
client.Settings.AfterCall += httpCall =>
{
propertyBag[FlurlHttpCallPropertyName].Value = httpCall;
propertyBag.DownloadTime = httpCall.Duration.GetValueOrDefault();
};
HttpResponseMessage getResult = await client.GetAsync();
propertyBag.CharacterSet = getResult.Content.Headers.ContentType.CharSet;
propertyBag.ContentEncoding = string.Join(";", getResult.Content.Headers.ContentEncoding);
propertyBag.ContentType = getResult.Content.Headers.ContentType.MediaType;
propertyBag.Headers = getResult.Content.Headers.ToDictionary(x => x.Key, x => x.Value);
propertyBag.LastModified = getResult.Headers.Date.GetValueOrDefault(DateTimeOffset.UtcNow).DateTime;
propertyBag.Method = "GET";
//propertyBag.ProtocolVersion = getResult.;
//propertyBag.ResponseUri = getResult.Headers.Server;
propertyBag.Server = string.Join(";", getResult.Headers.Server.Select(x => x.Product.ToString()));
propertyBag.StatusCode = getResult.StatusCode;
propertyBag.StatusDescription = getResult.StatusCode.ToString();
propertyBag.Response = await getResult.Content.ReadAsByteArrayAsync();
return true;
}
示例15: SerializationDoubleRoundtrip
public void SerializationDoubleRoundtrip ()
{
var bag = new PropertyBag ();
var t = new SerializableObject {
SomeValue = "test1"
};
bag.SetValue ("foo", t);
var w = new StringWriter ();
var ser = new XmlDataSerializer (new DataContext ());
ser.Serialize (w, bag);
var data = w.ToString ();
SerializableObject.CreationCount = 0;
bag = ser.Deserialize<PropertyBag> (new StringReader (data));
// SerializableObject is not instantiated if not queried
Assert.AreEqual (0, SerializableObject.CreationCount);
w = new StringWriter ();
ser.Serialize (w, bag);
data = w.ToString ();
bag = ser.Deserialize<PropertyBag> (new StringReader (data));
// SerializableObject is not instantiated if not queried
Assert.AreEqual (0, SerializableObject.CreationCount);
t = bag.GetValue<SerializableObject> ("foo");
Assert.NotNull (t);
Assert.AreEqual ("test1", t.SomeValue);
}