Esempio n. 1
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            bool isValid = ValidateChildren();

            if (!isValid)
            {
                // Prevent closing the dialog if we've not got valid fields.
                // necessary because the name attribute name field starts empty - and hence doesn't get validated by default
                this.DialogResult = DialogResult.None;
                return;
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }

            BasePatch patch;

            if ((AttributePatchTypes)patchTypeCombo.SelectedItem == AttributePatchTypes.Patch)
            {
                patch = new PatchAttribute(elementXPathTextBox.Text, nameTextBox.Text, valueTextBox.Text);
            }
            else
            {
                patch = new SetAttribute(elementXPathTextBox.Text, nameTextBox.Text, valueTextBox.Text);
            }

            Patch = new PatchItem(patch, _treeNode);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a SetAttribute.
        /// </summary>
        /// <param name="values">Values allowed in the set.</param>
        /// <param name="comparer"></param>
        /// <param name="errMsg">Gets or sets an error message to associate with a validation control if validation fails.</param>
        /// <returns></returns>
        public BaValidatorList Set(object[] values, IEqualityComparer comparer, string errMsg = null)
        {
            var att = new SetAttribute(values, comparer);

            if (errMsg != null)
            {
                att.ErrorMessage = errMsg;
            }
            Add(att);
            return(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a SetAttribute.
        /// </summary>
        /// <param name="values">Values allowed in the set.</param>
        /// <param name="ignoreCase"></param>
        /// <param name="errMsg">Gets or sets an error message to associate with a validation control if validation fails.</param>
        /// <returns></returns>
        public BaValidatorList Set(string[] values, bool ignoreCase, string errMsg = null)
        {
            var att = new SetAttribute(values, ignoreCase);

            if (errMsg != null)
            {
                att.ErrorMessage = errMsg;
            }
            Add(att);
            return(this);
        }
Esempio n. 4
0
        private void init()
        {
            TaxCard       card   = TaxCardFactory.CreateTaxCard();
            string        str    = card.get_Corporation();
            string        str2   = card.get_Address();
            string        str3   = card.get_Telephone();
            string        str4   = card.get_BankAccount();
            SetAttribute  method = new SetAttribute(this.OnSetAttribute);
            List <string> list   = new List <string> {
                str,
                str2,
                str3,
                str4
            };

            base.BeginInvoke(method, new object[] { list });
        }
Esempio n. 5
0
        private void setAttribute(Node node, SetAttribute flag)
        {
            switch (node.type)
            {
            case Type.ATK:
                this.TotalATK += node.number * (int)flag;
                break;

            case Type.DEF:
                this.TotalDEF += node.number * (int)flag;
                break;

            case Type.HP:
                this.TotalHP += node.number * (int)flag;
                break;

            case Type.A:
                this.TotalA += node.number * (int)flag;
                break;

            case Type.B:
                this.TotalB += node.number * (int)flag;
                break;

            case Type.C:
                this.TotalC += node.number * (int)flag;
                break;

            case Type.SKL:
                this.Skill = node.description;
                break;

            case Type.ABL:
                this.Abilities.Add(node.description);
                break;

            default:
                return;
            }
        }
Esempio n. 6
0
        public void SetAttribute_PatchGenerator_Accepts_SetAttribute()
        {
            var sa  = new SetAttribute("/sitecore/sites/site[@name='a']", "cheese", "1");
            var xml = XDocument.Parse("<sitecore><sites><site name=\"a\"/></sites></sitecore>");

            var sut = new PatchGenerator(xml);

            var result = sut.GeneratePatchFile(new BasePatch[] { sa });

            var patch = result
                        .Element("configuration")
                        .Element("sitecore")
                        .Element("sites")
                        .Element("site");

            Assert.IsNotNull(patch);

            var attr = patch.Attribute(Namespaces.Set + "cheese");

            Assert.IsNotNull(attr);
            Assert.AreEqual("1", attr.Value);
        }
Esempio n. 7
0
        /// <summary> Write a Set XML Element from attributes in a member. </summary>
        public virtual void WriteSet(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, SetAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "set" );
            // Attribute: <name>
            writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Set_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass));
            // Attribute: <access>
            if(attribute.Access != null)
            writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass));
            // Attribute: <table>
            if(attribute.Table != null)
            writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, mappedClass));
            // Attribute: <schema>
            if(attribute.Schema != null)
            writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, mappedClass));
            // Attribute: <catalog>
            if(attribute.Catalog != null)
            writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, mappedClass));
            // Attribute: <subselect>
            if(attribute.Subselect != null)
            writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, mappedClass));
            // Attribute: <lazy>
            if(attribute.Lazy != CollectionLazy.Unspecified)
            writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(CollectionLazy), attribute.Lazy));
            // Attribute: <inverse>
            if( attribute.InverseSpecified )
            writer.WriteAttributeString("inverse", attribute.Inverse ? "true" : "false");
            // Attribute: <mutable>
            if( attribute.MutableSpecified )
            writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false");
            // Attribute: <cascade>
            if(attribute.Cascade != null)
            writer.WriteAttributeString("cascade", GetAttributeValue(attribute.Cascade, mappedClass));
            // Attribute: <order-by>
            if(attribute.OrderBy != null)
            writer.WriteAttributeString("order-by", GetAttributeValue(attribute.OrderBy, mappedClass));
            // Attribute: <where>
            if(attribute.Where != null)
            writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, mappedClass));
            // Attribute: <batch-size>
            if(attribute.BatchSize != -9223372036854775808)
            writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString());
            // Attribute: <outer-join>
            if(attribute.OuterJoin != OuterJoinStrategy.Unspecified)
            writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(OuterJoinStrategy), attribute.OuterJoin));
            // Attribute: <fetch>
            if(attribute.Fetch != CollectionFetchMode.Unspecified)
            writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(CollectionFetchMode), attribute.Fetch));
            // Attribute: <persister>
            if(attribute.Persister != null)
            writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, mappedClass));
            // Attribute: <collection-type>
            if(attribute.CollectionType != null)
            writer.WriteAttributeString("collection-type", GetAttributeValue(attribute.CollectionType, mappedClass));
            // Attribute: <check>
            if(attribute.Check != null)
            writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, mappedClass));
            // Attribute: <optimistic-lock>
            if( attribute.OptimisticLockSpecified )
            writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false");
            // Attribute: <node>
            if(attribute.Node != null)
            writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass));
            // Attribute: <embed-xml>
            if( attribute.EmbedXmlSpecified )
            writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false");
            // Attribute: <generic>
            if( attribute.GenericSpecified )
            writer.WriteAttributeString("generic", attribute.Generic ? "true" : "false");
            // Attribute: <sort>
            if(attribute.Sort != null)
            writer.WriteAttributeString("sort", GetAttributeValue(attribute.Sort, mappedClass));

            WriteUserDefinedContent(writer, member, null, attribute);

            System.Collections.ArrayList memberAttribs = GetSortedAttributes(member);
            int attribPos; // Find the position of the SetAttribute (its <sub-element>s must be after it)
            for(attribPos=0; attribPos<memberAttribs.Count; attribPos++)
                if( memberAttribs[attribPos] is SetAttribute
                    && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position )
                    break; // found
            int i = attribPos + 1;

            // Element: <meta>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is MetaAttribute )
                        WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute);
            // Element: <subselect>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SubselectAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SubselectAttribute )
                        WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SubselectAttribute), attribute);
            // Element: <cache>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(CacheAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is CacheAttribute )
                        WriteCache(writer, member, memberAttrib as CacheAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(CacheAttribute), attribute);
            // Element: <synchronize>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SynchronizeAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SynchronizeAttribute )
                        WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SynchronizeAttribute), attribute);
            // Element: <comment>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(CommentAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is CommentAttribute )
                        WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(CommentAttribute), attribute);
            // Element: <key>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(KeyAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is KeyAttribute )
                        WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(KeyAttribute), attribute);
            // Element: <element>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ElementAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is ElementAttribute )
                        WriteElement(writer, member, memberAttrib as ElementAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ElementAttribute), attribute);
            // Element: <one-to-many>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(OneToManyAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is OneToManyAttribute )
                        WriteOneToMany(writer, member, memberAttrib as OneToManyAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(OneToManyAttribute), attribute);
            // Element: <many-to-many>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ManyToManyAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is ManyToManyAttribute )
                        WriteManyToMany(writer, member, memberAttrib as ManyToManyAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ManyToManyAttribute), attribute);
            // Element: <composite-element>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(CompositeElementAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is CompositeElementAttribute )
                        WriteCompositeElement(writer, member, memberAttrib as CompositeElementAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(CompositeElementAttribute), attribute);
            // Element: <many-to-any>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ManyToAnyAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is ManyToAnyAttribute )
                        WriteManyToAny(writer, member, memberAttrib as ManyToAnyAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ManyToAnyAttribute), attribute);
            // Element: <loader>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(LoaderAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is LoaderAttribute )
                        WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(LoaderAttribute), attribute);
            // Element: <sql-insert>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SqlInsertAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SqlInsertAttribute )
                        WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SqlInsertAttribute), attribute);
            // Element: <sql-update>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SqlUpdateAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SqlUpdateAttribute )
                        WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SqlUpdateAttribute), attribute);
            // Element: <sql-delete>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SqlDeleteAttribute )
                        WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SqlDeleteAttribute), attribute);
            // Element: <sql-delete-all>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAllAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is SqlDeleteAllAttribute )
                        WriteSqlDeleteAll(writer, member, memberAttrib as SqlDeleteAllAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(SqlDeleteAllAttribute), attribute);
            // Element: <filter>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(FilterAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is SetAttribute )
                        break; // Following attributes are for this Set
                    if( memberAttrib is FilterAttribute )
                        WriteFilter(writer, member, memberAttrib as FilterAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(FilterAttribute), attribute);

            writer.WriteEndElement();
        }
Esempio n. 8
0
 public void SetAttribute_Constructor_NullPath_Throws()
 {
     var sut = new SetAttribute(null, "test", "a");
 }
Esempio n. 9
0
        private void init()
        {
            TaxCard       card          = TaxCardFactory.CreateTaxCard();
            TaxStateInfo  info          = card.get_StateInfo();
            string        str           = (info.IsMainMachine == 1) ? "主开票机" : "分开票机";
            int           machineNumber = info.MachineNumber;
            DateTime      time          = card.get_RepDate();
            DateTime      time2         = card.get_TaxClock();
            double        invLimit      = info.InvLimit;
            int           isInvEmpty    = info.IsInvEmpty;
            int           isRepReached  = info.IsRepReached;
            int           isLockReached = info.IsLockReached;
            int           iCCardNo      = info.ICCardNo;
            int           iCAuthInfo    = info.ICAuthInfo;
            int           iCCapacity    = info.ICCapacity;
            int           iCRetInv      = info.ICRetInv;
            int           iCBuyInv      = info.ICBuyInv;
            int           iCRepDone     = info.ICRepDone;
            int           iCRepInfo     = info.ICRepInfo;
            int           iCInvSegm     = info.ICInvSegm;
            string        str2          = string.Format("{0}.{1:00}", info.MajorVersion, info.MinorVersion);
            string        driverVersion = info.DriverVersion;
            int           lockedDays    = info.LockedDays;
            int           companyType   = info.CompanyType;
            DateTime      time3         = card.get_LastRepDate();
            int           tBCardNo      = info.TBCardNo;
            int           tBAuthInfo    = info.TBAuthInfo;
            int           tBBuyInv      = info.TBBuyInv;
            int           tBCapacity    = info.TBCapacity;
            int           tBRegFlag     = info.TBRegFlag;
            int           tBRepDone     = info.TBRepDone;
            int           tBRepInfo     = info.TBRepInfo;
            int           tBRetInv      = info.TBRetInv;
            int           tBType        = info.TBType;
            int           isTBEnable    = info.IsTBEnable;
            SetAttribute  method        = new SetAttribute(this.OnSetAttribute);
            List <object> list          = new List <object> {
                str,
                machineNumber,
                time,
                time2,
                invLimit,
                isInvEmpty,
                isRepReached,
                isLockReached,
                iCCardNo,
                iCAuthInfo,
                iCCapacity,
                iCRetInv,
                iCBuyInv,
                iCRepDone,
                iCRepInfo,
                iCInvSegm,
                str2,
                driverVersion,
                lockedDays,
                companyType,
                time3,
                tBCardNo,
                tBAuthInfo,
                tBBuyInv,
                tBCapacity,
                tBRegFlag,
                tBRepDone,
                tBRepInfo,
                tBRetInv,
                tBType,
                isTBEnable
            };

            base.BeginInvoke(method, new object[] { list });
        }
Esempio n. 10
0
 public static bool ContainsAll <T>(this SetAttribute <T> source, params string[] values)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 public void SetAttribute_Constructor_EmptyPath_Throws()
 {
     var sut = new SetAttribute(string.Empty, "test", "a");
 }
        private void buttonCreateDemoTemplate_Click(object sender, EventArgs e)
        {
            List <TemplateElement> templateElements = new List <TemplateElement>();


            SwitchWindowVisibility visibility = new SwitchWindowVisibility();

            visibility.NewInstance();
            visibility.Visible.Value = true;
            templateElements.Add(new TemplateElement("show window", visibility));

            //Dont forget to change identifier to real one!
            LoadUrl url = new LoadUrl();

            url.NewInstance();
            url.Url.Value = "http://keepass.info/help/kb/testform.html";
            templateElements.Add(new TemplateElement("Load Site", url));

            BrowserAction actionLoaded = new BrowserAction();
            SiteLoaded    siteLoaded   = new SiteLoaded();

            siteLoaded.NewInstance();
            siteLoaded.ExpectedSiteToLoad.Value         = url.Url;
            siteLoaded.ExpectedSiteToLoad.IsRegex.Value = false;
            actionLoaded.ActionObject = siteLoaded;
            templateElements.Add(new TemplateElement("Check if Site has loaded", actionLoaded));

            BrowserAction checkNumberOfElements1 = new CefBrowserControl.BrowserAction();
            ElementToLoad loadElement            = new ElementToLoad();

            loadElement.NewInstance();
            loadElement.Selector.SelectorExecuteActionOn  = BrowserAction.ExecuteActionOn.Id;
            loadElement.Selector.SelectorString           = "LoginFormUser";
            loadElement.Selector.ExpectedNumberOfElements = new InsecureInt(1);
            checkNumberOfElements1.ActionObject           = loadElement;
            templateElements.Add(new TemplateElement("Check if Form exists", checkNumberOfElements1));


            BrowserAction imageAction = new BrowserAction();
            GetImage      getImage1   = new GetImage();

            getImage1.NewInstance();
            imageAction.ActionObject                   = getImage1;
            getImage1.Selector.SelectorString          = "/html/body/table/tbody/tr[1]/td/table/tbody/tr/td[1]/img";
            getImage1.Selector.SelectorExecuteActionOn = BrowserAction.ExecuteActionOn.Xpath;
            TemplateElement getImageTemplateElement = new TemplateElement("Download KeePass Image", imageAction);

            templateElements.Add(getImageTemplateElement);


            GetInputFromUser input = new GetInputFromUser();

            input.NewInstance();
            input.InputNeeded.Value = true;
            input.InsecureDisplayObjects.Add(new InsecureText("Please type in 'OK'. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."));
            input.InsecureDisplayObjects.Add(new InsecureImage(Template.EncodeTemplateElementIdWithOutputName(getImageTemplateElement.UEID, GetImage.KeyList.Base64String.ToString())));
            TemplateElement templateElement1 = new TemplateElement("Get OK from User", input);

            templateElement1.SuccessConditions.Add(new Condition("Contains", Template.EncodeTemplateElementIdWithOutputName("", GetInputFromUser.KeyList.UserInputResult.ToString()), "OK"));
            templateElements.Add(templateElement1);


            //----------------------------


            BrowserAction checkNumberOfElements2 = new CefBrowserControl.BrowserAction();
            ElementToLoad elementToLoad2         = new ElementToLoad();

            elementToLoad2.NewInstance();
            checkNumberOfElements2.ActionObject                    = elementToLoad2;
            elementToLoad2.Selector.SelectorExecuteActionOn        = BrowserAction.ExecuteActionOn.Name;
            elementToLoad2.Selector.SelectorString                 = "pwd";
            elementToLoad2.Selector.ExpectedNumberOfElements.Value = 1;
            templateElements.Add(new TemplateElement("Check if Form Field 'pwd' exists", checkNumberOfElements2));

            BrowserAction checkNumberOfElements3 = new CefBrowserControl.BrowserAction();
            ElementToLoad elementToLoad3         = new ElementToLoad();

            elementToLoad3.NewInstance();
            checkNumberOfElements3.ActionObject                    = elementToLoad3;
            elementToLoad3.Selector.SelectorExecuteActionOn        = BrowserAction.ExecuteActionOn.Name;
            elementToLoad3.Selector.SelectorString                 = "LoginForm";
            elementToLoad3.Selector.ExpectedNumberOfElements.Value = 1;
            templateElements.Add(new TemplateElement("Check if Form Field 'LoginForm' exists", checkNumberOfElements3));

            BrowserAction enteryUserName       = new BrowserAction();
            SetAttribute  setAttributeUserName = new SetAttribute();

            setAttributeUserName.NewInstance();
            enteryUserName.ActionObject = setAttributeUserName;
            setAttributeUserName.AttributeName.Value = "Value";
            setAttributeUserName.ValueToSet.Value    = BaseObject.ConvertStringToPlaceholderString(PwDefs.UserNameField);
            setAttributeUserName.Selector.ExpectedNumberOfElements.Value = 1;
            setAttributeUserName.Selector.SelectorExecuteActionOn        = BrowserAction.ExecuteActionOn.Id;
            setAttributeUserName.Selector.SelectorString = "LoginFormUser";
            templateElements.Add(new TemplateElement("enter username", enteryUserName));

            BrowserAction enterPassword        = new BrowserAction();
            SetAttribute  setAttributePassword = new SetAttribute();

            setAttributePassword.NewInstance();
            enterPassword.ActionObject = setAttributePassword;
            setAttributePassword.AttributeName.Value = "Value";
            setAttributePassword.ValueToSet.Value    = BaseObject.ConvertStringToPlaceholderString(PwDefs.PasswordField) + " " + BaseObject.ConvertStringToPlaceholderString("");
            setAttributePassword.Selector.ExpectedNumberOfElements.Value = 1;
            setAttributePassword.Selector.SelectorExecuteActionOn        = BrowserAction.ExecuteActionOn.Name;
            setAttributePassword.Selector.SelectorString = "pwd";
            templateElements.Add(new TemplateElement("enter password", enterPassword));

            BrowserAction handleJsDialog = new BrowserAction();
            SetJsPrompt   setJsPrompt    = new SetJsPrompt();

            setJsPrompt.NewInstance();
            handleJsDialog.ActionObject                   = setJsPrompt;
            setJsPrompt.ExpectedDialogType.Value          = GetJsPrompt.DialogTypes.Alert;
            setJsPrompt.ExpectedMessageText.IsRegex.Value = true;
            setJsPrompt.ExpectedMessageText.Value.Value   = "The following data would have been submitted";
            templateElements.Add(new TemplateElement("set jsdialog handler", handleJsDialog));

            SwitchWindowVisibility visibility2 = new SwitchWindowVisibility();

            visibility2.NewInstance();
            visibility2.Visible.Value = false;
            templateElements.Add(new TemplateElement("hide window", visibility2));

            BrowserAction clickSubmit  = new BrowserAction();
            InvokeSubmit  invokeSubmit = new InvokeSubmit();

            invokeSubmit.NewInstance();
            clickSubmit.ActionObject = invokeSubmit;
            invokeSubmit.Selector.SelectorExecuteActionOn        = BrowserAction.ExecuteActionOn.Name;
            invokeSubmit.Selector.SelectorString                 = "LoginForm";
            invokeSubmit.Selector.ExpectedNumberOfElements.Value = 1;
            templateElements.Add(new TemplateElement("submit form", clickSubmit));

            BrowserAction checkJsDialog = new BrowserAction();
            GetJsPrompt   getJsPrompt   = new GetJsPrompt();

            getJsPrompt.NewInstance();
            checkJsDialog.ActionObject                    = getJsPrompt;
            getJsPrompt.ExpectedDialogType.Value          = GetJsPrompt.DialogTypes.Alert;
            getJsPrompt.ExpectedMessageText.IsRegex.Value = true;
            getJsPrompt.ExpectedMessageText.Value.Value   = "The following data would have been submitted";
            TemplateElement templateElement2 = new TemplateElement("get jsdialog", checkJsDialog);

            templateElement2.SuccessConditions.Add(new Condition("Contains",
                                                                 Template.EncodeTemplateElementIdWithOutputName("", GetJsPrompt.KeyList.MessageText.ToString()),
                                                                 "The following data would have been submitted"));
            templateElements.Add(templateElement2);

            Template template = new Template(1,
                                             new StringOrRegex()
            {
                IsRegex = new InsecureBool(true), Value = new InsecureText("keepass")
            },
                                             "KeePass TestForm, some illegal chars: \"M\"\\a/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?", new PasswordCreationPolicy(), templateElements);

            AddTemplate(template);
            RefreshUI();
        }
Esempio n. 13
0
        public void SetAttribute_Constructor_ValidPath_Works()
        {
            var sut = new SetAttribute("/sites/site", "test", "a");

            Assert.AreEqual("/sites/site", sut.XPathForElement);
        }
Esempio n. 14
0
        public NewTemplateElement()
        {
            InitializeComponent();

            LoadUrl loadUrl = new LoadUrl();

            loadUrl.NewInstance();
            availableBaseObjects.Add(loadUrl);
            GetInputFromUser getInputFromUser = new GetInputFromUser();

            getInputFromUser.NewInstance();
            availableBaseObjects.Add(getInputFromUser);
            SwitchWindowVisibility switchWindowVisibility = new SwitchWindowVisibility();

            switchWindowVisibility.NewInstance();
            availableBaseObjects.Add(switchWindowVisibility);
            ElementToLoad elementToLoad = new ElementToLoad();

            elementToLoad.NewInstance();
            availableBaseObjects.Add(elementToLoad);
            EventToTrigger eventToTrigger = new EventToTrigger();

            eventToTrigger.NewInstance();
            availableBaseObjects.Add(eventToTrigger);
            GetAttribute getAttribute = new GetAttribute();

            getAttribute.NewInstance();
            availableBaseObjects.Add(getAttribute);
            GetHttpAuth getHttpAuth = new GetHttpAuth();

            getHttpAuth.NewInstance();
            availableBaseObjects.Add(getHttpAuth);
            GetImage getImage = new GetImage();

            getImage.NewInstance();
            availableBaseObjects.Add(getImage);
            GetJsPrompt getJsPrompt = new GetJsPrompt();

            getJsPrompt.NewInstance();
            availableBaseObjects.Add(getJsPrompt);
            GetStyle getStyle = new GetStyle();

            getStyle.NewInstance();
            availableBaseObjects.Add(getStyle);
            InvokeSubmit invokeSubmit = new InvokeSubmit();

            invokeSubmit.NewInstance();
            availableBaseObjects.Add(invokeSubmit);
            InvokeMouseClick invokeMouseClick = new InvokeMouseClick();

            invokeMouseClick.NewInstance();
            availableBaseObjects.Add(invokeMouseClick);
            JavascriptToExecute javascriptToExecute = new JavascriptToExecute();

            javascriptToExecute.NewInstance();
            availableBaseObjects.Add(javascriptToExecute);
            ResourceToLoad resourceToLoad = new ResourceToLoad();

            resourceToLoad.NewInstance();
            availableBaseObjects.Add(resourceToLoad);
            SetAttribute setAttribute = new SetAttribute();

            setAttribute.NewInstance();
            availableBaseObjects.Add(setAttribute);
            SetHttpAuth setHttpAuth = new SetHttpAuth();

            setHttpAuth.NewInstance();
            availableBaseObjects.Add(setHttpAuth);
            SetJsPrompt setJsPrompt = new SetJsPrompt();

            setJsPrompt.NewInstance();
            availableBaseObjects.Add(setJsPrompt);
            SetStyle setStyle = new SetStyle();

            setStyle.NewInstance();
            availableBaseObjects.Add(setStyle);
            SiteLoaded siteLoaded = new SiteLoaded();

            siteLoaded.NewInstance();
            availableBaseObjects.Add(siteLoaded);
            GetInnerText getInnerText = new GetInnerText();

            getInnerText.NewInstance();
            availableBaseObjects.Add(getInnerText);
            GetInnerHtml getInnerHtml = new GetInnerHtml();

            getInnerHtml.NewInstance();
            availableBaseObjects.Add(getInnerHtml);
            SetValue setValue = new SetValue();

            setValue.NewInstance();
            availableBaseObjects.Add(setValue);
            SecondsToWait secondsToWait = new SecondsToWait();

            secondsToWait.NewInstance();
            availableBaseObjects.Add(secondsToWait);
            InvokeFullKeyboardEvent invokeFullKeyBoardEvent = new InvokeFullKeyboardEvent();

            invokeFullKeyBoardEvent.NewInstance();
            availableBaseObjects.Add(invokeFullKeyBoardEvent);
        }
Esempio n. 15
0
 public void SetAttribute_Constructor_NullAttrName_Throws()
 {
     var sut = new SetAttribute("/site", null, "a");
 }
Esempio n. 16
0
        public void SetAttribute_Constructor_ValidAttrValue_Works()
        {
            var sut = new SetAttribute("/sites/site", "a", "test");

            Assert.AreEqual("test", sut.AttributeValue);
        }
Esempio n. 17
0
 public void SetAttribute_Constructor_NullAttrValue_Throws()
 {
     var sut = new SetAttribute("/site", "a", null);
 }
Esempio n. 18
0
 public void SetAttribute_Constructor_EmptyAttrName_Throws()
 {
     var sut = new SetAttribute("/site", string.Empty, "a");
 }