Пример #1
0
        public void test_money_with_currency()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("Money.Symbol", "$");
            bag.Add("Money.Currency", "AUD");

            string s = new MoneyWithCurrencyFilter().Run(1.7568, null, bag, null) as string;
            Assert.AreEqual("$1.76 AUD", s);
        }
Пример #2
0
        public void DummyTemplateTest_HtmlCheckedFormatter()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("TrueValue", true);
            bag.Add("FalseValue", false);

            ImpressionEngine ie = ImpressionEngine.Create(bag);

            Assert.AreEqual("checked=\"checked\"", ie.RunString("{{ TrueValue | html_checked }}"));
            Assert.AreEqual("", ie.RunString("{{ FalseValue | html_checked }}"));
        }
Пример #3
0
        public void Copy()
        {
            PropertyBag original = new PropertyBag();
            original.Add("abc", "123");
            original.Add("abc", "456");
            original.Add("def", "");

            PropertyBag copy = original.Copy();

            Assert.AreNotSame(original, copy);
            AssertAreEqual(original, copy);
        }
Пример #4
0
        public void TestIIFWithBag()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("Val1", 1);
            bag.Add("Val2", 2);

            object result = new IFFilter().Run(true, new[] { "Val1", "Val2" }, bag, null);
            Assert.AreEqual(result, 1);

            result = new IFFilter().Run(false, new[] { "Val1", "Val2" }, bag, null);
            Assert.AreEqual(result, 2);
        }
Пример #5
0
 private void LoadMeUp1()
 {
     PropertyBag bag = new PropertyBag();
     bag.Add("One", 1);
     bag.Add("Two", 2);
     bag.Add("Three", 3);
     bag.Add("Four", 4);
     bag.Add("Five", 5);
     string currentFolder = Path.GetDirectoryName(Environment.CurrentDirectory);
     string templatePath = Path.Combine(currentFolder, "../templates/SimpleIfElseIfElseEndIf.htm");
     ImpressionEngine.Create(bag).Run(templatePath);
     count--;
 }
Пример #6
0
        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));
        }
Пример #7
0
 public void Accept()
 {
     var updated = new PropertyBag(Get());
     Admixture.ForEach(kvp => updated.Add(kvp.Key, kvp.Value));
     Changes.ForEach(kvp => updated[kvp.Key] = kvp.Value);
     Leakage.ForEach(kvp => updated.Remove(kvp.Key));
     Set(updated);
 }
Пример #8
0
 public void CanParseVarTags()
 {
     IPropertyBag bag = new PropertyBag();
     bag.Add("list", new [] { "Tom", "Dick", "Harry"});
     ImpressionEngine ie = ImpressionEngine.Create(bag);
     var result = ie.RunString("<!-- #VAR {{ list2 = list }} -->{{list2}}");
     Assert.AreEqual(bag["list"].GetType().ToString(), result);
 }
Пример #9
0
        public void DummyTemplateTest_DefaultFormatter()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("DefaultValue", 1234);

            ImpressionEngine ie = ImpressionEngine.Create(bag);
            string result = ie.RunString("{{ InvalidField | default(DefaultValue) }}");
            Assert.IsNotNull(result);
            Assert.AreEqual("1234", result);
        }
Пример #10
0
        public void SerializeToXml(string expectedXml, string[] keyValuePairs)
        {
            PropertyBag map = new PropertyBag();
            for (int i = 0; i < keyValuePairs.Length; i += 2)
                map.Add(keyValuePairs[i], keyValuePairs[i + 1]);

            StringWriter writer = new StringWriter();
            serializer.Serialize(writer, map);

            Assert.AreEqual(expectedXml, writer.ToString());
        }
Пример #11
0
 public PropertyBag GetQueryParameters()
 {
     var retval = new PropertyBag();
     if (QueryParameters != null)
     {
         foreach (var queryParameter in QueryParameters)
         {
             retval.Add(queryParameter.Key, queryParameter.Value);
         }
     }
     return retval;
 }
Пример #12
0
        public void IsMatchCombinations(bool expectedMatch, string[] values)
        {
            PropertyBag metadata = new PropertyBag();
            foreach (string value in values)
                metadata.Add("key", value);

            ITestDescriptor component = Mocks.StrictMock<ITestDescriptor>();
            SetupResult.For(component.Metadata).Return(metadata);
            Mocks.ReplayAll();

            Assert.AreEqual(expectedMatch, new MetadataFilter<ITestDescriptor>("key",
                new EqualityFilter<string>("expectedValue")).IsMatch(component));
        }
Пример #13
0
        protected void AddElement(Profiles.OrderRelationElement element, PropertyBag bag)
        {
            const string category = "Provision¶©¹º";

            string desc = String.Format("ID := {{{0}}}", element.GetAttribute("Code"));
            PropertySpec item = new PropertySpec(element.GetAttribute("Name"), 0, category, desc);

            item.Key = element.GetAttribute("Code");
            #if false
            item.Attributes = new Attribute[] { ReadOnlyAttribute.Yes };
            #endif

            bag.Add(item);
        }
Пример #14
0
        public void TestHtmlSelectOptions()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("SelectedValue", "Value2");

            SelectListItem[] items = new[] {
                new SelectListItem { Text = "11", Value = "Value1"},
                new SelectListItem { Text = "6", Value = "6"},
                new SelectListItem { Text = "12", Value = "Value3"}
            };

            string optionHtml = new HtmlOptionsFilter().Run(items, new[] { "Text", "Value", "SelectedValue.Length" }, bag, null) as string;

            int i = 0;
        }
Пример #15
0
        public Subscription(InfoServiceProxy swis, string endpointAddress, string query, string binding = "NetTcp", string dataFormat = "Xml", CredentialType credentialType = CredentialType.Certificate, string username = null, string password = null)
        {
            this.swis = swis;

            PropertyBag propertyBag = new PropertyBag
                {
                    {"Query", query}, 
                    {"EndpointAddress", endpointAddress}, 
                    {"Description", "SWQL Studio"}, 
                    {"DataFormat", dataFormat}, 
                    {"CredentialType", credentialType.ToString()}
                };

            if (!string.IsNullOrEmpty(binding))
                propertyBag["Binding"] = binding;

            if (credentialType == CredentialType.Username)
            {
                propertyBag.Add("Username", username);
                propertyBag.Add("Password", password);
            }

            SubscriptionUri = swis.Create(systemSubscription, propertyBag);
        }
Пример #16
0
        /// <summary>
        /// Populates the provided metadata map with asembly-level metadata derived
        /// from custom attributes.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Currently recognized attributes:
        /// <list type="bullet">
        /// <item><see cref="AssemblyCompanyAttribute" /></item>
        /// <item><see cref="AssemblyConfigurationAttribute" /></item>
        /// <item><see cref="AssemblyCopyrightAttribute" /></item>
        /// <item><see cref="AssemblyDescriptionAttribute" /></item>
        /// <item><see cref="AssemblyFileVersionAttribute" /></item>
        /// <item><see cref="AssemblyInformationalVersionAttribute" /></item>
        /// <item><see cref="AssemblyProductAttribute" /></item>
        /// <item><see cref="AssemblyTitleAttribute" /></item>
        /// <item><see cref="AssemblyTrademarkAttribute" /></item>
        /// <item><see cref="AssemblyVersionAttribute" /></item>
        /// </list>
        /// </para>
        /// </remarks>
        /// <param name="assembly">The assembly.</param>
        /// <param name="metadataMap">The metadata map.</param>
        public static void PopulateMetadataFromAssembly(IAssemblyInfo assembly, PropertyBag metadataMap)
        {
            metadataMap.Add(MetadataKeys.CodeBase, assembly.Path);

            AssemblyCompanyAttribute companyAttribute = AttributeUtils.GetAttribute<AssemblyCompanyAttribute>(assembly, false);
            if (companyAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Company, companyAttribute.Company);

            AssemblyConfigurationAttribute configurationAttribute = AttributeUtils.GetAttribute<AssemblyConfigurationAttribute>(assembly, false);
            if (configurationAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Configuration, configurationAttribute.Configuration);

            AssemblyCopyrightAttribute copyrightAttribute = AttributeUtils.GetAttribute<AssemblyCopyrightAttribute>(assembly, false);
            if (copyrightAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Copyright, copyrightAttribute.Copyright);

            AssemblyDescriptionAttribute descriptionAttribute = AttributeUtils.GetAttribute<AssemblyDescriptionAttribute>(assembly, false);
            if (descriptionAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Description, descriptionAttribute.Description);

            AssemblyFileVersionAttribute fileVersionAttribute = AttributeUtils.GetAttribute<AssemblyFileVersionAttribute>(assembly, false);
            if (fileVersionAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.FileVersion, fileVersionAttribute.Version);

            AssemblyInformationalVersionAttribute informationalVersionAttribute = AttributeUtils.GetAttribute<AssemblyInformationalVersionAttribute>(assembly, false);
            if (informationalVersionAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.InformationalVersion, informationalVersionAttribute.InformationalVersion);

            AssemblyProductAttribute productAttribute = AttributeUtils.GetAttribute<AssemblyProductAttribute>(assembly, false);
            if (productAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Product, productAttribute.Product);

            AssemblyTitleAttribute titleAttribute = AttributeUtils.GetAttribute<AssemblyTitleAttribute>(assembly, false);
            if (titleAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Title, titleAttribute.Title);

            AssemblyTrademarkAttribute trademarkAttribute = AttributeUtils.GetAttribute<AssemblyTrademarkAttribute>(assembly, false);
            if (trademarkAttribute != null)
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Trademark, trademarkAttribute.Trademark);

            // Note: AssemblyVersionAttribute cannot be accessed directly via reflection.  It gets baked into the assembly name.
            metadataMap.Add(MetadataKeys.Version, assembly.GetName().Version.ToString());
        }
Пример #17
0
        public ChangeSet Capture()
        {
            if (Leakage != null || Admixture != null || Changes != null)
                throw new NotSupportedException("Cannot call this method twice.");

            NewVersion = Get().AsReadOnly();
            Admixture = new PropertyBag();
            Changes = new PropertyBag();
            Leakage = new PropertyBag();

            foreach(var key in BaseLine.Keys.Union(NewVersion.Keys))
            {
                if (BaseLine.ContainsKey(key) && NewVersion.ContainsKey(key))
                {
                    var bval = BaseLine[key];
                    var cval = NewVersion[key];

                    if (!Equals(bval, cval))
                    {
                        Changes.Add(key, cval);
                    }
                }
                else if (BaseLine.ContainsKey(key) && !NewVersion.ContainsKey(key))
                {
                    Leakage.Add(key, BaseLine[key]);
                }
                else if (!BaseLine.ContainsKey(key) && NewVersion.ContainsKey(key))
                {
                    Admixture.Add(key, NewVersion[key]);
                }
            }

            Admixture = Admixture.AsReadOnly();
            Changes = Changes.AsReadOnly();
            Leakage = Leakage.AsReadOnly();

            return this;
        }
Пример #18
0
        public void ShowCode(String file)
        {
            FileInfo info = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file));

            if (info.Exists &&
                (info.Extension.Equals(".cs") || info.Extension.Equals(".vm") || info.Extension.Equals(".aspx")))
            {
                bool encodeTags = info.Extension.Equals(".vm") || info.Extension.Equals(".aspx");

                StringBuilder sb = new StringBuilder();

                using (FileStream fs = File.OpenRead(info.FullName))
                {
                    StreamReader reader = new StreamReader(fs);
                    String       line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Replace("\t", "    ");
                        if (encodeTags)
                        {
                            line = line.Replace("<", "&lt;");
                            line = line.Replace(">", "&gt;");
                        }
                        sb.Append(line);
                        sb.Append("\r\n");
                    }
                }

                PropertyBag.Add("file", info.FullName);
                PropertyBag.Add("code", sb.ToString());
            }
            else
            {
                RenderText(String.Format("Source file {0} not found", info.Name));
            }
        }
Пример #19
0
        public void PropertyBag_MultiEngine_Property()
        {
            var outerBag = new PropertyBag();

            engine.AddHostObject("bag", outerBag);

            var    innerBag  = new PropertyBag();
            Action innerTest = () =>
            {
                // The Visual Studio 2013 debugging stack fails to release the engine properly,
                // resulting in test failure. Visual Studio 2012 does not have this bug.

                using (var scriptEngine = new VBScriptEngine())
                {
                    scriptEngine.AddHostObject("bag", outerBag);
                    outerBag.Add("innerBag", innerBag);
                    Assert.AreEqual(2, innerBag.EngineCount);
                }
            };

            innerTest();
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            Assert.AreEqual(1, innerBag.EngineCount);
        }
Пример #20
0
        public PropertyBag GetGeoblockConfiguration()
        {
            GeoblockConfigurationSection config = (GeoblockConfigurationSection)ManagementUnit.Configuration.GetSection(GeoblockConfigurationSection.SectionName, typeof(GeoblockConfigurationSection));

            PropertyBag result = new PropertyBag();

            result.Add(0, config.Enabled);
            result.Add(1, config.DenyAction);
            result.Add(2, config.GeoIpFilepath);
            result.Add(3, config.VerifyAll);
            result.Add(4, config.AllowedMode);


            ArrayList countries = new ArrayList();

            foreach (CountryConfigurationElement country in config.SelectedCountryCodes)
            {
                PropertyBag item = new PropertyBag();
                item.Add(0, country.Code);
                countries.Add(item);
            }
            result.Add(5, countries);

            ArrayList exceptionRules = new ArrayList();

            foreach (ExceptionRuleConfigurationElement exceptionRule in config.ExceptionRules)
            {
                PropertyBag item = new PropertyBag();
                item.Add(0, exceptionRule.AllowedMode);
                item.Add(1, exceptionRule.IpAddress);
                item.Add(2, exceptionRule.Mask);
                exceptionRules.Add(item);
            }
            result.Add(6, exceptionRules);

            return(result);
        }
Пример #21
0
 public void NewEntry()
 {
     PropertyBag.Add("entries", _blogService.ObtainPosts(ObtainCurrentBlog()));
 }
		/// <summary>
		/// Loads the <see cref="FormState"/> of a particular <paramref name="form"/> from the <paramref name="context"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionWebContext"/>.</param>
		/// <param name="form">The <see cref="Form"/> for which to load the state.</param>
		/// <returns>Returns the loaded <see cref="FormState"/>.</returns>
		protected override FormState DoLoadState(IMansionWebContext context, Form form)
		{
			// get the GET and POST propertybags
			var getProperties = context.Stack.Peek<IPropertyBag>("Get");
			var postProperties = context.Stack.Peek<IPropertyBag>("Post");
			var fieldProperties = new PropertyBag();
			var formProperties = new PropertyBag();
			var action = string.Empty;

			// if the form has more than one step, try to load the state
			var stateLossDetected = false;
			if (form.Steps.Count > 1)
			{
				// try to load the state
				string stateString;
				var stateKey = form.Prefix + "state";
				if (!postProperties.TryGet(context, stateKey, out stateString) || string.IsNullOrEmpty(stateString))
					stateString = getProperties.Get<string>(context, stateKey, null);

				// dehydrate the field properties, if there is state
				if (!string.IsNullOrEmpty(stateString))
				{
					// dehydrate the field properties
					var dehydratedFieldProperties = context.Nucleus.ResolveSingle<IConversionService>().Convert<IPropertyBag>(context, stateString);

					// merge them with the current properties
					fieldProperties.Merge(dehydratedFieldProperties);
				}
				else
					stateLossDetected = true;
			}

			// load the properties from the data source
			foreach (var candidate in postProperties.Where(candidate => candidate.Key.StartsWith(form.Prefix, StringComparison.OrdinalIgnoreCase)))
			{
				// check for field property
				if (candidate.Key.StartsWith(form.FieldPrefix, StringComparison.OrdinalIgnoreCase))
					fieldProperties.Add(candidate.Key.Substring(form.FieldPrefix.Length), candidate.Value);
					// check for action property
				else if (candidate.Key.StartsWith(form.ActionPrefix, StringComparison.OrdinalIgnoreCase))
					action = candidate.Value.ToString();
				else
					formProperties.Add(candidate.Key.Substring(form.Prefix.Length), candidate.Value);
			}

			// determine the current step
			var currentStepId = formProperties.Get(context, "current-step", getProperties.Get(context, form.Prefix + "current-step", 0));
			var currentStep = form.Steps.ElementAtOrDefault(currentStepId) ?? form.Steps.First();

			// always go to the first step on multi step forms when the state has been lost
			if (form.Steps.Count > 1 && stateLossDetected)
				currentStep = form.Steps.First();

			// determine the next set
			var nextStep = form.Steps.ElementAtOrDefault(currentStepId + 1) ?? form.Steps.Last();

			// create the state
			return new FormState {
				FieldProperties = fieldProperties,
				FormInstanceProperties = formProperties,
				DataSource = dataSource,
				CurrentAction = action,
				IsPostback = !string.IsNullOrEmpty(action) || formProperties.Count > 0,
				CurrentStep = currentStep,
				NextStep = nextStep
			};
		}
Пример #23
0
		public void Details(int productid)
		{
			PropertyBag.Add("product", productService.Find(productid));
		}
Пример #24
0
 public void Bag2()
 {
     PropertyBag.Add("CustomerName", "hammett");
     PropertyBag.Add("List", new String[] { "1", "2", "3" });
 }
Пример #25
0
        public void ExportImport(string projectSlug)
        {
            var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug);

            PropertyBag.Add("project", project);
        }
Пример #26
0
 public void Index()
 {
     PropertyBag.Add("model", new TestModel());
 }
        public new InformationServiceDataReader ExecuteReader(CommandBehavior behavior)
        {
            //TODO: Check if the statement contains a RETURN clause
            string query = statement + " RETURN XML RAW";

            var bag = new PropertyBag();

            foreach (InformationServiceParameter parameter in Parameters)
            {
                bag.Add(parameter.ParameterName, parameter.Value);
            }

            QueryXmlRequest queryRequest = new QueryXmlRequest(query, bag);

            Message message = null;

            var swisSettingsContext = SwisSettingsContext.Current;

            if (swisSettingsContext != null)
            {
                var originalContextApplicationTag = swisSettingsContext.ApplicationTag;
                swisSettingsContext.AppendErrors = true; // we always want to add errors

                // only set its value if the ApplicationTag is not set.
                // If it is set in SwisSettingsContext, just use it
                if (string.IsNullOrEmpty(swisSettingsContext.ApplicationTag))
                {
                    swisSettingsContext.ApplicationTag = ApplicationTag;
                }

                try
                {
                    // SwisSettingsContext.ApplicationTag is sent in request to SWIS server
                    message = Query(queryRequest);
                }
                finally
                {
                    // make sure we don't change the value by calling this function
                    swisSettingsContext.ApplicationTag = originalContextApplicationTag;
                }
            }
            else
            {
                using (new SwisSettingsContext
                {
                    DataProviderTimeout = TimeSpan.FromSeconds(CommandTimeout),
                    ApplicationTag = ApplicationTag,
                    AppendErrors = true
                })
                {
                    message = Query(queryRequest);
                }
            }

            if (message != null)
            {
                if (message.IsFault)
                {
                    CreateFaultException(message);
                }

                return(new InformationServiceDataReader(this, message.GetReaderAtBodyContents(), DateTimeMode));
            }
            return(null);
        }
Пример #28
0
 public void MyDeclaredHelpers()
 {
     PropertyBag.Add("date", new DateTime(1979, 7, 16));
 }
Пример #29
0
 public void InheritedHelpers()
 {
     PropertyBag.Add("date", new DateTime(1979, 7, 16));
 }
Пример #30
0
 public PropertyAttribute(string propertyName, string propertyValue)
 {
     properties.Add(propertyName, propertyValue);
 }
Пример #31
0
        public void TestShuffle()
        {
            PropertyBag bag = new PropertyBag();
            bag.Add("Values", new[] {
                new SimpleObject {Age = 1, Name = "One"},
                new SimpleObject {Age = 2, Name = "Two"},
                new SimpleObject {Age = 3, Name = "Three"},
                new SimpleObject {Age = 4, Name = "Four"},
                new SimpleObject {Age = 5, Name = "Five"}
            });

            string result = ImpressionEngine.Create(bag).RunString("<!-- #FOREACH {{ x in Values | shuffle }} -->{{x.Name}}<!-- #NEXT -->");
            Assert.AreNotEqual("OneTwoThreeFourFive", result);
            string result2 = ImpressionEngine.Create(bag).RunString("<!-- #FOREACH {{ x in Values | shuffle }} -->{{x.Name}}<!-- #NEXT -->");
            Assert.AreNotEqual(result,result2);
        }
Пример #32
0
 public void Index()
 {
     PropertyBag.Add("hiraganaCounter", counterService.GetCounter("hiragana"));
     PropertyBag.Add("katakanaCounter", counterService.GetCounter("katakana"));
 }
Пример #33
0
 public void AccountSettings()
 {
     PropertyBag.Add("author", ObtainCurrentAuthor());
 }
 public void RemoveConfirm([ARFetch("id", false, true)] PersonUser user)
 {
     PropertyBag.Add("user", user);
 }
Пример #35
0
        /// <summary>
        /// Populates the provided metadata map with asembly-level metadata derived
        /// from custom attributes.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Currently recognized attributes:
        /// <list type="bullet">
        /// <item><see cref="AssemblyCompanyAttribute" /></item>
        /// <item><see cref="AssemblyConfigurationAttribute" /></item>
        /// <item><see cref="AssemblyCopyrightAttribute" /></item>
        /// <item><see cref="AssemblyDescriptionAttribute" /></item>
        /// <item><see cref="AssemblyFileVersionAttribute" /></item>
        /// <item><see cref="AssemblyInformationalVersionAttribute" /></item>
        /// <item><see cref="AssemblyProductAttribute" /></item>
        /// <item><see cref="AssemblyTitleAttribute" /></item>
        /// <item><see cref="AssemblyTrademarkAttribute" /></item>
        /// <item><see cref="AssemblyVersionAttribute" /></item>
        /// </list>
        /// </para>
        /// </remarks>
        /// <param name="assembly">The assembly.</param>
        /// <param name="metadataMap">The metadata map.</param>
        public static void PopulateMetadataFromAssembly(IAssemblyInfo assembly, PropertyBag metadataMap)
        {
            metadataMap.Add(MetadataKeys.CodeBase, assembly.Path);

            AssemblyCompanyAttribute companyAttribute = AttributeUtils.GetAttribute <AssemblyCompanyAttribute>(assembly, false);

            if (companyAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Company, companyAttribute.Company);
            }

            AssemblyConfigurationAttribute configurationAttribute = AttributeUtils.GetAttribute <AssemblyConfigurationAttribute>(assembly, false);

            if (configurationAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Configuration, configurationAttribute.Configuration);
            }

            AssemblyCopyrightAttribute copyrightAttribute = AttributeUtils.GetAttribute <AssemblyCopyrightAttribute>(assembly, false);

            if (copyrightAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Copyright, copyrightAttribute.Copyright);
            }

            AssemblyDescriptionAttribute descriptionAttribute = AttributeUtils.GetAttribute <AssemblyDescriptionAttribute>(assembly, false);

            if (descriptionAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Description, descriptionAttribute.Description);
            }

            AssemblyFileVersionAttribute fileVersionAttribute = AttributeUtils.GetAttribute <AssemblyFileVersionAttribute>(assembly, false);

            if (fileVersionAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.FileVersion, fileVersionAttribute.Version);
            }

            AssemblyInformationalVersionAttribute informationalVersionAttribute = AttributeUtils.GetAttribute <AssemblyInformationalVersionAttribute>(assembly, false);

            if (informationalVersionAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.InformationalVersion, informationalVersionAttribute.InformationalVersion);
            }

            AssemblyProductAttribute productAttribute = AttributeUtils.GetAttribute <AssemblyProductAttribute>(assembly, false);

            if (productAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Product, productAttribute.Product);
            }

            AssemblyTitleAttribute titleAttribute = AttributeUtils.GetAttribute <AssemblyTitleAttribute>(assembly, false);

            if (titleAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Title, titleAttribute.Title);
            }

            AssemblyTrademarkAttribute trademarkAttribute = AttributeUtils.GetAttribute <AssemblyTrademarkAttribute>(assembly, false);

            if (trademarkAttribute != null)
            {
                AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Trademark, trademarkAttribute.Trademark);
            }

            // Note: AssemblyVersionAttribute cannot be accessed directly via reflection.  It gets baked into the assembly name.
            metadataMap.Add(MetadataKeys.Version, assembly.GetName().Version.ToString());
        }
Пример #36
0
 internal SpecialFoldersSettings(DefaultSettings defaultSettings, PropertyChangedEventHandler eventHandler = null) : base(defaultSettings, eventHandler)
 {
     DontFireEvents = true;
     PropertyBag.Add("Visible", DefaultBoolean.False);
     DontFireEvents = false;
 }
Пример #37
0
        public void SerializationToXml()
        {
            var bag = new PropertyBag<string>();

            bag.Add("Value1", "asldkjalsk dalksdj");
            bag.Add("Value2", "bbasdasdklajsdalksdja");

            string xml = null;
            SerializationUtils.SerializeObject(bag, out xml);
            Console.WriteLine(xml);

            var bag2 = SerializationUtils.DeSerializeObject(xml, typeof(PropertyBag<string>)) as PropertyBag<string>;

            Assert.IsNotNull(bag2);
            Assert.IsNotNull(bag["Value2"] as string);
            Console.WriteLine(bag["Value1"] as string);
        }
Пример #38
0
 public void Index()
 {
     ProjectStatus[] status = CruiseManager.GetProjectStatus();
     PropertyBag.Add("status", status);
 }
 public void Edit([ARFetch("id", false, true)] PersonUser user)
 {
     PropertyBag.Add("user", user);
 }
Пример #40
0
        public void View(String name)
        {
            String[] names = CruiseManager.GetMostRecentBuildNames(name, 5);

            PropertyBag.Add("names", names);
        }
        /// <summary>
        /// Retrieves a set of roles nodes by <paramref name="roleGuids"/>.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="roleGuids"></param>
        /// <param name="repository"></param>
        /// <returns></returns>
        private Nodeset RetrieveRoleNodes(IMansionContext context, List<string> roleGuids, IRepository repository)
        {
            var queryProperties = new PropertyBag
            {
                {"baseType", "Role"},
                {"bypassAuthorization", true},
                {StorageOnlyQueryComponent.PropertyKey, true}
            };

            if (roleGuids.Count == 0)
                queryProperties.Add("name", "Visitor");
            else
                queryProperties.Add("guid", string.Join(",", roleGuids));

            return repository.RetrieveNodeset(context, queryProperties);
        }
Пример #42
0
        public void ViewSummary(String name, String log)
        {
            PropertyBag.Add("summary", contentTransformation.GetSummary(name, log));

            RenderView("partial_summary");
        }
Пример #43
0
        public void Index(string projectSlug, string query)
        {
            query = query ?? string.Empty;

            var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug);

            var matches = Regex.Matches(query, @"[a-zA-Z0-9_]+:(([a-zA-Z0-9_,.]+)|('[a-zA-Z0-9_,. ]+'))");

            var allSorts = new Dictionary <string, string>()
            {
                { "CreatedBy", "Aanmelder" },
                { "CreatedAt", "Aanmaakdatum" },
                { "PickedUpBy", "Behandelaar" },
                { "PickedUpAt", "Behandeldatum" },
                { "Number", "Nummer" },
                { "Name", "Naam" },
                { "TotalHours", "Inspanning" },
                { "Comments.Count", "Aantal reacties" }
            };

            IList <string>             selectedLabels    = new List <string>();
            IList <string>             notSelectedLabels = new List <string>();
            IList <IssueState>         states            = new List <IssueState>();
            IList <long>               ids               = new List <long>();
            IList <string>             involveds         = new List <string>();
            IList <string>             openedbys         = new List <string>();
            IList <string>             closedbys         = new List <string>();
            IList <string>             pickupbys         = new List <string>();
            IList <User>               selectedPickupbys = new List <User>();
            IDictionary <string, bool> querySorts        = new Dictionary <string, bool>();
            IDictionary <string, bool> linqSorts         = new Dictionary <string, bool>();
            IDictionary <string, bool> selectedSorts     = new Dictionary <string, bool>();
            var  searchQuery = query;
            bool pickupany   = false;
            bool pickupnone  = false;

            foreach (Match match in matches)
            {
                var parts = match.Value.Split(':');
                var value = parts[1].Replace("'", "");
                searchQuery = searchQuery.Replace(match.Value, "");
                switch (parts[0])
                {
                case "label":
                    selectedLabels.Add(value);
                    break;

                case "notlabel":
                    notSelectedLabels.Add(value);
                    break;

                case "state":
                    states.Add((IssueState)Enum.Parse(typeof(IssueState), value));
                    break;

                case "id":
                    ids = value.Split(',').Select(long.Parse).ToList();
                    break;

                case "involved":
                    involveds.Add(value == "me" ? CurrentUser.Name : value);
                    break;

                case "opened":
                    openedbys.Add(value == "me" ? CurrentUser.Name : value);
                    break;

                case "closed":
                    closedbys.Add(value == "me" ? CurrentUser.Name : value);
                    break;

                case "pickup":
                    if (value == "any")
                    {
                        pickupany = true;
                        break;
                    }
                    if (value == "none")
                    {
                        pickupnone = true;
                        break;
                    }
                    pickupbys.Add(value == "me" ? CurrentUser.Name : value);
                    break;

                case "sort":
                    selectedSorts.Add(value, false);
                    if (NHibernateMetadataHelper.IsMapped <Issue>(sessionFactory, value))
                    {
                        querySorts.Add(value, false);
                    }
                    else
                    {
                        linqSorts.Add(value, false);
                    }
                    break;

                case "sortdesc":
                    selectedSorts.Add(value, true);
                    if (NHibernateMetadataHelper.IsMapped <Issue>(sessionFactory, value))
                    {
                        querySorts.Add(value, true);
                    }
                    else
                    {
                        linqSorts.Add(value, true);
                    }
                    break;
                }
            }


            var itemsQuery =
                session.Query <Issue>().Where(
                    x =>
                    x.Project == project &&
                    x.Labels.Count(l => selectedLabels.Contains(l.Name)) == selectedLabels.Count &&
                    !x.Labels.Any(l => notSelectedLabels.Contains(l.Name)));

            if (!string.IsNullOrWhiteSpace(searchQuery))
            {
                var searchQueryParts = searchQuery.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x));
                foreach (var searchQueryPart in searchQueryParts)
                {
                    var trimmedSearchQueryPart = searchQueryPart.Trim();
                    itemsQuery = itemsQuery.Where(x => x.Name.Contains(trimmedSearchQueryPart) || x.Body.Contains(trimmedSearchQueryPart));
                }
            }

            if (ids.Any())
            {
                itemsQuery = itemsQuery.Where(x => ids.Contains(x.Number));
            }

            foreach (var involved in involveds)
            {
                itemsQuery =
                    itemsQuery.Where(
                        x =>
                        x.Comments.Any(a => a.User != null && (a.User.Name == involved || a.User.FullName == involved)) ||
                        x.ChangeStates.Any(a => a.User != null && (a.User.Name == involved || a.User.FullName == involved)) ||
                        x.Changes.Any(a => a.User != null && (a.User.Name == involved || a.User.FullName == involved)));
            }

            foreach (var openedby in openedbys)
            {
                itemsQuery = itemsQuery.Where(
                    x => x.ChangeStates.Any(
                        a => a.IssueState == IssueState.Open && a.User != null &&
                        (a.User.Name == openedby || a.User.FullName == openedby)));
            }

            foreach (var closedby in closedbys)
            {
                itemsQuery = itemsQuery.Where(
                    x => x.ChangeStates.Any(
                        a => a.IssueState == IssueState.Closed && a.User != null &&
                        (a.User.Name == closedby || a.User.FullName == closedby)));
            }

            foreach (var pickupby in pickupbys)
            {
                selectedPickupbys.Add(session.Query <User>().FirstOrDefault(x => x.Name == pickupby || x.FullName == pickupby));
            }

            if (pickupany)
            {
                itemsQuery = itemsQuery.Where(x => x.Pickups.Any());
            }

            if (pickupnone)
            {
                itemsQuery = itemsQuery.Where(x => x.Pickups.Count == 0);
            }

            if (pickupbys.Any())
            {
                itemsQuery = itemsQuery.Where(
                    x => x.Pickups.Any(
                        a => a.User != null && pickupbys.Contains(a.User.Name) || pickupbys.Contains(a.User.FullName)));
            }

            if (querySorts.Count > 0)
            {
                foreach (var sort in querySorts)
                {
                    itemsQuery = itemsQuery.OrderByProperty(sort.Key, sort.Value);
                }
            }

            var items = itemsQuery.ToList();

            if (linqSorts.Count > 0)
            {
                foreach (var sort in linqSorts)
                {
                    items = items.OrderByProperty(sort.Key, sort.Value).ToList();
                }
            }
            var prioritizable = false;

            if (querySorts.Count == 0 && linqSorts.Count == 0)
            {
                prioritizable = true;
                items         = items.OrderBy(x => x.State).ThenBy(x => x.Pickups.Count == 0).ThenBy(x => x.PrioOrder == 0).ThenBy(x => x.PrioOrder).ThenByDescending(x => x.ChangeStates.Max(cs => cs.CreatedAt)).ToList();
            }

            // TODO: dit moet eigenlijk verder naar boven in de query
            //if (states.Any())
            //{
            //    itemsQuery = itemsQuery.Where(x => states.Contains(x.ChangeStates.Single().IssueState));
            //}
            if (states.Any())
            {
                items = items.Where(x => states.Contains(x.State)).ToList();
            }

            var filterPresets       = session.Query <FilterPreset>().Where(x => x.User == CurrentUser && (x.Project == null || x.Project.Id == project.Id)).ToList();
            var globalFilterPresets = session.Query <FilterPreset>().Where(x => x.User == null && (x.Project == null || x.Project.Id == project.Id)).ToList();

            PropertyBag.Add("items", items.ToList());
            PropertyBag.Add("project", project);
            PropertyBag.Add("selectedLabels", selectedLabels);
            PropertyBag.Add("notSelectedLabels", notSelectedLabels);
            PropertyBag.Add("labels", CurrentUser.IsAdmin ? project.Labels : project.Labels.Where(l => l.VisibleForCustomer).ToList());
            PropertyBag.Add("customerLabels", CurrentUser.IsAdmin ? project.Labels : project.Labels.Where(l => l.ApplicableByCustomer).ToList());
            PropertyBag.Add("states", states);
            PropertyBag.Add("query", query);
            PropertyBag.Add("filterPresets", filterPresets);
            PropertyBag.Add("globalFilterPresets", globalFilterPresets);
            PropertyBag.Add("selectedSorts", selectedSorts);
            PropertyBag.Add("allSorts", allSorts);
            PropertyBag.Add("allAdmins", session.Query <User>().Where(x => x.IsAdmin).ToList());
            PropertyBag.Add("selectedPickupbys", selectedPickupbys);
            PropertyBag.Add("pickupany", pickupany);
            PropertyBag.Add("pickupnone", pickupnone);
            PropertyBag.Add("prioritizable", prioritizable);
        }
Пример #44
0
 /// <summary>
 /// Returns a list of property/values of the machine taken at the time this class was created.  Used most frequently in logging scenarios
 /// </summary>
 /// <returns></returns>
 public PropertyBag ToList()
 {
     var retList = new PropertyBag();
     retList.Add("HostName", this.HostName);
     retList.Add("AppDomainName", this.AppDomainName);
     retList.Add("ProcessId", this.ProcessId);
     retList.Add("ProcessName", this.ProcessName);
     retList.Add("ManagedThreadName", this.ManagedThreadName);
     retList.Add("Win32ThreadId", this.Win32ThreadId);
     retList.Add("ClassName", this.ClassName);
     retList.Add("MethodName", this.MethodName);
     retList.Add("StackTrace", StackTrace);
     return retList;
 }
Пример #45
0
        private Stream genericReportSetting(ReportDocument report, HttpContext httpctx)
        {
            PropertyBag connectionAttributes = new PropertyBag();

            connectionAttributes.Add("Auto Translate", "-1");
            connectionAttributes.Add("Connect Timeout", "15");
            connectionAttributes.Add("Data Source", ConfigurationManager.AppSettings["Server"]);
            connectionAttributes.Add("General Timeout", "0");
            connectionAttributes.Add("Initial Catalog", ConfigurationManager.AppSettings["Database"]);
            connectionAttributes.Add("Integrated Security", false);
            connectionAttributes.Add("Locale Identifier", "1040");
            connectionAttributes.Add("OLE DB Services", "-5");
            connectionAttributes.Add("Provider", "SQLOLEDB");
            connectionAttributes.Add("Tag with column collation when possible", "0");
            connectionAttributes.Add("Use DSN Default Properties", false);
            connectionAttributes.Add("Use Encryption for Data", "0");

            PropertyBag attributes = new PropertyBag();

            attributes.Add("Database DLL", "crdb_ado.dll");
            attributes.Add("QE_DatabaseName", ConfigurationManager.AppSettings["Database"]);
            attributes.Add("QE_DatabaseType", "OLE DB (ADO)");
            attributes.Add("QE_LogonProperties", connectionAttributes);
            attributes.Add("QE_ServerDescription", httpctx.Server);
            attributes.Add("QESQLDB", true);
            attributes.Add("SSO Enabled", false);

            CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo ci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
            ci.Attributes = attributes;
            ci.Kind       = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
            ci.UserName   = ConfigurationManager.AppSettings["UserID"];
            ci.Password   = ConfigurationManager.AppSettings["Password"];

            foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in report.ReportClientDocument.DatabaseController.Database.Tables)
            {
                CrystalDecisions.ReportAppServer.DataDefModel.Procedure newTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();

                newTable.ConnectionInfo = ci;
                newTable.Name           = table.Name;
                newTable.Alias          = table.Alias;
                newTable.QualifiedName  = ConfigurationManager.AppSettings["Database"] + ".dbo." + table.Name;
                report.ReportClientDocument.DatabaseController.SetTableLocation(table, newTable);
            }


            Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);

            report.Dispose();
            return(stream);
        }
Пример #46
0
 public void PropertyBag_IScriptableObject_OnModify()
 {
     var bag = new PropertyBag();
     engine.AddHostObject("bag", bag);
     var host = new HostFunctions();
     bag.Add("host", host);
     Assert.AreSame(engine, host.GetEngine());
 }
Пример #47
0
		public void List()
		{
			AddCategoriesToPropertyBag();

			PropertyBag.Add("products", productService.FindAll());
		}
Пример #48
0
        public void PropertyBag_MultiEngine_Property()
        {
            var outerBag = new PropertyBag();
            engine.AddHostObject("bag", outerBag);

            var innerBag = new PropertyBag();
            Action innerTest = () =>
            {
                // The Visual Studio 2013 debugging stack fails to release the engine properly,
                // resulting in test failure. Visual Studio 2012 does not have this bug.

                using (var scriptEngine = new VBScriptEngine())
                {
                    scriptEngine.AddHostObject("bag", outerBag);
                    outerBag.Add("innerBag", innerBag);
                    Assert.AreEqual(2, innerBag.EngineCount);
                }
            };

            innerTest();
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            Assert.AreEqual(1, innerBag.EngineCount);
        }
Пример #49
0
		private void AddCategoriesToPropertyBag()
		{
			PropertyBag.Add("categories", categoryService.ObtainCategories());
		}
Пример #50
0
        public void JavaScriptSerializerTest()
        {
            var bag = new PropertyBag();      
            /// new Dictionary<string, object>();

            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 });


            var json = JsonConvert.SerializeObject(bag);


            JavaScriptSerializer ser = new JavaScriptSerializer();            
            json = ser.Serialize(bag);
            //var json = JsonConvert.SerializeObject(bag);

            Console.WriteLine(json);

            var bag2 = ser.Deserialize<Dictionary<string, object>>(json);
            Assert.IsNotNull(bag2);

            // the following two tests should fail as the types don't match
            Assert.IsNotInstanceOfType(bag2["Key3"], typeof(Guid), "Value isn't a GUID"); // string
            Assert.IsNotInstanceOfType(bag2["Key9"], typeof(ComplexObject), "Value isn't a ComplexObject"); // Dictionary<string,object>
        }
        public new InformationServiceDataReader ExecuteReader(CommandBehavior behavior)
        {
            //TODO: Check if the statement contains a RETURN clause
            string query = statement + " RETURN XML RAW";

            var bag = new PropertyBag();
            foreach (InformationServiceParameter parameter in parameters)
                bag.Add(parameter.ParameterName, parameter.Value);

            QueryXmlRequest queryRequest = new QueryXmlRequest(query, bag);

            Message message = null;

            using (new SwisSettingsContext { DataProviderTimeout = TimeSpan.FromSeconds(commandTimeout), ApplicationTag = ApplicationTag, AppendErrors = true})
            {
                message = this.connection.Service.Query(queryRequest);
            }

            if (message != null)
            {
                if (message.IsFault)
                    CreateFaultException(message);

                return new InformationServiceDataReader(this, message.GetReaderAtBodyContents());
            }
            return null;
        }
Пример #52
0
        public void PropertyBagInContainerTwoWayObjectSerializationTest()
        {
            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 });

            ContainerObject cont = new ContainerObject();
            cont.Name = "Rick";
            cont.Items = bag;


            string xml = SerializationUtils.SerializeObjectToString(cont);

            TestContext.WriteLine(xml);

            ContainerObject cont2 = SerializationUtils.DeSerializeObject(xml,
            typeof(ContainerObject)) as ContainerObject;

            Assert.IsTrue(cont2.Items["key"] as string == "Value");
            Assert.IsTrue(cont2.Items["Key3"].GetType() == typeof(Guid));

            Assert.IsNull(cont2.Items["Key8"]);

            //Assert.IsNull(bag["Key10"]);

            TestContext.WriteLine(cont.Items["Key3"].ToString());
            TestContext.WriteLine(cont.Items["Key4"].ToString());
        }
Пример #53
0
 public void EditEntry(long entryid)
 {
     PropertyBag.Add("entries", _blogService.ObtainPosts(ObtainCurrentBlog()));
     PropertyBag.Add("post", _blogService.ObtainPost(ObtainCurrentBlog(), entryid));
 }
Пример #54
0
        public void PropertyBagTwoWayValueTypeSerializationTest()
        {
            var bag = new PropertyBag<decimal>();

            bag.Add("key", 10M);
            bag.Add("Key1", 100.10M);
            bag.Add("Key2", 200.10M);
            bag.Add("Key3", 300.10M);
            string xml = bag.ToXml();

            TestContext.WriteLine(bag.ToXml());

            bag.Clear();

            bag.FromXml(xml);

            Assert.IsTrue(bag["Key1"] == 100.10M);
            Assert.IsTrue(bag["Key3"] == 300.10M);
        }
Пример #55
0
 public void BlogSettings()
 {
     PropertyBag.Add("blog", ObtainCurrentBlog());
 }
Пример #56
0
        public void SerializationToJson()
        {
            var bag = new PropertyBag<string>();

            bag.Add("Value1", "asldkjalsk dalksdj");
            bag.Add("Value2", "bbasdasdklajsdalksdja");

            string json = JsonConvert.SerializeObject(bag,Formatting.Indented);
            Console.WriteLine(json);

            var bag2 = JsonConvert.DeserializeObject(json, typeof(PropertyBag<string>)) as PropertyBag<string>;

            Assert.IsNotNull(bag2);
            Assert.IsNotNull(bag["Value2"] as string);
            Console.WriteLine(bag["Value1"] as string);            
        }
Пример #57
0
        public void ViewSpecific(String name, String log, DetailEnum detail)
        {
            PropertyBag.Add("summary", contentTransformation.GetDetail(name, log, detail));

            RenderView("partial_summary");
        }
        public void List()
        {
            Product[] products = Product.FindAll();

            PropertyBag.Add("list", PaginationHelper.CreatePagination(products, 10));
        }
Пример #59
0
        public void Index()
        {
            IList list = GetList();

            PropertyBag.Add("users", list);
        }
Пример #60
0
 public void PropertyBag_ExternalModification_AddProperty()
 {
     var bag = new PropertyBag { { "foo", 123 } };
     engine.AddHostObject("bag", bag);
     Assert.AreEqual(123, engine.Evaluate("bag.foo"));
     bag.Add("bar", 456);
     Assert.AreEqual(456, engine.Evaluate("bag.bar"));
 }