You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List of customers and suppliers
Supplier: Lucerne Publishing (https://www.lucernepublishing.com/)
Customer: Preston, Chris
Customer: Hines, Patrick
Customer: Cameron, Maria
Supplier: Graphic Design Institute (https://www.graphicdesigninstitute.com/)
Supplier: Fabrikam, Inc. (https://www.fabrikam.com/)
Customer: Seubert, Roxanne
Supplier: Proseware, Inc. (http://www.proseware.com/)
Customer: Adolphi, Stephan
Customer: Koch, Paul
To create a sample application that uses the custom dynamic object
publicenumStringSearchOption{StartsWith,Contains,EndsWith}internalclassReadOnlyFile:DynamicObject{// Store the path to the file and the initial line count value.privatestringp_filePath;// Public constructor. Verify that file exists and store the path in// the private variable.publicReadOnlyFile(stringfilePath){if(!File.Exists(filePath)){thrownewException("File path does not exist.");}p_filePath=filePath;}publicList<string>GetPropertyValue(stringpropertyName,StringSearchOptionStringSearchOption=StringSearchOption.StartsWith,booltrimSpaces=true){StreamReader?sr=null;List<string>results=new();stringline;stringtestLine;try{sr=newStreamReader(p_filePath);while(!sr.EndOfStream){line=sr.ReadLine();// Perform a case-insensitive search by using the specified search options.testLine=line.ToUpper();if(trimSpaces){testLine=testLine.Trim();}switch(StringSearchOption){caseStringSearchOption.StartsWith:if(testLine.StartsWith(propertyName.ToUpper())){results.Add(line);}break;caseStringSearchOption.Contains:if(testLine.Contains(propertyName.ToUpper())){results.Add(line);}break;caseStringSearchOption.EndsWith:if(testLine.EndsWith(propertyName.ToUpper())){results.Add(line);}break;}}}catch{// Trap any exception that occurs in reading the file and return null.results=null;}finally{if(sr!=null){sr.Close();}}returnresults;}// Implement the TryGetMember method of the DynamicObject class for dynamic member calls.publicoverrideboolTryGetMember(GetMemberBinderbinder,outobjectresult){result=GetPropertyValue(binder.Name);returnresult==null?false:true;}// Implement the TryInvokeMember method of the DynamicObject class for// dynamic member calls that have arguments.publicoverrideboolTryInvokeMember(InvokeMemberBinderbinder,object[]args,outobjectresult){StringSearchOptionStringSearchOption=StringSearchOption.StartsWith;booltrimSpaces=true;try{if(args.Length>0){StringSearchOption=(StringSearchOption)args[0];}}catch{thrownewArgumentException("StringSearchOption argument must be a StringSearchOption enum value.");}try{if(args.Length>1){trimSpaces=(bool)args[1];}}catch{thrownewArgumentException("trimSpaces argument must be a Boolean value.");}result=GetPropertyValue(binder.Name,StringSearchOption,trimSpaces);returnresult==null?false:true;}}