public DiscoveryRequestPayloadBuilder WithVerifiedIdentifiers(IdentifierType type, string value) { _patientVerifiedIdentifiers = new List <Identifier> { new Identifier(type, value) }; return(this); }
/// <summary> /// Creates a <see cref="UbisoftAccountRequest"/> targeting multiple users on the same <see cref="Platform"/> /// </summary> public UbisoftAccountRequest(IEnumerable <string> queries, Platform platform, IdentifierType identifierType) { Platform = platform; IdentifierType = identifierType; Identifiers = queries; }
public bool FindIdentifier(string name, IdentifierType type, out IdentifierSearchResult res) { res = new Assemble.IdentifierSearchResult(); switch (this.Type) { case enumStatementType.Instruction: { if (Instruction.FindIdentifier(name, type, out res)) { return(true); } } break; case enumStatementType.Block: { //Don't search sub block's contents if (Block.FindIdentifierOfThis(name, type, out res)) { return(true); } } break; } return(false); }
public override void ReadData(BinaryReader reader) { bool isOld = ModdedSaveData.LATEST_READ_VERSION < 4; int number = reader.ReadInt32(); if (number >= 3) { isOld = false; } if (number >= 3) { number -= 3; } idType = (IdentifierType)number; if (!isOld) { Version = reader.ReadInt32(); } longIdentifier = reader.ReadInt64(); stringIdentifier = isOld ? "" : reader.ReadString(); dataPiece = DataPiece.Deserialize(reader) as CompoundDataPiece; if (dataPiece == null) { throw new Exception("Invalid top level datapiece!"); } }
public static BaijiType BuildFieldType(ParseTreeNode fieldTypeNode) { BaijiType type = null; var fieldTypeChildNode = fieldTypeNode.ChildNodes[0]; if (fieldTypeChildNode.Term.Name == IdlGrammar.TNAME_TIDENTIFIER) { var identifier = fieldTypeChildNode.Token.Text; type = new IdentifierType(identifier); } else if (fieldTypeChildNode.Term.Name == IdlGrammar.NTNAME_TBASE_TYPE) { var baseTypeKeyword = fieldTypeChildNode.FindTokenAndGetText(); var bType = ConvertBaseTypeKeywordToBaseType(baseTypeKeyword); type = new BaseType(bType); } else if (fieldTypeChildNode.Term.Name == IdlGrammar.NTNAME_TCONTAINER_TYPE) { var containerTypeNode = fieldTypeChildNode.ChildNodes[0]; if (containerTypeNode.Term.Name == IdlGrammar.NTNAME_TMAP_TYPE) { var keyType = BuildMapKeyType(containerTypeNode.ChildNodes[0]); var valueType = BuildFieldType(containerTypeNode.ChildNodes[1]); type = new MapType(keyType, valueType); } else if (containerTypeNode.Term.Name == IdlGrammar.NTNAME_TLIST_TYPE) { var listValueType = BuildFieldType(containerTypeNode.ChildNodes[0]); type = new ListType(listValueType); } } return(type); }
public IdentifierTerminal(string name, IdentifierType identifierType) : base(name) { AllChars = Strings.AllLatinLetters + Strings.DecimalDigits + "-_"; AllFirstChars = Strings.AllLatinLetters; switch (identifierType) { case IdentifierType.CONSTANT: break; case IdentifierType.VARIABLE: AllFirstChars = "?"; break; case IdentifierType.VARIABLE_OR_CONSTANT: AllFirstChars += "?"; break; case IdentifierType.REQUIREMENT: AllFirstChars = ":"; break; default: Debug.Assert(false); break; } }
public static void SetIdentifiers(FI fi, IdentifierType identifierType, string[] identifiers, SymmetryEntities dc) { IList<FIIdentifier> list = null; { var currentIDs = fi.FIIdentifiers.Where(x => x.IdentifierType == identifierType); if (currentIDs != null && currentIDs.Any()) list = currentIDs.ToList(); } foreach (var identifier in identifiers) { if (string.IsNullOrEmpty(identifier)) continue; if (list == null) { fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier }); } else if (list.Any(x => string.Compare(x.Identifier, identifier, true) == 0)) // already exists { list.Remove(list.First(x => string.Compare(x.Identifier, identifier, true) == 0)); // remove from the list of existing } else { fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier }); } } // if we have any left in the original list, then remove them all if (list != null && list.Any()) foreach (var v in list) dc.Entry(v).State = EntityState.Deleted; }
private IEnumerable <Identifier> GetIdentifierParts(string source) { int index = 0; int partLocation = 0; var partType = IdentifierType.Literal; IdentifierType nextType = IdentifierType.None; for (int i = 0; i < source.Length; i++) { IdentifierTypeFromCharacter(source[i], ref nextType); if (nextType != IdentifierType.None) { yield return(new Identifier { Name = source.Substring(index, i - index), Type = partType }); index = i + 1; partType = nextType; nextType = IdentifierType.None; } } yield return(new Identifier { Name = source.Substring(index), Type = partType }); }
///<summary>Gets a list of all external ID's for the internal ID and type provided. Used to construct outbound HL7 messages.</summary> public static List<OIDExternal> GetByInternalIDAndType(long idInternal,IdentifierType idType) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { return Meth.GetObject<List<OIDExternal>>(MethodBase.GetCurrentMethod(),idInternal,idType); } string command="SELECT * FROM oidexternal WHERE IDType='"+idType.ToString()+"' AND IDInternal="+POut.Long(idInternal); return Crud.OIDExternalCrud.SelectMany(command); }
internal bool FindIdentifierDefaultNameForType(Type type, IdentifierType identifier, string memberName) { ConcurrentDictionary <IdentifierType, string> identifierNames = null; if (defaultIdentifierNamesForType.TryGetValue(type, out identifierNames)) { string resolvedName = null; if (identifierNames.TryGetValue(identifier, out resolvedName)) { return(memberName == resolvedName); } } else { identifierNames = new ConcurrentDictionary <IdentifierType, string>(); defaultIdentifierNamesForType.TryAdd(type, identifierNames); } Func <Type, string> f = null; if (!defaultIdentifierFuncs.TryGetValue(identifier, out f)) { return(false); } if (memberName == f(type)) { identifierNames[identifier] = memberName; return(true); } return(false); }
public static string getIdentifier(IdentifierType t) { int i = 3; if (t == IdentifierType.ORDER) { i = 20; } if (t == IdentifierType.PRODUCT) { i = 10; } if (t == IdentifierType.USER) { i = 5; } if (t == IdentifierType.CATEGORY) { i = 4; } if (t == IdentifierType.PROFILE) { i = 15; } const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZzxcvbnmalskdjfhgpqowieuryt0123456789"; return(new string(Enumerable.Repeat(chars, i) .Select(s => s[r.Next(s.Length)]).ToArray())); }
public VoidedDocumentsLineType[] getVoidedDocumentsLine() { VoidedDocumentsLineType HILT = new VoidedDocumentsLineType(); VoidedDocumentsLineType[] MILT = new VoidedDocumentsLineType[RAD.Count]; MS.GeneraLog.IngresoBD01("Se añaden a la cola los siguientes documentos, para luego actualiza su estado"); for (int i = 0; i < RAD.Count; ++i) { RAC.DOC_UPD_LIST.Add($"{MS.RucNumber}-{RAD[i].TPO_CPE}-{RAD[i].DOC_SER}-{RAD[i].DOC_NUM.ToString().PadLeft(8, '0')}"); MS.GeneraLog.IngresoBD01($"{MS.RucNumber}-{RAD[i].TPO_CPE}-{RAD[i].DOC_SER}-{RAD[i].DOC_NUM.ToString().PadLeft(8, '0')}"); MILT[i] = new VoidedDocumentsLineType(); LineIDType LIT = new LineIDType(); LIT.Value = (i + 1).ToString(); MILT[i].LineID = LIT; DocumentTypeCodeType DTCT = new DocumentTypeCodeType(); DTCT.Value = RAD[i].TPO_CPE; MILT[i].DocumentTypeCode = DTCT; IdentifierType IT1 = new IdentifierType(); IT1.Value = RAD[i].DOC_SER; MILT[i].DocumentSerialID = IT1; IdentifierType IT2 = new IdentifierType(); IT2.Value = RAD[i].DOC_NUM.ToString().PadLeft(8, '0'); MILT[i].DocumentNumberID = IT2; TextType TT = new TextType(); TT.Value = RAD[i].DOC_DES; MILT[i].VoidReasonDescription = TT; } return(MILT); }
public void AssertElementExistsWithTimeoutFailsTest(IdentifierType identType, string identifier, double timeOutLengthMilliseconds, string tagName) { DateTime startTime = DateTime.MinValue; bool correctTime = false; bool threwException = false; bool checkTimeout = timeOutLengthMilliseconds > 0; try { startTime = DateTime.Now; _browser.AssertElementExistsWithTimeout(identType, identifier, timeOutLengthMilliseconds, tagName); } catch (AssertionFailedException) { DateTime exceptionTime = DateTime.Now; threwException = true; if (timeOutLengthMilliseconds > 0) { double expectedTimeoutModifier = (_browserType == BrowserType.Safari) ? 4000 : 2000; // since safari is ran on another computer, we need to expect a delay. if (exceptionTime < startTime.AddMilliseconds(timeOutLengthMilliseconds + expectedTimeoutModifier)) //we should get our exception within the timeout value within 2 second. //Increased due to sending 2 messages within the loop correctTime = true; } } catch (ArgumentException) { threwException = true; } Assert.IsTrue(threwException, "AssertElementExists passed when it should have failed."); if (checkTimeout) Assert.IsTrue(correctTime, "AssertElementExists threw the correct exception but not within the timeout value."); }
public GenericLexer(IdentifierType idType = IdentifierType.Alpha, BuildExtension <IN> extensionBuilder = null, params GenericToken[] staticTokens) { InitializeStaticLexer(idType, staticTokens); derivedTokens = new Dictionary <GenericToken, Dictionary <string, IN> >(); ExtensionBuilder = extensionBuilder; }
/** In the event that the element var goes stale, * re-call ths meathod, * or re-declare the element within the test **/ private void GetElement(IdentifierType idType, string id = null) { switch (idType) { case IdentifierType.automationId: baseElement = window.FindFirstDescendant(cf => cf.ByAutomationId(id)); break; case IdentifierType.xPath: baseElement = window.FindFirstByXPath(id); break; case IdentifierType.name: baseElement = window.FindFirstDescendant(cf => cf.ByName(id)); break; case IdentifierType.text: baseElement = window.FindFirstDescendant(cf => cf.ByText(id)); break; case IdentifierType.menu: baseElement = window.FindFirstChild(cf => cf.Menu()); break; } }
/// <summary> /// Constructs the typed list rule from the specified parameters. /// </summary> /// <param name="p">Parent master grammar.</param> /// <param name="itemIdentifierType">Item identifier type.</param> /// <returns>Typed list grammar rule.</returns> public static NonTerminal ConstructTypedListRule(MasterGrammar p, IdentifierType itemIdentifierType) { // NON-TERMINAL AND TERMINAL SYMBOLS var typedList = new NonTerminal("Typed list", typeof(TypedListAstNode)); var singleTypedList = new NonTerminal("Single typed list", typeof(TransientAstNode)); var typeDeclaration = new NonTerminal("Type declaration", typeof(TransientAstNode)); var type = new NonTerminal("Type", typeof(TransientAstNode)); var typePlusList = new NonTerminal("Type list", typeof(TransientAstNode)); var identifiersList = new NonTerminal("Typed list identifiers", typeof(TransientAstNode)); var itemIdentifier = new IdentifierTerminal("Item identifier", itemIdentifierType); var typeIdentifier = new IdentifierTerminal("Type identifier", IdentifierType.CONSTANT); // RULES typedList.Rule = p.MakeStarRule(typedList, singleTypedList); singleTypedList.Rule = identifiersList + typeDeclaration; identifiersList.Rule = p.MakeStarRule(identifiersList, itemIdentifier); typeDeclaration.Rule = p.Empty | ("-" + type); type.Rule = typeIdentifier | ("(" + p.ToTerm("either") + typePlusList + ")"); typePlusList.Rule = p.MakePlusRule(typePlusList, typeIdentifier); return(typedList); }
public static string ToAttributeName(this IdentifierType identifierType) { switch (identifierType) { case IdentifierType.None: return(null); case IdentifierType.Key: return(ArangoAttributes.Key); case IdentifierType.Handle: return(ArangoAttributes.Id); case IdentifierType.Revision: return(ArangoAttributes.Revision); case IdentifierType.EdgeFrom: return(ArangoAttributes.EdgeFrom); case IdentifierType.EdgeTo: return(ArangoAttributes.EdgeTo); default: return(null); } }
/// <summary> /// Marshall the fields of a persistent instance to a prepared statement /// </summary> /// <param name="id"></param> /// <param name="fields">The fields to write to the command.</param> /// <param name="includeProperty">A bool indicating if the Property should be written to the Command</param> /// <param name="st"></param> /// <param name="session"></param> /// <returns></returns> protected virtual int Dehydrate(object id, object[] fields, bool[] includeProperty, IDbCommand st, ISessionImplementor session) { if (log.IsDebugEnabled) { log.Debug("Dehydrating entity: " + MessageHelper.InfoString(this, id)); } int index = 0; // there's a pretty strong coupling between the order of the SQL parameter // construction and the actual order of the parameter collection. for (int j = 0; j < HydrateSpan; j++) { if (includeProperty[j]) { PropertyTypes[j].NullSafeSet(st, fields[j], index, session); index += propertyColumnSpans[j]; } } if (id != null) { IdentifierType.NullSafeSet(st, id, index, session); index += IdentifierColumnNames.Length; } return(index); }
public static ItemIdentificationType ItemIdentification(IdentifierType id = null) { return(new ItemIdentificationType { ID = id }); }
private void InitializeIdentifier(IdentifierType idType = IdentifierType.Alpha) { // identifier FSMBuilder.GoTo(start). RangeTransition('a', 'z'). Mark(in_identifier) .End(GenericToken.Identifier); FSMBuilder.GoTo(start). RangeTransitionTo('A', 'Z', in_identifier). RangeTransitionTo('a', 'z', in_identifier). RangeTransitionTo('A', 'Z', in_identifier). End(GenericToken.Identifier); if (idType == IdentifierType.AlphaNumeric || idType == IdentifierType.AlphaNumericDash) { FSMBuilder.GoTo(in_identifier). RangeTransitionTo('0', '9', in_identifier); } if (idType == IdentifierType.AlphaNumericDash) { FSMBuilder.GoTo(in_identifier). TransitionTo('-', in_identifier). TransitionTo('_', in_identifier); FSMBuilder.GoTo(start). TransitionTo('_', in_identifier); } }
/// <summary> /// Construct a new DownloadFileAction /// </summary> /// <param name="authorizationSession">The authorization session to use</param> /// <param name="fileDestination">The file destination for the downloaded file</param> /// <param name="identifier">The identifier</param> /// <param name="downloadIdentifierType">The type of identifier</param> private DownloadFileAction( BackblazeB2AuthorizationSession authorizationSession, string fileDestination, string identifier, IdentifierType downloadIdentifierType ) : this(authorizationSession, new FileStream(fileDestination, FileMode.CreateNew), identifier, downloadIdentifierType) { }
/// <summary> /// Writes a floating point-valued TLV. /// </summary> /// <param name="IdentifierType">Type of identifier.</param> /// <param name="Identifier">Identifier.</param> /// <param name="Value">Value</param> public void Write(IdentifierType IdentifierType, ushort Identifier, double Value) { this.WriteName(Identifier); sb.Append(",\"v\":"); sb.Append(Value.ToString("F")); sb.Append('}'); }
///<summary>Returns the currently defined OID for a given IndentifierType. If not defined, IDroot will be empty string.</summary> public static OIDInternal GetForType(IdentifierType IDType) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { return Meth.GetObject<OIDInternal>(MethodBase.GetCurrentMethod(),IDType); } InsertMissingValues();// string command="SELECT * FROM oidinternal WHERE IDType='"+IDType.ToString()+"'";//should only return one row. return Crud.OIDInternalCrud.SelectOne(command); }
private string GetIdentifierData(string bpNumber, IdentifierType type) { var response = McfClient.GetAllIdentifiers(bpNumber); var results = response.Result.Results.ToList(); var identifier = results.FirstOrDefault(x => x.IdentifierType == type.ToString()); return(identifier?.IdentifierNo); }
/// <summary> /// Writes a Boolean valued TLV. /// </summary> /// <param name="IdentifierType">Type of identifier.</param> /// <param name="Identifier">Identifier.</param> /// <param name="Value">Value</param> public void Write(IdentifierType IdentifierType, ushort Identifier, bool Value) { this.WriteName(Identifier); sb.Append(",\"bv\":"); sb.Append(Value ? "true" : "false"); sb.Append('}'); }
public Identifier(string number, IdentifierType idtype) : this(number) { if (idtype != this.identifierType) { isValid = false; this.identifierType = idtype; } }
/// <summary> /// Writes a string-valued TLV. /// </summary> /// <param name="IdentifierType">Type of identifier.</param> /// <param name="Identifier">Identifier.</param> /// <param name="Value">Value</param> public void Write(IdentifierType IdentifierType, ushort Identifier, string Value) { this.WriteName(Identifier); sb.Append(",\"sv\":\""); sb.Append(Value); sb.Append("\"}"); }
public GenericLexer(IdentifierType idType = IdentifierType.Alpha, BuildExtension <IN> extensionBuilder = null, params GenericToken[] staticTokens) : this(new Config { IdType = idType, ExtensionBuilder = extensionBuilder }, staticTokens) { }
public IdentifierInfo(string name, string fullName, IdentifierType type, TypeReference dataType) { this.Name = name; this.FullName = fullName; this.Type = type; this.DataType = dataType; this.Reference = dataType.DynamicType; }
public ISO3166(object identifier, IdentifierType identifiertype) { try { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { ISO3166 iso = null; switch (identifiertype) { case IdentifierType.Id: iso = (from a in context.ISO3166s where a.Id == (int)identifier && a.ParentId == null select a).SingleOrDefault(); break; case IdentifierType.Country_Code_Alpha2: iso = (from a in context.ISO3166s where a.Alpha2 == (string)identifier && a.ParentId == null select a).SingleOrDefault(); break; case IdentifierType.Country_Code_Alpha3: iso = (from a in context.ISO3166s where a.Alpha3 == (string)identifier && a.ParentId == null select a).SingleOrDefault(); break; case IdentifierType.Country_Code_Numeric: iso = (from a in context.ISO3166s where a.Numeric == (int)identifier && a.ParentId == null select a).SingleOrDefault(); break; case IdentifierType.Level1_Subdivision_Code: iso = (from a in context.ISO3166s where a.Level1_Subdivision == (string)identifier select a).SingleOrDefault(); break; case IdentifierType.Level2_Subdivision_Code: iso = (from a in context.ISO3166s where a.Level2_Subdivision == (string)identifier select a).SingleOrDefault(); break; case IdentifierType.Name: iso = (from a in context.ISO3166s where a.Name == (string)identifier select a).SingleOrDefault(); break; case IdentifierType.DisplayName: iso = (from a in context.ISO3166s where a.DisplayName == (string)identifier select a).SingleOrDefault(); break; } if (iso == null) { throw new ObjectNotFoundException(identifier, identifiertype); } else { this.Id = iso.Id; this.Alpha2 = iso.Alpha2; this.Alpha3 = iso.Alpha3; this.Numeric = iso.Numeric; this.Level1_Subdivision = iso.Level1_Subdivision; this.Level2_Subdivision = iso.Level2_Subdivision; this.Name = iso.Name; this.ParentId = iso.ParentId; this.SFGCode = iso.SFGCode; this.DisplayName = iso.DisplayName; } } } catch { throw new IdentifierNotUniqueException(identifier, identifiertype); } }
/// <summary> /// Writes a TLV. /// </summary> /// <param name="IdentifierType">Type of identifier.</param> /// <param name="Identifier">Identifier.</param> /// <param name="Value">Value</param> public virtual void Write(IdentifierType IdentifierType, ushort Identifier, byte[] Value) { int c = Value.Length; byte b; b = (byte)IdentifierType; if (Identifier >= 256) { b |= 32; } if (c > 0xffffff) { throw new ArgumentOutOfRangeException("Value too large.", nameof(Value)); } else if (c > 0xffff) { b |= 24; } else if (c > 0xff) { b |= 16; } else if (c > 7) { b |= 8; } else { b |= (byte)c; } this.ms.WriteByte(b); if (Identifier >= 256) { this.ms.WriteByte((byte)(Identifier >> 8)); } this.ms.WriteByte((byte)Identifier); if (c > 0xffff) { this.ms.WriteByte((byte)(c >> 16)); } if (c > 0xff) { this.ms.WriteByte((byte)(c >> 8)); } if (c > 7) { this.ms.WriteByte((byte)c); } this.ms.Write(Value, 0, Value.Length); }
//methods public void addItemIdentifier(IdentifierType idType, string identifier) { ItemIdentifier newID = new ItemIdentifier(); newID.IDType = idType; newID.Identifier = identifier; this.ItemIdentifiers.Add(newID); }
public bool RegisterId(IdentifierType identifierType, ushort identifier, string idname) { if (identifiers[identifier] == true) { identifiers[identifier] = false; return(true); } return(false); }
private UserIdentifier(string value, IdentifierType type) { if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("value"); } this.Value = value; this.Type = type; }
public IdentifierValidatorAttribute(IdentifierType type) : base( type == IdentifierType.PascalAscii ? PascalAscii : type == IdentifierType.Ascii ? Ascii: type == IdentifierType.International ? International : null ) { this.type = type; }
public static string[] GetFIIdentifiers(string symmetryCode, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw) { try { return dc.FIIdentifiers.Where(x => x.FI.SymmetryCode.Equals(symmetryCode, StringComparison.InvariantCultureIgnoreCase) && x.IdentifierType == identifierType) .Select(x => x.Identifier).ToArray(); } catch (Exception ex_) { Exceptions.Rethrow("GetFIIdentiers", behavior, ex_); } return null; }
public static string GetFIIdentifier(string symmetryCode, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw) { try { var fiID = dc.FIIdentifiers.SingleOrDefault(i => i.FI.SymmetryCode.Equals(symmetryCode, StringComparison.InvariantCultureIgnoreCase) && i.IdentifierType == identifierType); return fiID==null ? null : fiID.Identifier; } catch (Exception ex) { Exceptions.Rethrow("GetFIIdentifier", behavior, ex); } return null; }
public static FI GetFIByIdentifier(string identifier, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw) { try { var identifierEntry = dc.FIIdentifiers.SingleOrDefault(i => i.IdentifierType == identifierType && i.Identifier.Equals(identifier, StringComparison.InvariantCultureIgnoreCase)); if (identifierEntry != null) { return identifierEntry.FI; } } catch (Exception ex) { Exceptions.Rethrow("GetFIByIdentifier", behavior, ex); } return null; }
public static void SetOrUpdateIdentifier(FI fi, IdentifierType identifierType, string identifier, SymmetryEntities dc) { if (!string.IsNullOrWhiteSpace(identifier)) { var id = fi.FIIdentifiers.SingleOrDefault(i => i.IdentifierType == identifierType); if (id == null) { fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier }); } else { if (id.Identifier != identifier) { id.Identifier = identifier; FIChangeTracking.SetModified(id, dc); } } } }
//private ExpressionToken GetInnerParentAttribute(ExpressionToken token, ref IHTMLElement element) //{ // while (token.Attribute.StartsWith("parentElement")) // { // isParent = true; // element = element.parentElement; // token.Attribute = token.Attribute.Remove(0, "parentElement.".Length); // } // return token; //} private IHTMLElement findElements(HTMLDocument doc, IdentifierType identType, string identifier, IdentifierExpression identExp, string tagName) { IHTMLElement elem = null; elem = findElement(doc, identType, identifier, identExp, tagName); if (elem == null) { object index = 0; int frames = doc.frames.length; for (int i = 0; i < frames; i++) { index = i; IHTMLDocument2 _docBypassSecurity = CrossFrameIE.GetDocumentFromWindow((IHTMLWindow2)doc.frames.item(ref index)); HTMLDocument _docFullAccess = (HTMLDocument)_docBypassSecurity; //elem = findElements((HTMLDocument)((HTMLWindow2)doc.frames.item(ref index)).document, identType, identifier, tagName); elem = findElements((HTMLDocument)_docFullAccess, identType, identifier, identExp, tagName); if (elem != null) break; } } return elem; }
private IHTMLElement getElement(IdentifierType identType, string identifier, string tagName, int timeOut) { IHTMLElement elem = null; DateTime startTime = DateTime.Now; while (DateTime.Now < startTime.AddSeconds(timeOut)) { try { elem = findElements(_doc, identType, identifier, tagName); } catch (Exception) { } //if (elem == null) // System.Threading.Thread.Sleep(1000); if (elem != null) break; } if (elem == null) { if (SWAT.WantInformativeExceptions.GetInformativeExceptions) throw new ElementNotFoundException(identifier, identType, tagName); else throw new ElementNotFoundException(identifier, identType); } return elem; }
private IHTMLElement getElement(IdentifierType identType, string identifier, string tagName) { return getElement(identType, identifier, tagName, DefaultTimeouts.FindElementTimeout); }
public void PressKeys(IdentifierType identType, string identifier, string word, string tagName) { waitForBrowser(); IHTMLElement elem = getElement(identType, identifier, tagName); _keyEvents = new List<KeyEventStatus>(); if (!(((IHTMLElement3)elem).isDisabled) && (elem is IHTMLInputElement)) { int length = word.Length; int elemMaxLength = ((IHTMLInputElement)elem).maxLength; if (elemMaxLength < length) length = elemMaxLength; // Fire the key events for each character in the word char[] characters = word.ToCharArray(); for (int charIndex = 0; charIndex < length; charIndex++) { _keyCode = (int)characters[charIndex]; // onkeydown, onkeypress, onkeyup are all fired when this is called fireKeyEvents((IHTMLElement3)elem); } // Build a string based on which events were fired successfully StringBuilder msg = new StringBuilder(); for (int charIndex = 0; charIndex < length; charIndex++) { string subString = word.Substring(charIndex, 1); if (keyEventsFired(_keyEvents[charIndex])) msg.Append(subString); } toggleElementColor((IHTMLElement)elem); // Set the value of the input element string currentElementValue = (string)elem.getAttribute("value", 0); if (currentElementValue != null) elem.setAttribute("value", currentElementValue + msg.ToString(), 0); else elem.setAttribute("value", msg.ToString(), 0); } else throw new ArgumentException("Can't type text in a non-input or disabled element."); }
public SecurityRequest() { // default these to none to force them to set at least one in the request IdentifierType = IdentifierType.NONE; GoldKey = GoldKey.NONE; }
public override AstNode VisitIdentifierType(IdentifierType ast) { ast.ResolvedType = ResolveTypeRef(ast.Type); return ast; }
private void SetFileInputPath(IdentifierType identType, string identifier, string filePath, string tagName) { if (!File.Exists(filePath)) { throw new FileNotFoundException(string.Format("Could not find file {0}", filePath)); } ElementFireEvent(identType, identifier, tagName, "onclick"); waitForBrowserReadyOnly(); //Sleep(2000); StringBuilder className = new StringBuilder(255); StringBuilder btnName = new StringBuilder(255); IntPtr dialogHwnd = IntPtr.Zero; List<IntPtr> windowChildren = new List<IntPtr>(); for (int i = 0; i < 30; i++) { dialogHwnd = NativeMethods.FindWindow("#32770", "Choose File"); //Specific window title for IE8 if (dialogHwnd == IntPtr.Zero) dialogHwnd = NativeMethods.FindWindow("#32770", "Choose File to Upload"); if (dialogHwnd != IntPtr.Zero) { //Now find the combobox fill in box windowChildren = NativeMethods.GetWindowChildren(dialogHwnd); foreach (IntPtr dlgComboBox in windowChildren) { NativeMethods.GetClassName(dlgComboBox, className, className.MaxCapacity); //get the childs's type if (string.Equals(className.ToString(), "ComboBoxEx32")) { IntPtr comboBoxTxt = NativeMethods.GetChildWindowHwnd(dlgComboBox, "Edit"); //find the combobox ////old implementation //for (int tempCtr = 0; tempCtr < filePath.Length; tempCtr++) //send the text // sendKeyPressToHwnd((uint)filePath[tempCtr], comboBoxTxt); //reimplemented using .net UIAutomation library AutomationElement editBox = AutomationElement.FromHandle(comboBoxTxt); ValuePattern valuePattern = (ValuePattern)editBox.GetCurrentPattern(ValuePattern.Pattern); valuePattern.SetValue(filePath); break; } } //Click on the OK Button foreach (IntPtr okBtn in windowChildren) { NativeMethods.GetWindowText(okBtn, btnName, btnName.Capacity); if (string.Equals(btnName.ToString(), "&Open")) // we found the OK Button { NativeMethods.RECT placement = new NativeMethods.RECT(); NativeMethods.GetClientRect(okBtn, out placement); uint lParam = (uint)((placement.Left + 1 * 0x010000) + placement.Top + 1); //Find it's coordinates and generate the parameter //click on it NativeMethods.SendMessage(okBtn, 0x201, 0x000, lParam); //WM_LBUTTONDOWN NativeMethods.SendMessage(okBtn, 0x202, 0x000, lParam); //WM_LBUTTONUP break; } } break; } else { //Sleep(1000); } } if (dialogHwnd == IntPtr.Zero) { throw new Exception(string.Format("Could not find file input dialog handle")); } }
public void SetElementAttribute(IdentifierType identType, string identifier, string tagName, AttributeType attributeType, string attributeName, string attributeValue) { SetElementAttribute(identType, identifier, tagName, attributeType, attributeName, attributeValue, DefaultTimeouts.FindElementTimeout); }
public void SetElementAttribute(IdentifierType identType, string identifier, string tagName, AttributeType attributeType, string attributeName, string attributeValue, int timeOut) { isBrowserAccessible(); waitForBrowser(); IHTMLElement elem; elem = (IHTMLElement)getElement(identType, identifier, tagName, timeOut); toggleElementColor(elem); if (elem.outerHTML.Contains("type=file")) { //the element IS a file input SetFileInputPath(identType, identifier, attributeValue, tagName); } else if (elem.outerHTML.ToString().Contains("type=checkbox") && attributeName.Equals("checked", StringComparison.OrdinalIgnoreCase)) { if (attributeValue.ToLower().Equals("true")) elem.setAttribute(attributeName, " ", 0); else if (attributeValue.ToLower().Equals("false")) elem.setAttribute(attributeName, "", 0); } else { elem.setAttribute(attributeName, attributeValue, 0); } }
public void ElementFireEvent(IdentifierType identType, string identifier, string tagName, string eventName) { isBrowserAccessible(); waitForBrowser(); IHTMLElement3 elem = (IHTMLElement3)getElement(identType, identifier, tagName); _eventInfo = new ElementEventInfo(); //if (isParent && eventName.Equals("onclick") && !identifier.Contains(";")) //{ // searchedParent = true; // isParent = false; // //multiple casting to make sure it will perform the even on the first child found // if (elem is HTMLDivElement) // { // IHTMLElement3 childElem = (IHTMLElement3)(((HTMLDivElement)elem).firstChild); // _eventInfo.elem = childElem; // _eventInfo.eventName = eventName; // } // else if (elem is HTMLTableCellClass) // { // IHTMLElement3 childElem = (IHTMLElement3)(((HTMLTableCell)elem).firstChild); // _eventInfo.elem = childElem; // _eventInfo.eventName = eventName; // } // else if (elem is HTMLAnchorElement) // { // IHTMLElement3 childElem = (IHTMLElement3)(((HTMLAnchorElement)elem).firstChild); // _eventInfo.elem = childElem; // _eventInfo.eventName = eventName; // } //} //else //{ // isParent = false; // _eventInfo.elem = elem; // _eventInfo.eventName = eventName; //} _eventInfo.elem = elem; _eventInfo.eventName = eventName; toggleElementColor((IHTMLElement)elem); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(fireTheEvent)); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); //When debugging you can increase this time so the thread doesn't stop before you step into fireTheEvent //t.Join(20000); t.Join(2000); if (_eventInfo.exception != null) { throw new StimulateElementException(identifier, eventName); } if (t.IsAlive) t.Interrupt(); // Give the operating system time in case our stimulate element caused the window to close Sleep(100); }
public ObjectNotFoundException(object identifier, IdentifierType identifiertype) { id = identifier; idtype = identifiertype; }
public IdentifierNotUniqueException(object identifier, IdentifierType identifiertype) { id = identifier; idtype = identifiertype; }
//This findElements will build the IdentifierExpression before calling the recursive findElements private IHTMLElement findElements(HTMLDocument doc, IdentifierType identType, string identifier, string tagName) { IdentifierExpression identExp = null; switch (identType) { case IdentifierType.Expression: return findElements(doc, identType, identifier, new IdentifierExpression(identifier, new IsMatchHandler(IsMatchMethod)), tagName); //GetElementsByNAame does not work correctly in IE with frames. case IdentifierType.Name: identType = IdentifierType.Expression; identifier = "name=" + identifier; return findElements(doc, identType, identifier, new IdentifierExpression(identifier, new IsMatchHandler(IsMatchMethod)), tagName); //GetElementByID has problems with name and id attributes under IE. case IdentifierType.Id: //Only try getElementByID if no tags are specified otherwise do by Expression. if (tagName != TagName.ALL_TAGS) { identType = IdentifierType.Expression; identifier = "id=" + identifier; return findElements(doc, identType, identifier, new IdentifierExpression(identifier, new IsMatchHandler(IsMatchMethod)), tagName); } break; } return findElements(doc, identType, identifier, identExp, tagName); }
public IHTMLElement findElement(HTMLDocument doc, IdentifierType identType, string identifier, IdentifierExpression identExp, string tagName) { IHTMLElement elem = null; IHTMLElementCollection elements; elements = null; switch (identType) { //If getElementByID does not work then try byExpression which is more thorough. case IdentifierType.Id: IHTMLElement elementFound = doc.getElementById(identifier); if ((elementFound != null) && (elementFound.id == identifier)) return elementFound; else return null; case IdentifierType.InnerHtml: elements = GetElements(tagName, doc); foreach (IHTMLElement el in elements) { if (el.innerHTML != null && el.innerHTML.Equals(identifier, StringComparison.OrdinalIgnoreCase)) return el; } break; case IdentifierType.InnerHtmlContains: elements = GetElements(tagName, doc); foreach (IHTMLElement el in elements) { if (el.innerHTML != null && el.innerHTML.IndexOf(identifier, 0, StringComparison.OrdinalIgnoreCase) > -1) return el; } break; case IdentifierType.Expression: elements = GetElements(tagName, doc); return this.getElementByExp(identExp, elements); } return elem; }
public string GetElementAttribute(IdentifierType identType, string identifier, string tagName, AttributeType attributeType, string attributeName) { return GetElementAttribute(identType, identifier, tagName, attributeType, attributeName, DefaultTimeouts.FindElementTimeout); }
public string GetElementAttribute(IdentifierType identType, string identifier, string tagName, AttributeType attributeType, string attributeName, int timeOut) { isBrowserAccessible(); waitForBrowser(); IHTMLElement elem = null; elem = getElement(identType, identifier, tagName, timeOut); object result = elem.getAttribute(attributeName, 0); if (result != null && result.GetType() != typeof(System.DBNull)) return result.ToString(); return ""; }
public void AssertElementIsActive(IdentifierType identType, string identifier, string tagName, int timeoutSeconds) { isBrowserAccessible(); waitForBrowser(); IHTMLElement elem = getElement(identType, identifier, tagName, timeoutSeconds); toggleElementColor(elem); IHTMLElement activeElem = null; DateTime timeout = DateTime.Now.AddSeconds(2); do { activeElem = findActiveElement(_doc); } while (elem != null && !elem.Equals(activeElem) && DateTime.Now < timeout); toggleElementColor(activeElem); if (!elem.Equals(activeElem)) { if (WantInformativeExceptions.GetInformativeExceptions) throw new ElementNotActiveException(identifier, identType, tagName); else throw new ElementNotActiveException(identifier, identType); } }
public IdentifierInfo(IdentifierType type, string identifier) { this.identifierType = type; this.identifier = identifier; }
public AoKnownTypeAttribute(int offset, IdentifierType identifierType) { this.offset = offset; this.identifierType = identifierType; }
/// <summary> /// Refresh our cache of nhs number, this method will throw an exception if /// identifierType is NhsNumber and text is not a valid nhs number /// </summary> /// <param name="identifierType">Identifier type</param> /// <param name="text">identifier text</param> private void RefreshNhsNumberCache(IdentifierType identifierType, string text) { if (identifierType == IdentifierType.NhsNumber && text.Length > 0) { this.nhsNumber = new NhsNumber(text); } else { this.nhsNumber = null; } }
private void IdentifierTypeFromCharacter(char character, ref IdentifierType currentType) { switch (character) { case ':': currentType = IdentifierType.Type; break; case '#': currentType = IdentifierType.Id; break; case '.': currentType = IdentifierType.Class; break; } }