/// <inheritdoc /> public void PopulateMetadata(PropertyBag map) { if (map == null) throw new ArgumentNullException("map"); PopulateMetadataImpl(map); }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="propertyBag">The property bag.</param> internal override sealed void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) { MeetingTimeZone meetingTimeZone = new MeetingTimeZone(); meetingTimeZone.LoadFromXml(reader, this.XmlElementName); propertyBag[AppointmentSchema.StartTimeZone] = meetingTimeZone.ToTimeZoneInfo(); }
/// <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); } } }
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(); } } }
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); }
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(); } } } }
public void ReturnsTrueForRegisteredPropertyName() { var propertyBag = new PropertyBag(); propertyBag.SetPropertyValue("MyProperty", 1); Assert.IsTrue(propertyBag.IsPropertyAvailable("MyProperty")); }
public void ReturnsDefaultValueForNonRegisteredProperty() { var propertyBag = new PropertyBag(); Assert.AreEqual(null, propertyBag.GetPropertyValue<string>("StringProperty")); Assert.AreEqual(0, propertyBag.GetPropertyValue<int>("IntProperty")); }
/// <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); } }
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); }
public Template() { Properties = new PropertyBag(); Stats = new StatBag(); Scripts = new List<uint>(); GameObjectType = GOT.None; }
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; }
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); }
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; }
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; }
/// <summary> /// Executes this tag. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> protected override void DoExecute(IMansionContext context) { // get the web context var webContext = context.Cast<IMansionWebContext>(); // check if there is exactly one uploaded file if (webContext.Request.Files.Count != 1) throw new InvalidOperationException(string.Format("There were {0} uploaded files instead of 1", webContext.Request.Files.Count)); // get the uploaded file var uploadedFile = webContext.Request.Files.Values.ToArray()[0]; // store the file var resourcePath = contentResourceService.ParsePath(context, new PropertyBag { {"fileName", uploadedFile.FileName}, {"category", GetAttribute(context, "category", "Uploads")} }); var resource = contentResourceService.GetResource(context, resourcePath); using (var pipe = resource.OpenForWriting()) uploadedFile.InputStream.CopyTo(pipe.RawStream); // set the path to the file as the value of the property var uploadedFilePath = contentResourceService.GetFirstRelativePath(context, resourcePath); // create the properties var uploadedFileProperties = new PropertyBag { {"fileName", Path.GetFileName(uploadedFilePath)}, {"relativePath", uploadedFilePath} }; using (context.Stack.Push(GetRequiredAttribute<string>(context, "target"), uploadedFileProperties, GetAttribute(context, "global", false))) ExecuteChildTags(context); }
/// <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); }
/// <summary> /// Initializes the security for the specified <see cref="IMansionContext"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> public void InitializeSecurityContext(IMansionContext context) { // validate arguments if (context == null) throw new ArgumentNullException("context"); // set users context.SetFrontofficeUserState(InitializeFrontofficeUser(context)); context.SetBackofficeUserState(InitializeBackofficeUser(context)); // push the users to the stack var frontofficeUserProperties = new PropertyBag(context.FrontofficeUserState.Properties) { {"id", context.FrontofficeUserState.Id}, {"isAuthenticated", context.FrontofficeUserState.IsAuthenticated} }; var backofficeUserProperties = new PropertyBag(context.BackofficeUserState.Properties) { {"id", context.BackofficeUserState.Id}, {"isAuthenticated", context.BackofficeUserState.IsAuthenticated} }; context.Stack.Push("FrontofficeUser", frontofficeUserProperties, true).Dispose(); context.Stack.Push("BackofficeUser", backofficeUserProperties, true).Dispose(); context.Stack.Push("User", context.IsBackoffice ? backofficeUserProperties : frontofficeUserProperties, true).Dispose(); }
public NamespaceNode(string @namespace, string text) : base(@namespace, text) { CheckState = System.Windows.Forms.CheckState.Checked; CodeElement = Reflector.WrapNamespace(@namespace); Metadata = new PropertyBag(); }
public void ThrowsArgumentExceptionForInvalidPropertyName() { var propertyBag = new PropertyBag(); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.IsPropertyAvailable(null)); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.IsPropertyAvailable(string.Empty)); }
public PropertyBag GetAppSettings() { var bag = new PropertyBag(); ConfigurationSection section = ManagementUnit.Configuration.GetSection("system.webServer/cosign"); bag[CosignGlobals.ServiceName] = section.GetChildElement("service").GetAttributeValue("name"); bag[CosignGlobals.CertificateCommonName] = section.GetChildElement("crypto").GetAttributeValue("certificateCommonName"); bag[CosignGlobals.CosignServerName] = section.GetChildElement("webloginServer").GetAttributeValue("name"); bag[CosignGlobals.CosignServerUrl] = section.GetChildElement("webloginServer").GetAttributeValue("loginUrl"); bag[CosignGlobals.CosignServerPort] = section.GetChildElement("webloginServer").GetAttributeValue("port"); bag[CosignGlobals.CosignCookieDbPath] = section.GetChildElement("cookieDb").GetAttributeValue("directory"); bag[CosignGlobals.CosignProtected] = section.GetChildElement("protected").GetAttributeValue("status"); bag[CosignGlobals.CosignErrorUrl] = section.GetChildElement("validation").GetAttributeValue("errorRedirectUrl"); bag[CosignGlobals.CosignUrlValidation] = section.GetChildElement("validation").GetAttributeValue("validReference"); bag[CosignGlobals.CosignSiteEntry] = section.GetChildElement("siteEntry").GetAttributeValue("url"); bag[CosignGlobals.CosignCookieTimeout] = section.GetChildElement("cookieDb").GetAttributeValue("expireTime"); bag[CosignGlobals.CosignSecureCookies] = section.GetChildElement("cookies").GetAttributeValue("secure"); bag[CosignGlobals.CosignHttpOnlyCookies] = section.GetChildElement("cookies").GetAttributeValue("httpOnly"); bag[CosignGlobals.CosignKerberosTicketPath] = section.GetChildElement("kerberosTickets").GetAttributeValue("directory"); bag[CosignGlobals.CosignConnectionRetries] = section.GetChildElement("webloginServer").GetAttributeValue("connectionRetries"); var certificateStore = new X509Store(StoreName.My, StoreLocation.LocalMachine); certificateStore.Open(OpenFlags.ReadOnly); X509Certificate2Collection certificateCollection = certificateStore.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, true); var certs = new string[certificateCollection.Count]; int count = 0; foreach (X509Certificate2 x509 in certificateCollection) { certs[count] = x509.GetNameInfo(X509NameType.DnsName, false); count++; } bag[CosignGlobals.CertificateCollection] = certs; return bag; }
public void ThrowsArgumentExceptionForInvalidPropertyName() { var propertyBag = new PropertyBag(); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(null)); ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(string.Empty)); }
public override void Process(Crawler crawler, PropertyBag propertyBag) { AspectF.Define. NotNull(crawler, "crawler"). NotNull(propertyBag, "propertyBag"); if (propertyBag.StatusCode != HttpStatusCode.OK) { return; } if (!IsHtmlContent(propertyBag.ContentType)) { return; } string documentDomHtml = string.Empty; Thread tempThread = new Thread(o => { using (TridentBrowserForm internetExplorer = new TridentBrowserForm(propertyBag.ResponseUri.ToString())) { Application.Run(internetExplorer); documentDomHtml = internetExplorer.DocumentDomHtml; } }); tempThread.SetApartmentState(ApartmentState.STA); tempThread.Start(); tempThread.Join(); propertyBag.GetResponse = () => new MemoryStream(Encoding.UTF8.GetBytes(documentDomHtml)); base.Process(crawler, propertyBag); }
public override void Process(Crawler crawler, PropertyBag propertyBag) { AspectF.Define. NotNull(crawler, "crawler"). NotNull(propertyBag, "propertyBag"); if (propertyBag.StatusCode != HttpStatusCode.OK) { return; } if (!IsHtmlContent(propertyBag.ContentType)) { return; } using (GeckoBrowserForm geckoBrowserForm = new GeckoBrowserForm(XulRunnerPath, propertyBag.ResponseUri.ToString())) { geckoBrowserForm.Show(); while (!geckoBrowserForm.Done) { Application.DoEvents(); } propertyBag.GetResponse = () => new MemoryStream(Encoding.UTF8.GetBytes(geckoBrowserForm.DocumentDomHtml)); base.Process(crawler, propertyBag); } }
public SubRoutine() : base() { Properties = new PropertyBag(); Properties["SubRoutineName"] = new MetaProp("SubRoutineName", typeof(string)); SubRoutineName = ""; }
/// <summary> /// Invokes a procedure and returns it output. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="procedureName">The name of the section which to render.</param> /// <param name="arguments">The arguments of the procedure.</param> /// <returns></returns> public string Evaluate(IMansionContext context, string procedureName, params object[] arguments) { // validate arguments if (context == null) throw new ArgumentNullException("context"); if (string.IsNullOrEmpty(procedureName)) throw new ArgumentNullException("procedureName"); if (arguments == null) throw new ArgumentNullException("arguments"); // get the procedure ScriptTag procedure; if (!context.ProcedureStack.TryPeek(procedureName, out procedure)) throw new InvalidOperationException(string.Format("No procedure found with name '{0}'", procedureName)); // assemble the arguments var procedureArguments = new PropertyBag(); for (var index = 0; index < arguments.Length; ++index) procedureArguments.Set(index.ToString(CultureInfo.InvariantCulture), arguments[index]); // render the control var buffer = new StringBuilder(); using (var pipe = new StringOutputPipe(buffer)) using (context.OutputPipeStack.Push(pipe)) using (context.Stack.Push("Arguments", procedureArguments)) procedure.Execute(context); // make sure the break procedure flag is cleared context.BreakTopMostProcedure = false; // return the buffer return buffer.ToString(); }
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; File.WriteAllBytes(temp.FileName, propertyBag.Response); using (FilterReader filterReader = new FilterReader(temp.FileName)) { string content = filterReader.ReadToEnd(); propertyBag.Text = content.Trim(); } } }
public If() { // ReSharper disable DoNotCallOverridableMethodsInConstructor Properties = new PropertyBag(); Properties["IgnoreCanRun"] = new MetaProp("IgnoreCanRun", typeof (bool), new DisplayNameAttribute( Professionbuddy.Instance.Strings["FlowControl_If_IgnoreCanRun" ])); Properties["Condition"] = new MetaProp("Condition", typeof (string), new EditorAttribute(typeof (MultilineStringEditor), typeof (UITypeEditor)), new DisplayNameAttribute( Professionbuddy.Instance.Strings["FlowControl_If_Condition"])); Properties["CompileError"] = new MetaProp("CompileError", typeof (string), new ReadOnlyAttribute(true), new DisplayNameAttribute( Professionbuddy.Instance.Strings[ "Action_CSharpAction_CompileError"])); CanRunDelegate = c => false; Condition = ""; CompileError = ""; Properties["CompileError"].Show = false; Properties["Condition"].PropertyChanged += Condition_PropertyChanged; Properties["CompileError"].PropertyChanged += CompileErrorPropertyChanged; IgnoreCanRun = true; // ReSharper restore DoNotCallOverridableMethodsInConstructor }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="propertyBag">The property bag.</param> internal override void LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); timeZoneDefinition.LoadFromXml(reader, this.XmlElementName); propertyBag[this] = timeZoneDefinition.ToTimeZoneInfo(reader.Service); }
public void PropertyBagTwoWayObjectSerializationTest() { var bag = new PropertyBag(); bag.Add("key", "Value"); bag.Add("Key2", 100.10M); bag.Add("Key3", Guid.NewGuid()); bag.Add("Key4", DateTime.Now); bag.Add("Key5", true); bag.Add("Key7", new byte[3] { 42, 45, 66 } ); bag.Add("Key8", null); bag.Add("Key9", new ComplexObject() { Name = "Rick", Entered = DateTime.Now, Count = 10 }); string xml = bag.ToXml(); TestContext.WriteLine(bag.ToXml()); bag.Clear(); bag.FromXml(xml); Assert.IsTrue(bag["key"] as string == "Value"); Assert.IsInstanceOfType( bag["Key3"], typeof(Guid)); Assert.IsNull(bag["Key8"]); //Assert.IsNull(bag["Key10"]); Assert.IsInstanceOfType(bag["Key9"], typeof(ComplexObject)); }
public void New() { PropertyBag.Add("pl", new ProductLicense()); }
// Token: 0x06000B2F RID: 2863 RVA: 0x000336E4 File Offset: 0x000318E4 internal DeletedObject(IDirectorySession session, PropertyBag propertyBag) { this.m_Session = session; this.propertyBag = (ADPropertyBag)propertyBag; base.ResetChangeTracking(true); }
public void NewWithAccounts() { PropertyBag.Add("pl", new ProductLicense()); PropertyBag.Add("accounts", Account.FindAll()); }